Generic Code : Keeping It Simple
So, Generic Code
, eh? Is that like store brand food?
Generic code, otherwise known as Psuedocode, is simply writing out the logic of your program in plain text. This can be as basic as:
Start Program
Get Input From User
Perform Calculations
Display Results
End Program
or, for those wanting something a bit more complicated:
Begin Program
' Declare variables to hold user data.
string user_name
integer user_age
' Get user's name and age.
Print Please enter your name:
, Store to user_name
Print Please enter you age:
, Store to user_age
' Echo input back out to screen.
Print Thank you,
, user_name, !
Print The age you entered was:
, user_age, .
Print
' Echo message out to user before terminating program.
Print Press any key to end program...
End Program
.
Well, that's neat, but why would I do that?
Psuedocode is normally used in conjuction with UML during the planning stage of your program. Note the implied suggestion here: plan before you code! While it is possible to simply sit down and start hacking out code in you favorite editor, it is a bad habit to get into.
In my personal experience, lack of planning always led me to redundant code and/or bad logic. The time I wasted going back and forth between errors could have been dramatically lessened if I had simply spent a little more time planning out what I wanted my program to accomplish.
This seems like a lot of work...
At first, it probably will be. After all, if you knew what you were doing, why would you be in class? Silly...
What I believe you will eventually discover is that the process of diagramming and psuedocoding becomes second nature. You will be able to put together a mock-up of your program quickly, present it for approval, and be coding in short order. And THAT, my friends, makes potential employers drool... :)
Sorry. There are currently no comments for this article.