Program Development: Program Development: Software Development [PDF]

The Software Development Life Cycle (SDLC) is a general process describing steps used to develop programs. • Recommend

0 downloads 3 Views 199KB Size

Recommend Stories


Leadership Development Program
When you do things from your soul, you feel a river moving in you, a joy. Rumi

leadership development program plus
Courage doesn't always roar. Sometimes courage is the quiet voice at the end of the day saying, "I will

Program Development Guide
The best time to plant a tree was 20 years ago. The second best time is now. Chinese Proverb

Student Leadership Development Program
Silence is the language of God, all else is poor translation. Rumi

Treasure Island Development Program
When you talk, you are only repeating what you already know. But if you listen, you may learn something

Construction Management Development Program
Don't be satisfied with stories, how things have gone with others. Unfold your own myth. Rumi

Student Leadership Development Program
If you are irritated by every rub, how will your mirror be polished? Rumi

Family Leadership Development Program
Nothing in nature is unbeautiful. Alfred, Lord Tennyson

Credit Analyst Development Program
When you do things from your soul, you feel a river moving in you, a joy. Rumi

Web Development Program
Raise your words, not voice. It is rain that grows flowers, not thunder. Rumi

Idea Transcript


Program Development: Program Development: Software Development Life Cycle • The Software Development Life Cycle (SDLC) is a general process describing steps used to develop programs • Recommended steps (differs from text): 1. Analyze – Basic problem-solving - identifying what the problem is – Generate program requirements/specifications: ∗ Id input and output 2. Design – Identify program constructs and processing required to solve problem – Involves designing an algorithm: ∗ A step-by-step sequence of unambiguous instructions for solving a problem in a finite amount of time 3. Implement – Write code – Compile – Debug 4. Test – Generate test cases – Debug 5. Maintain – Includes documentation and tweaking as needed

1

Intro to Programming: Program Development (2)

2

Program Development: Tools - Top-Down Design • Top-down design is a strategy for designing programs • It is based on the divide-and-conquer strategy • The philosophy behind divide-and-conquer is: 1. Break a problem into smaller sub problems 2. Solve each sub problem, breaking them up even more if needed 3. Combine the solutions of the sub problems 4. By combining the solutions to the sub problems, you will have solved the original problem • The philosophy is that smaller problems are easier to solve than larger ones • A tool used in top-down design is the Hierarchical Input Processing Output chart – HIPO charts are a graphical means of displaying top-down design – The main problem is shown at the top – The sub problems it is broken into are listed below it, in order to be solved – Sub-sub problems are listed underneath these, etc. – Decomposition stops when you have a sub problem that is easy to solve – The subproblems at the very bottom of the chart (tree) are called leaves – Problem decomposition is read from top to bottom – Order of execution is read from left to right

3

Program Development: Tools - Top-Down Design (2) • Example:

• HIPO charts are useful for subroutine design – Sub problems are usually represented by subroutine in a program – Each sub program should accomplish a single task – In addition, if there is processing that appears several times in the HIPO chart, a subroutine is usually written for that processing • Top-down design and HIPO charts are useful for representing the major steps/components in solving a problem

4

Program Development: Tools - Flow Charts • Flow chart is another tool for designing programs • Graphical way of showing flow of control in a program – Flow of control deals with the order in which statements are executed • Symbols used in flow charts:

– Terminal: Start or End of program – Processing: Any basic computation – Decision: Indicates a choice to be made – Connector: Allows breaking of chart into several pieces ∗ Labeled with a letter or number

5

Program Development: Tools - Pseudocode • Pseudocode is a set of instructions written in English • There is no formal set of rules for writing pseudocode • Often used as a step between flow charts and actual code, or in place of flow charts • Usually do not use variable names - just English words - for values • Many of the programming exercises in the text are pseudocode

6

Program Development: Structured Programming • Deals with control structures: – Program statements that control flow of control thru program • Each control structure has single entry point, single exit point (in theory) • Promotes readability and ease of debugging • Types of control structures: 1. Sequence – Simplest control – Execute one statement after another in sequence

2. Selection (conditional) – Execute a set of statements conditionally

7

Program Development: Structured Programming (2) 3. Sub program call – On call, control jumps to first statement in sub program – When end of sub program reached, contro returns to point immediately after the call

4. Iteration (looping, repetition) – Execute a set of statements – When end of sub program reached, control returns to point immediately after the call

8

Program Development: Coding Techniques • Identifiers should be meaningful • Use camel case/style • Bodies of structures (methods, etc.) should be indented from the headers • Programs should be documented – Documentation consists of comments – A comment is text that is added to a program but which the compiler ignores ∗ It is there purely for the sake of the programmer – Comments in VB are signalled by a single quote ∗ Everything from the quote to the end of the line is ignored by the compiler ∗ For example: Dim x, y As Integer ’Coordinates of point on graph ’***************************************************** ’* btnStart_Click * ’***************************************************** ’Event handler for the start button ’Initializes game variables Private Sub btnStart_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click ...

• Long lines of code – VB expects each statement to be on a single line – Long statements should be broken up over several lines to improve readability – To continue a statement on the next line, include an underscore as the last character of the line ∗ VB will consider the next line to be a continuation – If a line ends with an operator, VB will assume (without the need for an underscore) that the statement is continued on the next line – Continuation lines should be indented from the starting line

9

Program Development: Errors • Types of errors: – Syntax errors ∗ Generated by compiler/interpreter ∗ Are violations of language structure ∗ These are signaled in the Code Editor using blue underlining

– Semantic errors ∗ Errors in use of language · E.g., division by 0, invalid type assignments, use of unassigned variables in expressions

10

Program Development: Errors (2) ∗ These are generally run-time errors · They cause the program to crash while executing · An exception is thrown

∗ Offending line indicated using yellow arrow

– Logical errors ∗ Error in problem-solving strategy ∗ These identified by running the program with various inputs with known outputs and comparing results 11

Program Development: Errors (3) • Errors displayed in Error List Window – Can be accessed via view/Error List

12

Program Development: Errors (4) • Division by zero – This is a ”common” error – VB handles this in different ways, depending on data type 1. Integer division ∗ Generates a Divide By Zero exception (see semantic error example above) ∗ Run time error 2. Floating point division ∗ Generates the value Double.PositiveInfinity or Double.NegativeInfinity ∗ Value displayed as ±Inf inity ∗ If numerator is also zero, generates the value Double.NaN · Value displayed as N aN (not a number) ∗ Neither generates a run time error

13

Program Development: Debugging • Debugging is process of testing a program and eliminating errors • Approaches to debugging: 1. Desk checking – Manually going over code to find errors 2. Outputting values – Adding code to program to print values of variables to trace execution of program 3. Using a debugging tool – Provides facilities to step through program, examine values of variables, etc.

14

Program Development: VB Debugger • Debug mode is VB’s third mode (Design and Run are the other two) • Entered in one of two ways: 1. When a run time error occurs 2. When a break point is reached in a program’s execution • Break points – Setting a break point ∗ Click in gray bar to left of line in code window, or ∗ Right click on line, or ∗ Menu bar/Debug/Toggle Breakpoint, ... – Break point indicated by red circle

– When a break point is reached during program execution, VB enters debug mode and halts execution immediately before the line with the break point

15

Program Development: VB Debugger (2) – From this point, the user has several options: 1. Step into ∗ Executes the next statement, stopping at the following statement ∗ If the next statement is a method call, it will execute the first statement of the method’s body 2. Step over ∗ Executes the next statement ∗ If the next statement is a method call, it will execute the entire method, stopping at the statement following the method call 3. Step out of ∗ When inside a method, executes the rest of the method’s body, stopping at the statement following the method call 4. Continue execution ∗ Will continue executing the program until another break point is reached (if there is another) 5. Run to cursor ∗ The user clicks on a line, and the program executes up to that line and stops

16

Program Development: VB Debugger (3) • Debug mode windows – Important windows associated with Debug mode are: 1. 2. 3. 4.

Locals - which lists values of local variables in current scope Autos - which lists values of global variables Watch - which lists values of specified variables Immediate - in which you interact with the program

– These can be displayed by 1. Selecting tab at bottom, or 2. Via Debug menu/Windows – Autos window (Locals is similar) ∗ Displays variables that are in scope

∗ Variable values can be changed here

17

Program Development: VB Debugger (4) – Watch window ∗ Displays variables explicitly tagged to watch

∗ To tag a variable 1. Right-click/Add Watch, or 2. Type dirctly into Watch window ∗ Watched variables are highlighted in red in code

∗ Variable values can be changed here

18

Program Development: VB Debugger (5) – Immediate window ∗ Allows you to change values of variables as program executes without actually changing the code · Use an assignment statement ∗ Can query the value of a variable by entering the variable’s name preceded by a question mark ∗ Called immediate because changes you specify here immediately affect the values used by the program

19

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.