Title: Program Design and Flowcharting
1Program Design and Flowcharting
- Bringing Professionalism to the DetailsOr
- How to Get a Better Grade in This Class.
2Proper Program Design Is Important
- Reduce program development time
- Reduce programming logic errors
- Increase your productivity
- Increase your "promote-ability"
- If they cant do without you, you may not get
fired, but you wont get promoted either!
3Proper Design Consists of Five Features
- Structured designed techniques.
- Proper documentation.
- Internal and external
- Creating Task-Object-Event (or TOE) charts.
- Consistency in form and function.
- Exit buttons are identical and appearance and
function. - Flowcharting the logic.
41. Structured Design
- A Systematic Approach to ProgrammingorMaking
Your Life Easy
5Why Structured Design?
- First, lets identify the five phases of program
development. - Conception phase.
- Analysis phase.
- Programming phase.
- Testing phase.
- Implementation phase.
6a. Conception Phase
- A need is determined.
- Something is lacking in the current system.
- The user has a new or specific request.
- Important to understand the system as a whole.
- Is the information already available in another
form? - Is there appropriate data to satisfy the request?
- What exactly is the user looking for?
7b. Analysis Phase
- We agree that a new program needs to be built.
Now, how are we going to do this? - What data is needed?
- From where will the data come?
- How shall the information be presented? Form?
Report? Other? - What features will the program need? Command
buttons? Text boxes? Etc.
8In the Analysis Phase, We Follow a Formal
Structure Design
- Modularization of techniques.
- VB lends itself well to modularization. In VB,
each event initiates a specific module of code. - Modularization allows for consistency between
programs. - It also allows code to be lifted from one
program and copied into another with minimal
changes.
9Most Logic Errors Are Located in This Phase
- During the analysis phase we create preliminary
flowcharts and TOE charts. - Charting helps us to think clearly through the
problem. - It also helps us to map the programflow and
locate situations we may not have thought of.
Nice grammar, eh?
10c. Programming Phase
- Now we can create the actual program
- Create the VB code necessary to perform the task.
- Some programming come to this step first, but at
their peril. - Old carpenters adage Measure twice, cut once
11Programmer Awareness
- For your own benefit and for the benefit of those
who will follow you - Use structured programming techniques
- Top-down programming
- Single entry / single exit modules
- Demonstrative naming conventions
- Consistency in naming
- Clear internal documentation
12Remember You Will Not Be the Only Person Looking
at Your Code.
- Your boss will. Your co-workers will. And I will.
- If your code is clean, your work and opinions
will be respected. - If your code is not, well what do you expect?
- Consistency, clarity, and documentation will help
those to look at your code to understand what you
are doing.
13d. Testing Phase
- Testing actually occurs all along the programming
phase. Instead of writing all of the code and
testing all at once, you write some and test it
then write some more. - Large systems usually go through a series of
testing phases before going live. - Sometimes beta test at the users location.
14Testing Techniques
- Use live data whenever possible.
- Programmers tend to use data that will cause the
program to always work. - Test on the people who will actually be using the
program (duh but often missed). - No one knows the job better than the person who
does the job. - Test to find failure not success.
- Bullet-proofing the program.
15e. Implementation Phase
- Shut-Down / Start-Up
- Come in Monday morning to a whole new system
- Great motivator for success(you have no choice)
- No turning back
- Bad if new system fails
Old
New
16Implementation Phase
- Phase-in.
- New system installed a littleat a time.
- Many parts of the old systemstill function.
- Good because permits parts of larger systems to
go in sooner. - Bad because new system must interface with the
old system which you want to replace. - Bad structures hang on.
- Or need to create interface modules.
Old
New
17Implementation Phase
- Parallel systems
- New system and old runsimultaneously
- Good for mission criticalsystems
- If survival is dependant on the systems and there
is a possibility that the new system may not be
fully functional - Bad if have to duplicate data entry and data
tracking - Also bad because it gives the users an
opportunity to kill the new system without
sufficient testing
New
Old
18As the designer, it is your decision as to which
approach is appropriate for your immediate needs.
Old
New
New
Old
Old
New
19Structured Programming Advantages
- Structured programming reduces development time
through consistent techniques - Structured programming reduces testing time
through easier programming management
Development Time
You may not reduce the size of the slices, but
you will reduce the size of the pie!
202. Documentation
21Documentation The Missing Phase
- Documentation is information written and
maintained about the program or system. - It usually consists of descriptions and
explanations of what the program does and why it
does it that way. - All changes are documented with the nature of the
change, the reason for the change, and the
initiator of the request.
22What Makes Good Documentation?
- Program identification
- Program name
- Programmer
- Date
- Purpose of program
- Modular identification
- Purpose of module
- Initiator of module
- Any special or difficult techniques in the module
- Self-documenting programming.
- Name controls for what they do.
- cmdExit.
- Name variables for what they are.
- sngNetPay.
- txtNameEntry.
- More on this later!
23Because all of these documentation techniques are
required for the applications that you write,
each technique will be described in detail as we
begin programming.
243. Using the T.O.E. Chart
- Three Easy Steps to Organizing Your Mind
- Or
- Bringing Clarity to the Madness
25Task Object - Event Chart
- The TOE chart is a required piece of
documentation for this class. - It identifies every technique that the
application performs and the mode by which it is
performed. - Every event in your program will have a separate
listing on the TOE chart.
26Typical TOE Chart
274. Consistency in Form and Function
- Consistency is the best defense against errors.
28Every Part of the Visual Basic Application Is
Identified
VB will provide default values for everything
that you can identify
For example, if you create three command buttons,
they will be identified on the form and in the
code as Command1, Command2, and Command3
29Warning
While Visual Basic will allow you to operate
completely using the default values, as the
programs become bigger and more complicated, it
gets harder and harder to figure out what is
going on. Especially for your instructor. For
this reason as well as to follow structured
programming techniques, you are required to write
self documenting code which includes renaming
all identifiable features.
30- Many programmers develop personal naming
conventions that they have developed over the
years. - In this class, we will identify all items using a
standard three character prefix developed by
Diane Zak.
More prefixes will be identified as we go!
Forms frmCommand Buttons..cmdText
Boxes.txtPicture Boxes.picLabel
slbl
315. Flowcharting
- Graphically Describing Your Logic FloworRoad
mapping Your Program
32Why Flowchart?
- VB has an interactive editor that catches your
syntax errors usually before you finish the
sentence. - The majority of programming errors are now
logic errors. - Flowcharting helps you to find your errors before
you write the code when they are easier to fix.
33All Logic Has A Flow
- The flow of logic tends to be deductive
- If the light is green, then drive through.
- When the flow is reversed, the results can be
disastrous. - Drive through then check the color of the light.
34All Logic Has a Flow Part 2
- It is also possible to flow logic by induction.
- If the light is not green, then it is probably
red. - If the light is not red then it is probably ok to
drive through (better).
35We Use Symbols to Describe the Flow.
Process
Decision
Print
Flow
Connection
Disk Access
36These Symbols in Combination Help Us to Find
Logic Errors
False
True
Light Red
Drive Through
Stop Wait
37OK, Lets try one together
We call this
The Mechanical Man
38Mechanical Man Rules
- Man starts in chair, arms down.
- Motions include Stand, Sit, Lift arms,
Take Step, Turn around. - Sensors in finger tips indicate when at wall.
- Sensors in finger tips cannot sense chair.
- Chair is unknown, whole step distance from wall.
- Mission Get Man to the wall and back safely.
- Complete when Man is safely in chair