Crawl, Walk, Run - The Evolution from Algorithm to Useful Code
Most babies transition the way they get around the world by crawling, then walking, and finally running. Those who make the jump from crawling to running without building the walking part often suffer from more falls and tumbles. Writing useful, efficient code can be the same way. A talented programmer can make a jump from idea in their head to code that a computer can run, but once a program becomes sufficiently complex, stream of consciousness software writing is more likely to take longer than a process that involves drafting out ideas in advance of writing code. Software that is complex enough to necessitate a team building environment requires some means of ensuring that everyone is moving in the same direction in the design and development of an application. Writing complex software code without a roadmap ensures that it will be hard to maintain and have limited use as time goes on.
How can you enhance the chances that a complex design will be successful (delivered in-scope, on time, and on-budget) in the end? If writing the line-by-line code of the application is where the programmer’s feet meet the ground, the roadmap to the programmer’s destination is the application flowchart, and the Program Design Language (PDL) and Pseudocode is what provides the programmer with the detailed instructions to get through the jungle and safely home. With these tools in hand, a programmer has a reasonable chance of writing concise code that follows a complex, high level design with a minimum of errors.
Flowcharts resemble maps more than any other tool used to document the flow of logic in an application. Flowcharts provide a visual representation of the logic and algorithms that are used. It can help a programmer sequence logical operations in the most efficient way, highlighting logical errors (loops without ending conditions, forks in logic with abandoned logic threads, etc.). If an application is complex enough, simply having a flow chart is often not enough, just as detailed instructions tell a traveler where and when to make the turns in a journey PDL or Pseudocode provide human readable code that is used to document the specifics and visualize a logical process that will be used by an application.
PDL is plain language coding that is designed to be written by human beings and read by human beings, never for a computer's eyes, allowing the programmer to put their thoughts on how a program will be executed on paper (or pixel, as it were). Pseudocode can be used as an intermediary step between PDL and writing actual code, providing an even more detailed view of how a complex algorithm will be executed by an application. Starting to jump from flowcharts to writing actual code is kind of like writing a complex essay in pen. Though it can be done, it prevents ideas from being developed on the fly and lead to more errors that result from an inability to translate ideas to text accurately.
To break this idea down to a level even my grandmother can understand, let me apply these ideas to a daily task that is too complex for me to wing it: getting my daughter’s diaper bag ready at 4:00 A.M., well before I’m fully (or remotely) awake. Something as simple as this, based on hard experience, is well beyond my ability to do right without some tools. I have a sketch drawn by my lovely wife of the contents of the diaper bag as it should be, drawn in the IKEA style, hanging next to the door. This is my equivalent of the flow-chart. In addition, there is a check list of items below that, written so that my sleep addled brain can make sense of it:
1. Inventory the supplies in the diaper bag
2. If Diapers less than six, add some
3. If the pack of wipes is less than half full, put another pack in
4. If there isn't a fruit puree, add one
5. If there isn't a vegetable, add one
6. If there isn't a meaty jar of some type, add one
7. Was the spare outfit used after an accident? If so, replace it with a clean one
8. Finally add 22 ounce bottle of milk, and a full 12 ounce toddler cup of fresh, cold milk
My wife isn’t demeaning me. I asked for help after the frustration of delivering Ava to the sitter over and over again missing something important. It isn’t until later in the morning that I start to become a high level thinker, capable of preparing complex diaper bags without assistance.
No comments:
Post a Comment