Programming bugbears

The EV3 Programs provided by LEGO with the software are highly impressive, but are nearly impossible to understand. The LEGO tutorials do accomplish their goal of introducing the reader to the blocks and vernacular of EV3 programming. The provided models demonstrate the potential of the kit for the advanced hobbyist. This is a great marketing tool for LEGO when one watches videos of the extremely cool models that can be built with EV3. However, the programs are entirely lacking in any kind of documentation. One of the main reasons I wrote a book for the intermediate level user is this need for explanation of these great programs and to help bridge the gap between the rudimentary tutorials and the advanced models.

There are great advantages to visual programming languages such as LabVIEW, Scratch, and the EV3 LEGO MINDSTORMS software. They can be just as powerful as line code, but examining the main code for the Gyro Boy program in the following screenshot, we can see that LEGO does not make use of the advantages of visual programming:

Programming bugbears

One of the leading rules in writing a good program in a visual programming language is that you should be able to view your entire program on your computer screen at one time. Although I myself am guilty of not following this, as you can see in the preceding screenshot, we have to zoom out to a ridiculous level to view the entire Gyro Boy program. Most of the blocks in the preceding screenshot are too small to recognize. Compounding the nonvisible details, the preceding screenshot shows the switch blocks in a tabbed view instead of a flat view. In complex programs, one should make prodigious use of My Blocks. This allows for a hierarchical program with several levels of depth. Such programs are much easier for the reader to decipher and to debug. When one finally zooms into the program, you will also find a complete and utter lack of comments to document the code. Sans comments, understanding the code can be an insurmountable task. If the names of the variables and loops were informative, this might make the lack of documentation forgivable. However, most of the loops and variables have short abbreviated names that are equally confusing. Lastly, the algorithms contain many numerical constants embedded inside the Math blocks. These constants actually represent what should be variables, which would have to be tuned for different surfaces or if you redesigned the mechanical features of Gyro Boy. The aforementioned Gyro Boy code written by Dean Hystad is well commented and doesn't have the previously mentioned programming bugbears. In this chapter, I will attempt to provide a road map to decipher the Gyro Boy program, which really is an impressive example of the potential of EV3.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.230