Professional Documents
Culture Documents
DP Pangalos
DP Pangalos
(structured programming)
1:
______________________________________________________________________________
. , , , , 54006
. 1
I. ......................................3
II. ..................................................................................7
I. : ...................................................................13
IV. ..........................17
V. ......................................20
VI. ......................................26
VI. .................................27
VII. ....................................34
IX.. A ..............................39
. C ( ) .............47
. .......................................50
XI. ...........................................................................52
I. - ...........................................................................................................52
______________________________________________________________________________
. , , , , 54006
. 2
I.
:
().
.
,
() . ,
() .
:
. .
.
.
60%
() .
1:
() .
ACM, :
(the
software industry is in a state of crisis and new programming methods are needed).
______________________________________________________________________________
. , , , , 54006
. 3
2: ,
.
:
:
- (,
, .. ,
, )
- (..
)
- (..
, expert systems, .)
.
:
.
:
.
,
, .
. ,
.
,
:
______________________________________________________________________________
. , , , , 54006
. 4
:
- () ;
- ;
- ;
- ;
T (software engineering).
,
H :
-
-
INTERFACES
INTERFACES
(.....)
(.....)
2:
:
:
:
1. ,
: ,
. :
- ,
- ,
______________________________________________________________________________
. , , , , 54006
. 5
- ,
- , .
, ()
, .
(performance) , ,
.
2. ,
( modular design, top-down design,
.)
.
- ,
.
3. , ,
, ( ).
: systems analysis, structured systems
analysis, functional analysis, .
1960 - (stage-wise)
, o
(waterfall model) .
:
A. ( )
B. ( / )
C. ( )
4. ,
( /
). :
. 1970:
(). (low-level)
, . .
.
1980:
.
, ,
.
______________________________________________________________________________
. , , , , 54006
. 6
II.
.
.
, , .
, ,
, :
(waterfall model)
(rapid prototyping)
(incremental model)
(spiral model)
(unified model)
,
1. - o
:
______________________________________________________________________________
. , , , , 54006
. 7
(waterfall model)
. :
(phases)
, :
1. ( )
2. ( / )
3. ( )
(waterfall model)
:
______________________________________________________________________________
. , , , , 54006
. 8
:
:
( )
,
.
(
)
2.
- : ,
, (
).
:
______________________________________________________________________________
. , , , , 54006
. 9
:
/
:
. ,
3.
- :
() ,
/ , .
:
(Release) 1
:
-
-
:
-
4.
- :
() ,
.
:
______________________________________________________________________________
. , , , , 54006
. 10
(Version) 1
Requirements
Design
Coding
Test
Deployment
(Version) 2
Requirements
Design
Coding
(Version) 3
Requirements
Design
Test
Deployment
Feedback
Coding
Test
Deployment
:
-
- /
:
-
5.
- :
() , /
(
).
.
:
______________________________________________________________________________
. , , , , 54006
. 11
.
6.
, ,
, Extreme Programming (XP),
Planning
2-3
Write tests
Release
Pair Programming
+ Refactoring
Test
Integration
______________________________________________________________________________
. , , , , 54006
. 12
I. :
:
Von Neumann,
()
,
.
, (..
FORTRAN, C)
.
- :
,
. , :
(algorithmic/procedural )
(procedures).
-- ()
( Von Neyman)
(object oriented)
/,
(encapsulate) (methods).
(objects),
(classes),
.
, --
.
(functional programming)
(logic programming)
,
(parallel programming)
,
, .
, , ( )
. ()
.
.
______________________________________________________________________________
. , , , , 54006
. 13
/
Compiler/Assembler/Linker /Data
/
Domain Knowledge
/
/
Algorithm
Problem Definition
(Source
Code)
.. C
/
Result
:
, .
(
: ),
(
: ),
(
),
.
, :
()
()
(.. ,
, .).
(library code).
.
, .
______________________________________________________________________________
. , , , , 54006
. 14
, (source code)
(compiled) (linked) ,
.
(object code),
(run).
:
Compiling
Optimization
Linking
Optimized
:
( 2.000)
.
. ,
:
1950: FORTRAN (, , )
1960: ALGOL
( procedural )
1970: PASCAL ()
1970: C
( , system programming)
1980: C++, JAVA (object oriented)
______________________________________________________________________________
. , , , , 54006
. 15
C JAVA, :
C:
M ( ) ,
(system programming) .
top-down & modular
i:
o (efficient)
o (portable)
o (flexible)
o (powerful)
C++
JAVA:
z
systems engineering
(portable)
,
,
C++
CORBA, .
______________________________________________________________________________
. , , , , 54006
. 16
IV.
(problem solving)
, , ,
.
(Top Down), (Bottom Up), (mixed):
I. H A .
H A (top down problem solving)
, , :
:
1. - (sub goals)
.
2. , , .
3. - ( )
, () .
, ,
, () , .
:
- -
- H (integration) -.
:
- (systems analysis)
- (structured systems analysis)
- (functional analysis).
1-1
1-2
______________________________________________________________________________
. , , , , 54006
. 17
II.
(bottom up problem solving)
(successive refinement).
:
.
:
1. ,
.
2. ,
3. , .
1-1
1-2
2-1
3-1 3-2
,
:
( ) () ( ),
, ,
/
, ,
,
, :
______________________________________________________________________________
. , , , , 54006
. 18
(Release) 1
III.
(mixed), ,
. ,
- /
, .
______________________________________________________________________________
. , , , , 54006
. 19
V.
:
, ,
:
1.
2. GoTo
( ,
GoTo)
3. ,
FORTAN, BASIC, .
(): ,
, ,
, (
), . :
I.
()
. . ,
-
, (.. )
( )
II.
.
,
.
(.. ). H
.
.
.
(
)
. :
-
______________________________________________________________________________
. , , , , 54006
. 20
- ()
.
. :
(time complexity),
(space complexity),
(parameterization),
(reliability),
(robustness), .
:
. ,
.
. .
.
, .
. (data)
(input) ( , ..
)
. .
) (output)
. . /
, .
: ,
(.. )
IV.
.
(flow-chart)
.
(1).
,
. (flowcharts)
.
______________________________________________________________________________
. , , , , 54006
. 21
.
:
) ,
:
)
:
True
False
False
C
True
False
True
E1
E3
E4
______________________________________________________________________________
. , , , , 54006
. 22
.
V. ( )
(
). ,
. ,
(
) :
-
- (.. C)
(pseudocode):
,
-,
. - ,
( ) .
, /
(.. C).
- :
1.
2.
3. (design)
(implementation)
:
:
( )
)
( name1, name2
)
)
(
.. )
)
name1
(
name1
if expression then
A
else
B
endif
( )
)
______________________________________________________________________________
. , , , , 54006
. 23
x2 + x + = (x)
(x) = 0.
get a, b, c;
if a = 0 then
if b = 0 then
case 1;
record case;
else
.
case 2;
root1 - c/b
record case, root1;
endif
else
if b2 >= 4ac then
case 3;
root1 (-b + sqrt(b2 4ac) / (2a);
root2 (-b - sqrt(b2 4ac) / (2a);
record case, root1, root2;
else
case 4;
root1 (-b/ (2a)) + j (sqrt(abs(b2 4ac)) / (2a));
root1 (-b/ (2a)) - j (sqrt(abs(b2 4ac)) / (2a));
record case, root1, root2;
endif
endif
______________________________________________________________________________
. , , , , 54006
. 24
V.
:
()
.
, ,
data.
()
VI. ( )
,
( ).
VII.
() ,
(,, ).
- :
.
. , ()
.
.
,
,
,
, , .
.
______________________________________________________________________________
. , , , , 54006
. 25
VI.
:
(performance) . (data)
.
.
.
(data structures). :
( ):
. , ,
5: , : 70 99.
______________________________________________________________________________
. , , , , 54006
. 26
VI.
,
GoTo
( ,
GoTo).
GoTo
. , ,
() .
, .
GT, ,
, :
(performance)
( )
(correctness)
( )
.
, ,
,
, ,
.
. ,
GT
,
, .
E. Dijkstra 60.
(1968) "GO TO Statement Considered Harmful (
GO TO ), 70.
, (
), .
. , , ,
.
______________________________________________________________________________
. , , , , 54006
. 27
,
, ,
,
,
, . (.
):
H (principle of abstraction):
.
.
.
.
.
,
.
.
(principle of formality):
, .
.
.
. 28
,
.
(modular).
(hierarchical ordering concept):
. ,
.
.
(: = , =
)
:
. ,
(top - down development), ,
. , ,
, . ,
(bottom - up development)
:
,
.
o
,
.
o
______________________________________________________________________________
. , , , , 54006
. 29
?
?
?
?
:
:
o (
)
o (.
, ,
( ))
,
,
.
:
o
( )
o
( )
o
( )
FUNCTION F1
FUNCTION F2
FUNCTION F5
PROCEDURE P3
FUNCTION F6
PROCEDURE P4
FUNCTION F7
:
______________________________________________________________________________
. , , , , 54006
. 30
: ( )
(stepwise refinement) .
, , .
. :
, :
- ( )
- ( )
- ( )
- (
)
- ( )
- (
)
, , :
______________________________________________________________________________
. , , , , 54006
. 31
,
/
!
, , :
(logically cohesive modules)
:
--------------------------------------------Label :
--------------------------------------------IF A > 0 GOTO Label
---------------------------------------------
----------------------------------------------WHILE A > 0 DO
----------------------------------------------END WHILE
-----------------------------------------------
- . , , ... -
( ,
) .
, ,
1.
(sequence)
( )
2.
( : ..., ..., ...)
, , ,
3.
,
.
______________________________________________________________________________
. , , , , 54006
. 32
:
(..
).
, , :
, ,
Pascal / C:
To 1970 Pascal
.
C.
: Quickbasic, Visualbasic, .
.
______________________________________________________________________________
. , , , , 54006
. 33
VII.
,
GoTo.
(, , ).
.
.
, ,
. ,
top-down,
(hierarchical
programming), (modular programming),
.
A. TOP - DOWN
top-down ( ) ,
. N.
Wirth
(stepwise refinement). H A (top down)
:
:
1. - (sub goals).
2. ,
3.
, () .
,
, ()
-, .
top-down:
.
(-) ,
,
.
.
______________________________________________________________________________
. , , , , 54006
. 34
TOP-DOWN
1-1
- . , , ... -
top-down ,
, ,
.
. topdown -, ,
.
top-down :
1. ()
.
1. ,
.
2.
,
.
. , ()
.
,
.
______________________________________________________________________________
. , , , , 54006
. 35
B. O
(top-down programming)
,
.
top-down
(stepwise refinement). top-down, ,
. ,
,
.
(hierarchical
programming).
______________________________________________________________________________
. , , , , 54006
. 36
:
,
, :
H
(..
.. )
,
,
-- ,
,
(.. C).
.
(modular programming)
.
,
,
.
.
.
( )
.
(module) :
,
,
.
,
(modules), :
, ,
,
______________________________________________________________________________
. , , , , 54006
. 37
..
(modules)
. ,
,
. :
.
,
.
():
.
() :
1. .
2. .
3. .
4.
.
5. .
6. .
7. (
, , )
(modules) :
.
.
.
.
(modules) :
.
.
.
,
.
______________________________________________________________________________
. , , , , 54006
. 38
IX. A
.
(Bohm Jacopini (3))
:
1. .
.
2.
. ,
, .
,
,
.
.
,
.
(3)
Pascal.
1. .
.
2. IF - ELSE.
______________________________________________________________________________
. , , , , 54006
. 39
IF ELSE
( GoTo
).
IF ELSE :
:
if ( )
-1;
[else -2];
:
if (x>5) max=x;
if (a>b) max=a;
else max=b;
3. .
.
( ):
(while), (do while), (for).
:
. (while)
______________________________________________________________________________
. , , , , 54006
. 40
:
while ( ) -1;
:
x=0;
while (x<4) x=2+x;
. (do while):
:
do
while ( )
:
x=5;
do
x=x-1;
while (x>=4);
H do while .
:
______________________________________________________________________________
do .. while
while
. , , , , 54006
. 41
. (for):
:
for ( = ; ; )
;
:
for (x=1; x<=4; x=x+1)
. (nested)
,
(nested/), ,
. :
x=1;
while (x<=3) {
y=2;
while (y<=5) {
printf(%d %d, x,y);
y=y+1;
}
x=x+1;
}
/*------------------------------------------------------------------------------------*/
x=1;
do {
y=2;
do {
printf(%d %d, x,y);
y=y+1;
}
while (y>5);
x=x+1;
}
while (x>3);
/*------------------------------------------------------------------------------------*/
______________________________________________________________________________
. , , , , 54006
. 42
______________________________________________________________________________
. , , , , 54006
. 43
switch :
switch (type of )
{
case -1:-1;
case -2: -2;
case -: -;
default: ;
}
:
switch (x)
{
case 1: P1;
case 2: P2;
case 3: P3;
default: P4;
}
if else, :
______________________________________________________________________________
. , , , , 54006
. 44
if (x=1) P1;
else if (x=2) P2;
else if (x=3) P3;
else P4;
. ,
, C
,
,
.
.
.
.
.
GOTO , ,
.
,
.
,
. ,
: , ,
,
.
, :
,
,
,
(.
) .
. (escape)
,
.
GOTO. GOTO
,
.
______________________________________________________________________________
. , , , , 54006
. 45
GOTO
,
. , GOTO
. GOTO
.
:
goto ;
: ;
:
if (x=0) goto 99;
else x=x+1;
99:printf(%d, x);
______________________________________________________________________________
. , , , , 54006
. 46
. C (
)
(iterative statements) (..
2 )
( ,
, .). C .
C ,
.
C, (body)
. (condition).
(fixed point).
, C ,
:
while
do-while
for
, ,
C
():
1
while A do
B
endwhile
( )
False
True
______________________________________________________________________________
. , , , , 54006
. 47
2
( )
do B
while A
False
True
while
while
i = i+1
______________________________________________________________________________
. , , , , 54006
. 48
do while
while
do
while (< >)
.
.
:
:
int i = 0
do
{
printf(
printf(The number is: %d
%d\n, i);
i = i + 1;
}
while (i <= 10)
for
for
for (< >
>; <
< >
>; < >)
>)
:
:
int i, sum=0;
for (i = 1; i <= 10; i++)
{
sum = sum + 1;
printf(The sum now is: %d\n, sum);
}
printf(The final sum is:%d\n, sum);
______________________________________________________________________________
. , , , , 54006
. 49
.
.
(testing)
, ,
.
.
.
.
.
. :
. :
positive testing
.
.
. : [positive and
negative testing], [boundary case], white box vs black box testing,
( ;),
, ..
(
;), . :
.
.
.
. ,
-
. Black box / white box testing
______________________________________________________________________________
. , , , , 54006
. 50
Black box
[manual]. .
, White box
. ,
( , -if, if else
, )
.
. (
)
. ,
.
. ,
, . ,
.
,
.
, , . [regression
testing] (Regress = () , )
;
,
!
. (debugging)
(debugging)
. .
,
..
______________________________________________________________________________
. , , , , 54006
. 51
XI.
. ,
. ,
.
,
.
, (),
(coding style). .
, , .
.
,
(. ):
.
GO TO.
.
.
.
5 25
.
, , ,
,
.
.
.
THEN (.. if B then else S;) if (not B)
then S;
______________________________________________________________________________
. , , , , 54006
. 52
THEN IF
ELSE IF.
.
.
.
.
5
.
.
.
.
______________________________________________________________________________
. , , , , 54006
. 53
I. -
1.
2.
3.
4.
. , , , 2002
. , , , 2000
. , , , 2004
, . , et. al., . ,
1997
5. A Structured Approach to Programming, J. K. Hughes, et.al, Prentice-Hall, Inc. 1977.
6. , . , , 1991.
//////////////////////////
______________________________________________________________________________
. , , , , 54006
. 54