When I learned to program, hardware and storage were scarce. It is imperative for the code to be tight and the speed of execution is and remains a first and foremost concern. Achieving this isn’t always easy and often requires some very sophisticated programming techniques.
If there was ever a time or place to demand comments, a clever or complicated code sequence is it. Many books and courses will tell you to comment on your code and many experienced programmers do an excellent job of doing so. Writing clear and useful comments is as much a skill as it is a discipline.
The coding style where indentation, line length (80 characters maximum), avoiding the use of global variables and writing single purpose functions also help to understand and debug the code. Make your comments relevant and don’t restate what should already be clear.
Some will argue that good well-written code is self-documenting although my experience strongly suggests otherwise. Well-worded variable names are helpful; however, their intended purpose may not always be clear. Functions, subroutines, or classes may also have well-defined names yet arguments and/or parameters and results may not be.
I recently found myself having to debug a program I wrote over a year ago. The application was working on all machines but one. I learned that the client replaced the computer with an old legacy system. Fortunately, I have been working with PC’s for more years than I care to admit and understand what was happening and why.
Needless to say, were it not for the comments, fixing the issue in the actual code would’ve been a daunting task otherwise. The very sections of code that were to occupy my time were cause for previous visits. The comments clearly describe what the code sequence is supposed to do and the potential caveats to avoid.
Good Meaningful Comments
All of my code modules have an opening comment block that, aside from the author(s), date created, purpose, and revision, provide specific details regarding the methods/techniques and how they are used in the code to follow. Even the method of versioning the module is clearly outlined.
Complete history with version/revision number, date, and description of the changes accompanies the opening block. The specific changes are dated and documented in the revised code segments as well. Dating the changes in my code serves as a frame of reference and allows me to better recall the events that triggered the changes in the first place.
System.out.println(“Don’t use block comments to block out code\n”);
Rule of Thumb
A good “rule of thumb” is to provide sufficient comments to reteach yourself or to teach others what the code is supposed to do. I also provide ample warnings and advise of possible side effects that code changes may introduce.
If there is ever a place to serve yourself best in your coding skills, it’s in the comments. Everything that appears fresh today will be everything but fresh a year from now. A well-documented program requires focus and discipline, but the effort will make the debugging process so much easier when you visit your work in the near or distant future.
Microsoft’s DoWhy Library for Python greatly simplifies the task of estimating causal effects. If you or someone you know is involved in data analysis, it is worth your while to see what DoWhy can do for you.
I have spent a little time working with the library and although I have no coding examples at this time, the powerful nature of this library prevents me from waiting to share it.
Visit the DoWhy github page for more details on the DoWhy library. The information and documentation presented on the site provide sufficient detail to download and start working with the DoWhy library.
Learning to address various coding problems is directly dependent on the knowledge and tools with which you are already familiar. Be reminded however that just because they work doesn’t mean they are as effective or as efficient as they could be.
Of course, there is always Google, however, the information is typically solution oriented without the full benefit of scope or context. As I’ve said before, “Be careful who teaches you.” Unless you understand the code you are using, resorting to a “searched” solution may be cause for more trouble than it’s worth.
Creating Vector Graphics
Adobe Illustrator is a great product but also demands a monthly subscription fee which, unless you’re a professional web developer, isn’t something too many of us want to add to our monthly budget.
An SVG Editor (by henoc) is available for Microsoft’s Visual Studio Code that can simplify the task of working with SVG. You may also wish to consider using:
Vectr, a free cross-platform vector graphics editor, that allows you to create scalable vector graphics in 2D. You can use the online version or download a copy of the application for your operating system (Windows, Mac, Linux, or Chromebook).
Inkscape a professional vector graphics editor for Windows, Mac OSx and Linux. Free and open source.
Gravit Designer is a very capable and powerful design tool. You can use the online version or download a copy of the application for your platform (Mac OSx, Windows, Linux, and Chrome OS).
There are also a number of online SVG editors – easily found with a simple Google search – where you can create simple 2D SVG files online and save them locally to your machine.
It is also worth noting that the WebStorm IDE by JetBrains, our IDE of choice for web-based applications, also provides a level of support for working with SVG files.
Browser Support and Local Files
Browsers provide varying degrees of support for today’s web technologies and knowing what is or is not supported will determine whether your application will run as intended. IE (Internet Explorer) is one browser that is typically lacking in support for capabilities such as CSS transforms on SVG elements.
Remember: Browsers are NOT created equal.
Some browsers like Chrome do not permit access to files or data on your local drive and you may receive an error similar to the one pictured above if you make the attempt. Fortunately, I’m using the WebStorm IDE by JetBrains and have the option to run code either as a local file or using the built-in server.
Use a local server if you are using Chrome or another browser that does not provide access to data files that are local to your machine.
The options for animating your website are many and limited only by your imagination. As I’ve said many times before, “There’s always a better way and more one solution.” Working with SVG’s and the number of API’s available to animate them proves this statement to be true yet again.
Inkscape – Professional vector graphics editor for Windows, Mac OSx and Linux. Free and open source.
Vectr, a free cross-platform vector graphics editor, that allows you to create scalable vector graphics in 2D. You use the online version or download a copy of the application for your operating system (Windows, Mac, Linux, or Chromebook).
Using an Application Program Interface or API is not a new concept, is relatively simple, and easy to do. However, developing applications using resources outside of your local controlled environment can present new challenges and opportunities.
In this instance, I was testing one of Google’s API resources and received an “OVER_QUERY_LIMIT” error message. Although it’s not too often that this happens, apparently it can on occasion.
You typically need an API key before you can use an API such as the Google Maps Geocoding API. For those of you thinking or wondering about security, you can place restrictions on the use of your API key.
Registering an API Key
If you already have a Google account, go to the “https://console.developers.google.com/apis/credentials?project=” link as shown in the error message above, sign in to your account and accept the terms and conditions. You can then begin the process of creating your project and credentials. Google will then generate an API key for your project to use in your application.
As of this writing, there are at least 184 API’s available where some of the more popular API’s include Google Drive API, Gmail API, Google Maps Android API, Google Cloud Translation API, and Google Maps Geocoding API.
Once you’ve enabled the API’s required for your project and set up your API Key, you can begin using and monitoring the services requested from your GoogleAPIs dashboard. The “Web Services > Geocoding API” page provides a simple example of getting and using the API Key in your application.
API’s can greatly simplify your application development and enables you to deploy features that would otherwise consume a lot of time and effort to implement. The guides and documents in the API Library describe the scope of the API and provide sufficient information to begin using them to your advantage.
API Access Limits
Be aware that some API’s may have limits to the number of free “access requests” received and/or processed in a given day or over a given time period. Users may encounter problems if requests from your site exceed this limit. Increased access requests may be available if you are using a “fee-based” service or premium account.
For example, as of this writing, the Google Maps Geocoding API imposes the following Standard Usage Limits: 2,500 free requests per day and 50 requests per second. A “pay-as-you-go” billing option or Premium Plan is also available with a maximum of 100,000 daily requests.
API’s enable working with external resources both as a data source and for manipulating data. The ability to programmatically work with data reduces the possibility of data entry errors and other human fallibilities.
Remember to use API key restrictions to control and prevent unauthorized access requests! Making an attempt to use an API key from a site other than the one authorized in the restriction settings will return a “REQUEST_DENIED” status as pictured below:
Although JetBrains Web Storm is my IDE of choice for larger applications, Brackets is an ideal editor for those looking to start off with something simple and easy to use. Numerous extensions are readily available, easy to install, and will greatly enhance your experience while using Brackets.
To take advantage of the latest and greatest features, it’s important to keep your applications up to date. These updates may fix bugs that you’ve discovered (or have yet to discover) and may also introduce some features that can save you a lot of time and effort in your development process.
Extensions are often written by third-party programmers or developers and should be installed with caution. I highly recommend researching and reading reviews by others to ensure they are worthwhile and trustworthy.
The excitement of learning a new language is often met with varying degrees of chaos and confusion when selecting the right tools to get started. I recommend starting with something simple and less distracting that will allow you to focus on the task at hand. Brackets is one such editor.
In time, you will learn which tools will best serve your needs and you can adjust your working and coding environment accordingly. Feature filled IDE’s and Editors will do little to serve your needs if you have yet to learn or don’t know how to program.
Rather than write about these free offerings from Intel, click on the links above to see and choose the tools that will serve you best. The files are relatively large and you may want to reserve your time for when and how you download them to your machine. Versions are available for Windows, MacOS, and Linux.
Anaconda is my Python installation of choice if not simply for the ease of maintaining the many Python packages that are available. That the Intel distribution for Python is powered by Anaconda is not surprising.
Although I’ve expressed my fair share of caution when using code libraries written by others, I have no concerns with Intel as the documentation is more than thorough. If you’re truly interested in a comprehensive Python installation, consider this package offering from Intel.
In our post “Where’s the Graphics? Learning from our Roots (Tcl / Tk)” we focused on Tcl/Tk as a primary GUI development language. We also mentioned QT as a viable alternative. QT provides a more powerful GUI development API when compared to Tcl/Tk, however, the licensing schema for QT is also more complex.
To paraphrase the description from the wxWidgets website, wxWidgets is a C++ library that includes bindings for C++, Python and other languages to create cross-platform applications for Windows, Mac OS X, Linux, and more.
wxWidgets is available free of charge and offers a comprehensive collection of widgets that make it ideally suited for advanced GUI intensive applications. By using the native platform API, wxWidgets provides a native look and feel to your applications.
The latest version of wxWidgets is 3.0.2 as announced in the latest news release dated October 6, 2014.
Thanks to wxPack, we’ve expanded our list of cross-platform GUI’s to include wxWidgets. wxPack greatly simplifies the task of installing and setting up wxWidgets on your machine. wxPack is a full wxWidgets Development Kit, complete with wxWidgets source and binaries, wxFormBuilder (RAD Tool), and more. Without wxPack, installing wxWidgets is a task best left to more seasoned developers.
From a development perspective, wxFormBuilder is the tool that ultimately caught our attention. More specifically, wxFormBuilder offers the following features that are ideally suited to our language base and development environments:
Visual design of wxWidgets dialogs, frames, panels, toolbars and menubars
Source code generation for C++, Python, PHP, Lua and XRC
Support for wxWidgets 3.0 widgets (wxRibbonBar, wxPropertyGrid, wxDataViewCtrl, …)
Selecting Your GUI Tool Kit
The wealth of information available to learn and implement Qt suggests it is one of the better supported GUI tool kits in general. TKinter (Tcl/Tk) is also well supported due to it’s inclusion with the standard Python distribution. Regardless of the tool kit chosen, the initial learning curve can be rather steep for more complex applications. The number of widgets and options available with each package only add to the challenge of which package to choose.
Keeping it Lean
Too many options can make for more complicated interfaces than are necessary to meet the needs of the application and it’s end users. For Python, TKinter provides a minimal widget set that serves the majority of our requirements. That it’s already included with the standard Python distribution makes TKinter an even more convenient and attractive option.
There are times where a higher level of complexity and sophistication is necessary. Of course, to learn every GUI kit available isn’t an option available to everyone. The wealth of information and code samples available for QT make it a highly regarded option.
wxWidgets may just be the Goldilocks solution, falling somewhere between simplicity and sophistication where the tools available make it “just right” to get the job done. A quick review of the wxWidgets Class List suggests there are more than enough features to develop a robust GUI for your application.
Ultimately, the right choice is the tool kit that is both effective and efficient for the given application. Simplicity serves the purpose best especially during rapid development cycles and iterations.
Your feedback matters
If you have any comments, questions, or topics you would like us to address, please feel free to leave your comment in the space below or email us at email@example.com or firstname.lastname@example.org. We look forward to hearing from you and thank you for visiting.