Anda di halaman 1dari 672

The black art of programming

Mark McIlroy

A book about computer programming

(c) Blue Sky Technology 2013. All right re er!e"

###.blue kytechnology.com.au

Contents
1. Prelude 3 2. Program Structure 5 3. Topics from Computer Science 32 4. The Craft of Programming 292 5. Glossary 53 . !ppendi" ! # Summary of operators $1

1. Prelude

A computer program i a et o$ tatement that i u e" to create an output% uch a a creen "i play% a printe" report% a et o$ "ata recor" % or a calculate" et o$ number . Mo t program in!ol!e tatement that are e&ecute" in e'uence. A program i #ritten u ing the tatement o$ a programming language. In"i!i"ual tatement per$orm imple operation uch a printing an item o$ te&t% calculating a ingle !alue% an" comparing !alue to "etermine #hich et o$ tatement to e&ecute. Simple in truction are per$orme" in har"#are by the computer( central proce ing unit. 3

)omple& in truction are #ritten in programming language an" tran late" into the internal in truction et by another program. )omputer memory i generally compo e" o$ byte % #hich are "ata item that contain a binary number. The e !alue can range $rom 0 to 2**. Memory location are re$erre" to by number% kno#n a an a""re . A memory location can be u e" to recor" in$ormation uch a a mall number% "ata $rom a graphic image% part o$ a memory a""re % a program in truction% an" a numeric !alue repre enting a ingle letter. +rogram in truction an" "ata are tore" in memory #hile a program i e&ecuting.

2. Program Structure

2.1. Procedural Languages


+rogram #ritten in proce"ural language in!ol!e a et o$ tatement that are per$orme" in e'uence. Mo t program are #ritten u ing proce"ural language . Thir" generation language are language that operate at the le!el o$ in"i!i"ual "ata item % -i$. tatement % loop an" ubroutine . A large proportion o$ program are #ritten u ing thir"/generation language .

2.1.1.

Data

2.1.1.1. Data Types

Ba ic "ata type inclu"e numeric !alue an" tring . A tring i a hort te&t item% an" may contain in$ormation uch a a name or a report hea"ing. 0umeric "ata may be tore" internally a a binary number% #hich i a "i tinct $ormat $rom a et o$ in"i!i"ual "igit $ormat. Se!eral numeric "ata type may be a!ailable. The e may inclu"e integer "ata type % $loating point "ata type an" other $ormat . Integer are #hole number an" integer "ata type cannot recor" $ractional number . 1o#e!er% operation #ith integer "ata type tore" in a te&t

are generally $a ter than operation #ith other numeric "ata type . 3loating point "ata type tore the "igit

#ithin a number eparately $rom the magnitu"e% an" can tore #i"ely !arying !alue uch a 2,30000000 an" 0.00000023,2. Some language al o upport a range o$ other numeric "ata type #ith !arying range an" preci ion. 4ate are upporte" a a eparate "ate type in ome language . A Boolean "ata type i a type that recor" only t#o !alue % -true. an" -$al e.. Boolean "ata type an" e&pre ion are u e" in checking con"ition an" per$orming "i$$erent action in "i$$erent circum tance . The language )obol i u e" in "ata proce ing. 4ata item #ithin cobol are

e$$ecti!ely $iel" #ithin "ataba e recor" % an" may contain a combination o$ te&t an" numeric "igit . In"i!i"ual po ition #ithin a "ata $iel" in cobol can be "e$ine" a hol"ing an alphabetic% alphanumeric or numeric character. )alculation can be per$orme" #ith numeric $iel" .

2.1.1.2. Type Conversion

6anguage generally pro!i"e $acilitie $or con!erting bet#een "ata type % uch a bet#een t#o "i$$erent numeric "ata type % or bet#een numeric "ata in binary $ormat an" a te&t tring o$ "igit . Thi may be "one automatically #ithin e&pre ion % through the u e o$ an operator ymbol% or through a ubroutine call.

8hen "i$$erent numeric "ata type are mi&e" #ithin an e&pre ion% the !alue #ith the lo#er le!el o$ preci ion i generally promote" to the higher le!el o$ preci ion be$ore the calculation i per$orme". The "etail o$ type promotion !ary #ith each language.

2.1.1.3. Variables

A !ariable i a "ata item u e" #ithin a program% an" i"enti$ie" by a !ariable name. 9ariable may con i t o$ $un"amental "ata type uch a tring an" numeric "ata type % or a !ariable name may re$er to multiple in"i!i"ual "ata item . 9ariable can be u e" in e&pre ion $or calculation % an" al o $or compari on to

per$orm "i$$erent ection o$ co"e un"er "i$$erent con"ition . The !alue o$ a !ariable can be change" u ing an a ignment tatement% #hich change the !alue o$ a !ariable to e'ual the !alue o$ an e&pre ion.

2.1.1.4. Constants

)on tant co"e.

uch a $i&e" number an" tring

can be inclu"e" "irectly #ithin program

)on tant can al o be gi!en a name% imilar to a !ariable name% an" u e" in e!eral place #ith the program. The !alue o$ a con tant i $i&e" an" cannot be change" #ithout recompiling the program.

10

2.1.1.5. Data Structures

9ariable can be "e$ine" a a collection o$ in"i!i"ual "ata item . An array i a !ariable that contain multiple "ata item o$ the ame type. ;ach item i re$erre" to by number. A tructure type% al o kno#n a a recor"% i a collection o$ e!eral "i$$erent "ata item . An ob<ect i an element o$ ob<ect orientate" program . An ob<ect i re$erre" to by name an" contain in"i!i"ual "ata item . Subroutine kno#n a metho" are al o "e$ine" #ithin an ob<ect. Array can contain tructure % an" tructure can contain array an" other tructure . Some language uch a li t . upport other "ata tructure

11

2.1.1.6. Pointers & Re erences

A pointer i a !ariable that contain a re$erence to another !ariable. The econ" !ariable can be acce e" in"irectly by re$erring to the pointer !ariable. +ointer are u e" to link "ata item together% #hen "ata tructure are "ynamically create" a a program e&ecute . In ome language % pointer can be increa e" an" "ecrea e to can through memory an" acce "i$$erent element #ithin an array% or in"i!i"ual byte #ithin a block o$ "ata. A re$erence to a !ariable i al o kno#n a an a""re % an" re$er to the location o$ the !ariable in memory.

12

The !alue o$ a pointer !ariable can be et to the a""re o$ another "ata item by u ing a re$erence operator #ith the "ata item. The "ata item that a pointer point to can be acce e" by u ing a "e/re$erencing operator.

2.1.1.!. Variable Scope

In"i!i"ual !ariable can only be acce e" #ithin certain ection o$ a program. =lobal !ariable can be acce e" $rom any point #ithin the co"e. 6ocal !ariable apply #ithin a ingle ubroutine. An in"epen"ent copy o$ the local !ariable i create" each time that a ubroutine i calle". 8here a local !ariable ha the ame name a a global !ariable% the name #oul" re$er to the

13

!ariable #ith the tighte t cope% #hich in that ca e #oul" be the local !ariable. +arameter are "ata !alue or !ariable that are pa e" to a ubroutine #hen it i calle". +arameter can be acce e" $rom #ithin the ubroutine. Some language ha!e multiple le!el o$ cope. In the e ca e % ubroutine may be "e$ine" #ithin other ubroutine % an" !ariable may be "e$ine" #ithin inner co"e block . 9ariable #ithin the current le!el o$ cope an" outer le!el o$ cope can be acce e"% but not !ariable #ithin an inner le!el o$ cope or in an in"epen"ent part o$ the y tem. Mo"ule an" ob<ect may ha!e public an" pri!ate ubroutine an" !ariable . +ublic !ariable are acce ible out i"e the mo"ule%

1,

#hile pri!ate !ariable are only acce ible #ithin the mo"ule. The u e o$ global !ariable can lea" to interaction bet#een "i$$erent part o$ the co"e% #hich may make "ebugging an" mo"i$ying the co"e more "i$$icult.

2.1.1.". Variable #i eti$e

=lobal !ariable e&i t $or the perio" o$ time that the program i running. 6ocal !ariable are create" #hen a ubroutine i calle"% an" e&pire #hen the ubroutine terminate . Static !ariable may ha!e a cope that applie #ithin a ingle ubroutine% ho#e!er they ha!e a li$etime that e&i t $or the $ull perio" that the program i e&ecuting% an"

1*

they retain their !alue $rom one call to the ubroutine to the ne&t. 4ynamically create" "ata item e&i t until they are $ree". 4ynamic memory allocation in!ol!e creating "ata item #hile a program i running. Thi may be "one e&plicitly% or it may occur automatically #hen the la t remaining !ariable that point to the item i a igne" a "i$$erent !alue% or e&pire a it le!el o$ cope terminate .

2.1.2.

%&ecution

2.1.2.1. %&pressions

An e&pre ion i a combination o$ con tant % !ariable an" operator that i u e" to calculate a !alue.

12

An a ignment operation in!ol!e a !ariable name an" an e&pre ion. The e&pre ion i e!aluate"% an" the !alue o$ the !ariable i change" to e'ual the re ult o$ the e&pre ion. ;&pre ion are al o u e" #ithin control $lo# tatement uch a -i$. tatement an" loop .

0umeric e&pre ion inclu"e the tan"ar" arithmetic operation o$ a""ition% ubtraction% multiplication an" "i!i ion an" e&ponentiation. The ba ic tring operation are concatenating t#o tring to $orm a ingle tring% e&tracting a ub tring% an" comparing tring . String e&pre ion may inclu"e con tant tring % tring !ariable % an" operator a a concatenation operator. Boolean !ariable an" e&pre ion ha!e only t#o po ible !alue % -true. an" -$al e.. uch

15

An e&pre ion containing a relational operator% uch a ->?.% i a Boolean e&pre ion. 3or e&ample% -* > 3. ha the !alue -$al e.. The Boolean operator -an".% -or. an" -not. can al o be u e" in e&pre ion . An -an". e&pre ion ha the !alue -true. #hen both part are true% an -or. e&pre ion ha the !alue -true. #hen either !alue i true% an" a -not. e&pre ion re!er e the !alue. Boolean e&pre ion are u e" #ithin -i$. tatement to e&ecute co"e un"er certain con"ition an" #ithin loop to repeat a erie o$ tatement #hile a con"ition remain true.

2.1.2.2. State$ents 2.1.2.2.1. 'ssi(n$ent State$ents

17

An a ignment tatement contain a !ariable name% an a ignment ymbol uch a an -?. ign% an" an e&pre ion. The e&pre ion i e!aluate"% an" the !alue o$ the !ariable i e&pre ion. Some language are e&pre ion/$ocu e" rather than tatement/$ocu e". In the e language % an a ignment operation may it el$ be an e&pre ion% an" may be u e" #ithin other e&pre ion . et to e'ual the re ult o$ the

2.1.2.2.2. Control )lo* 2.1.2.2.2.1. + State$ents

An -i$. tatement contain a Boolean e&pre ion an" an a ociate" block o$ co"e. The e&pre ion i e!aluate"% an" i$ the re ult

1:

i true then the tatement #ithin the block are e&ecute"% other#i e they are kippe". An -i$. tatement may al o ha!e a block o$ co"e attache" to an -el e. ection. I$ the e&pre ion i $al e% then the co"e #ithin the -el e. ection i e&ecute"% other#i e it i kippe".

2.1.2.2.2.2. #oops

A loop tatement may contain a Boolean e&pre ion. The e&pre ion i e!aluate"% an" i$ it i true then the co"e #ithin the block i e&ecute". The control $lo# then return to the beginning o$ the loop% an" the cycle repeat the loop each time that the con"ition e!aluate to true. @ther loop tatement may al o be a!ailable% uch a tatement that peci$y a $i&e" number o$ iteration % or tatement that loop through all item in a language "ata tructure.

20

2.1.2.2.2.3. ,oto

Some language

upport a -goto. tatement.

A goto tatement cau e a <ump to a "i$$erent point in the program to continue e&ecution. )o"e that u e goto tatement can "e!elop !ery comple& control $lo# an" may be "i$$icult to "ebug an" mo"i$y. Some language al o upport tructure" goto operation % uch a a tatement that terminate the current loop mi"/#ay through the loop co"e. The e operation "o not complicate the control $lo# to the ame e&tent a general goto tatement % ho#e!er the e operation can be ea ily mi e" #hen co"e i being rea".

21

3or e&ample% a tatement in an early part o$ a comple& loop may re ult in the loop being e&ite" #hen it i e&ecute". Thi tatement complicate the control $lo# an" may make interpreting the loop co"e more "i$$icult.

2.1.2.2.2.4. %&ceptions

In ome language % e&ception han"ling ubroutine an" ection o$ co"e can be "e$ine". The e co"e ection are automatically e&ecute" #hen an error occur .

2.1.2.2.2.5. Subroutine Calls

Inclu"ing the name o$ a ubroutine #ithin a tatement cau e the ubroutine to be calle". The ubroutine name may be part o$ an

22

e&pre ion% or it may be an in"i!i"ual tatement. 8hen the ubroutine i calle"% program e&ecution <ump to the beginning o$ the ubroutine an" e&ecution continue at that point. 8hen the co"e in the ubroutine ha been e&ecute"% or a termination tatement i per$orme"% the ubroutine terminate an" e&ecution return to the ne&t tatement $ollo#ing the original ubroutine call.

2.1.2.3. Subroutines

Subroutine are in"epen"ent block o$ co"e that are re$erre" to by name. +rogram are compo e" o$ a collection o$ ubroutine .

23

8hen e&ecution reache a ubroutine call the program e&ecution <ump to the beginning o$ the ubroutine. )ontrol $lo# return to the point $ollo#ing the ubroutine call #hen the ubroutine terminate . Subroutine may inclu"e parameter . The e are !ariable that can be acce e" #ithin the ubroutine. The !alue o$ the parameter i i per$orme". )alling co"e can pa call. +arameter are pa e" in !ariou #ay . -)all/by/!alue. pa e the !alue o$ the "ata to the ubroutine. -)all/by/re$erence. pa e a re$erence to the !ariable in the calling routine% an" the ubroutine can alter the !alue con tant "ata !alue or et by the calling co"e #hen the ubroutine call

!ariable a the parameter to a ubroutine

2,

o$ a parameter !ariable #ithin the calling routine. )all by !alue lea" to $e#er une&pecte" e$$ect in the calling routine% ho#e!er returning more than one !alue $rom a ubroutine may be "i$$icult. Subroutine may al o contain local !ariable . The e !ariable are acce ible only #ithin the ubroutine% an" are create" each time that the ubroutine i calle". In ome language % ubroutine can al o call them el!e . Thi i kno#n a recur ion an" "oe not era e the pre!iou call to the ubroutine. A ne# et o$ local !ariable i create"% an" $urther call can be ma"e. Thi proce i u e" $or $unction that

in!ol!e branching to e!eral point at each tage in a proce . A each ubroutine call terminate % e&ecution return to the pre!iou le!el.

2*

2.1.2.4. Co$$ents

)omment are inclu"e" #ithin program co"e $or the bene$it o$ a human rea"er. )omment are i"enti$ie" a eparate te&t item % an" are ignore" #hen the program i compile". )omment are u e" to inclu"e a""itional in$ormation #ithin the co"e that i rele!ant to a particular calculation or proce % an" to "e cribe "etail o$ the $unction #ithin a comple& ection o$ co"e.

22

2.2. Declarative Languages


A "eclarati!e program "e$ine in$ormation an" $act . In contra t% proce"ural co"e peci$ie a et o$ operation that are e&ecute" in e'uence. 4eclarati!e co"e i not e&ecute" "irectly% but i u e" a input to other proce e . 3or e&ample% a "eclarati!e program may "e$ine a et o$ pattern % #hich i u e" by a par er to i"enti$y pattern an" ub/pattern #ithin a et o$ input "ata. @ther "eclarati!e y tem u e a et o$ $act to ol!e a problem that i pre ente". 4eclarati!e language are al o u e" to "e$ine et o$ item % uch a recor" #ithin "ata 'uerie . 25 tructure an"

pattern % an" may contain a et o$

4eclarati!e program are !ery po#er$ul in the operation that can be per$orme"% in compari on to the iAe an" comple&ity o$ the co"e. 3or e&ample% all po ible program can be compile" u ing a "e$inition o$ the language grammar. Al o% a problem ol!ing engine can ol!e all problem that $all #ithin the cope o$ the in$ormation that ha been pro!i"e". 3act may inclu"e ba ic "ata% an" may al o peci$y that t#o thing are e'ui!alent. 3or e&ampleB &Cy?AD2 Month304ay ? April @E Fune @E September @E 0o!ember

27

3iel"0ame ? 3,2/GGG/,*3 e&pre ionB number -C. e&pre ion

The $ir t e&ample i a mathematical tatement that t#o e&pre ion are e'ui!alent% the econ" e&ample peci$ie that -Month304ay . i e'ual to a et o$ $our month % the thir" e&ample matche the et o$ $iel" name beginning #ith 3,2 an" en"ing #ith ,*3% an" the $ourth e&ample peci$ie a pattern in a language grammar. +attern may be recur i!ely "e$ine"% uch a peci$ying that bracket #ithin an e&pre ion may contain an entire e&pre ion% #ith potentially in$inite le!el o$ ub/e&pre ion . 4eclarati!e co"e may in!ol!e pattern % #hich ha!e a $i&e" tructure% an" et % #hich are unor"ere" collection o$ item .

2:

2.2.1.

Co-e Structure

4eclarati!e co"e may contain key#or" % name % con tant % operator an" tatement . Hey#or" are language key#or" that may be u e" to eparate ection o$ the program an" i"enti$y the type o$ in$ormation that i recor"e". The name may i"enti$y pattern % #hile the operator may be u e" to create a ne# pattern $rom other pattern . Statement may be entere" in the $orm o$ peci$ying that t#o e&pre ion are e'ui!alent. The chain o$ connection i "e$ine" by the appearance o$ name #ithin "i$$erent tatement . There i no or"er #ithin a tatement or $rom one tatement to the ne&t.

30

2.3. Other Languages


+rogramming language appear in a #i"e !ariety o$ $orm an" tructure . In the language 6IS+% $or e&ample% all proce ing i per$orme" #ith li t % an" a 6IS+ program con i t o$ multiple bracket #ithin bracket "e$ining li t o$ "ata an" in truction

31

3. Topics from Computer Science

3.1. E ecution Platforms


3.1.1. .ar-*are

)omputer har"#are e&ecute a imple et o$ in truction kno#n a machine co"e. Machine co"e inclu"e in truction to mo!e "ata bet#een memory location % per$orm ba ic calculation uch a multiplication% an" <ump to "i$$erent point in the co"e "epen"ing on a con"ition. @nly machine co"e can be "irectly e&ecute". +rogram #ritten in programming language are con!erte" to a machine co"e $ormat be$ore they are e&ecute".

32

Machine co"e in truction an" "ata are tore" in memory #hile a program i running.

3.1.2.

/peratin( syste$s

An operating y tem i a program that manage the operation o$ a computer. The operating y tem per$orm a #i"e range o$ $unction % inclu"ing managing the creen "i play an" other u er inter$ace component % implementing the "i k $ile y tem% managing e&ecution o$ proce e % an" managing memory allocation an" har"#are "e!ice . =enerally program a "e!elope" to run on a particular operating y tem an" igni$icant change may be re'uire" to run on other operating y tem . Thi may inclu"e changing the #ay that creen proce ing i han"le"% changing the memory management

33

proce e % an" changing $ile an" "ataba e operation .

3.1.3.

Co$pilers

A compiler i a program that generate an e&ecutable $ile $rom a program ource co"e $ile. The e&ecutable $ile contain a machine co"e !er ion o$ the program that can be "irectly e&ecute". @n ome y tem % the compiler pro"uce ob<ect co"e $ile . @b<ect co"e i a machine co"e $ormat ho#e!er the re$erence to "ata location an" ubroutine ha!e not been linke". In the e ca e % a eparate program kno#n a a linker i u e" to link the ob<ect mo"ule together to $orm the e&ecutable $ile.

3,

3ully compile" co"e i generally the $a te t #ay to e&ecute a program. 1o#e!er% compilation i a comple& proce an" can be lo# in ome ca e .

3.1.4.

+nterpreters

An interpreter e&ecute a program "irectly $rom the ource co"e% rather than pro"ucing an e&ecutable $ile. Interpreter may per$orm a partial compilation to an interme"iate co"e $ormat% an" e&ecute the interme"iate co"e internally. Thi approach i lo#er than u ing a $ully

compile" program% an" al o the interpreter mu t be a!ailable to run the program. The program cannot be run "irectly in a tan"/ alone en!ironment.

3*

1o#e!er% interpreter ha!e a number o$ a"!antage . An interpreter tart imme"iately% an" may inclu"e $le&ible "ebugging $acilitie . Thi may inclu"e !ie#ing the co"e% tepping through proce e % an" e&amining the !alue o$ "ata !ariable . In ome ca e the co"e can be mo"i$ie" #hen e&ecution i halte" part/ #ay through a program.

3.1.5.

Virtual 0ac1ines

A !irtual machine pro!i"e a run/time en!ironment $or program e&ecution. The !irtual machine e&ecute a $orm o$ interme"iate co"e% an" al o pro!i"e a tan"ar" et o$ $unction an" ubroutine call to upply the in$ra tructure nee"e" $or a program to acce a u er inter$ace an" general operating y tem $unction .

32

9irtual machine are u e" to pro!i"e portability acro "i$$erent operating plat$orm % an" al o $or ecurity purpo e to pre!ent program $rom acce ing "e!ice uch a "i k torage. An e&ten ion to a !irtual machine i a <u t/in/ time compiler% #hich compile each ection o$ co"e a it begin e&ecuting.

3.1.6.

+nter$e-iate Co-e %&ecution

A run/time e&ecution routine can be u e" to e&ecute interme"iate co"e that ha been generate" by compiling ource co"e. +rogram may be #ritten u ing a language "e!elope" peci$ically $or an application% uch a $ormula e!aluation y tem or a macro language.

35

The y tem may contain a par er% co"e generator an" run/time e&ecution routine. Alternati!ely% the co"e generation coul" be "one eparately% an" the interme"iate co"e coul" be inclu"e" a "ata #ith the application.

3.1.!.

#in2in(

In ome en!ironment % ubroutine librarie can be linke" into a program tatically or "ynamically. A tatically linke" library i linke" into the e&ecutable $ile #hen it i create". The co"e $or the ubroutine that are calle" $rom the program are inclu"e" #ithin the e&ecutable $ile.

37

Thi en ure that all the co"e i pre ent% an" that the correct !er ion o$ the co"e i being u e". 1o#e!er% e&ecutable $ile may become large #ith thi approach. Al o% thi pre!ent the y tem $rom u ing up"ate" librarie to correct bug or impro!e per$ormance% #ithout u ing a ne# e&ecutable $ile. Static linking may only be a!ailable $or ome librarie an" may not be a!ailable $or ome $unction uch a operating y tem call .

4ynamic linking in!ol!e linking to the library #hen the program i e&ecuting. Thi allo# the program to u e $acilitie that are a!ailable #ithin the en!ironment% uch a operating y tem $unction . 4ynamically linke" librarie can be up"ate" to correct bug an" impro!e per$ormance% #ithout altering the main e&ecutable $ile.

3:

1o#e!er% problem can ari e #ith "i$$erent !er ion o$ librarie .

,0

3.2. Code E ecution !odels


3.2.1. Sin(le %&ecution T1rea-

+rogram e&ecution i generally ba e" on the mo"el o$ a ingle threa" o$ e&ecution. ;&ecution begin #ith the $ir t tatement in the program an" continue through ubroutine call % loop an" -i$. tatement until the program $inally terminate . At any point in time% the current in truction po ition #ill only apply to a ingle point #ithin the co"e. A y tem may inclu"e e!eral ma<or proce e an" threa" % but #ithin each ma<or block the ingle e&ecution threa" mo"el i maintaine".

,1

3.2.2.

Ti$e Slicin(

In or"er to run multiple program an" proce e u ing a ingle central proce ing unit% many operating y tem implement a time licing y tem. Thi approach in!ol!e running each proce $or a !ery hort perio" o$ time% in rapi" ucce ion. Thi create the e$$ect o$ e!eral program running imultaneou ly% e!en though only a ingle machine co"e in truction i e&ecuting at any point in time.

3.2.3.

Processes an- T1rea-s

@n many y tem % multiple program may be run imultaneou ly% inclu"ing more than one copy o$ a ingle program. An e&ecuting program i kno#n a a proce . ;ach running program i an in"epen"ent

,2

proce

an" e&ecute concurrently #ith the

other proce e . A program may al o tart in"epen"ent proce e $or ma<or o$t#are component uch a $unctional engine . Some y tem al o upport threa" . A threa" i an in"epen"ently e&ecuting ection o$ co"e. Threa" may not be entire program ho#e!er they are generally larger $unctional component than a ingle ubroutine. Threa" are u e" $or ta k uch a

backgroun" printing% compacting "ata tructure #hile a program i running an" o $orth. @n y tem that upport multiple u er terminal #ith a central har"#are y tem% u er can tart proce e $rom a terminal. Multiple proce e may operate concurrently% inclu"ing multiple e&ecuting copie o$ a ingle program.

,3

3.2.4.

Parallel Pro(ra$$in(

6anguage ha!e been "e!elope" to upport parallel programming. +arallel programming i ba e" on an e&ecution mo"el that allo# in"i!i"ual ubroutine to e&ecute in parallel. The e y tem may be e&tremely "i$$icult to "ebug. Synchroni ation co"e i re'uire" to pre!ent con$lict #hen t#o ubroutine attempt to up"ate the ame ection o$ "ata% an" to en ure that one ta k "oe not commence until relate" ta k ha!e complete". +arallel programming i rarely u e". Total e&ecution time i not re"uce" by the parallel e&ecution proce % a the total )+I time

,,

re'uire" to per$orm particular ta k i unchange".

3.2.5.

%vent Driven Co-e

;!ent "ri!en co"e i an e&ecution mo"el that in!ol!e ection o$ co"e being automatically triggere" #hen a particular e!ent occur . 3or e&ample% electing a $unction in a graphical u er inter$ace en!ironment may lea" to a relate" ubroutine being automatically calle". In ome y tem e!eral e!ent coul" occur

in rapi" ucce ion an" e!eral ection o$ co"e coul" run concurrently. Thi i not po ible #ith a tan"ar" menu/ "ri!en y tem% #here a proce run. mu t can be complete be$ore a "i$$erent proce

,*

;!ent "ri!en co"e upport a $le&ible e&ecution en!ironment #here co"e can be "e!elope" an" e&ecute" in in"epen"ent ection .

3.2.6.

+nterrupt Driven Co-e

Interrupt "ri!en co"e i u e" in har"#are inter$acing an" in"u trial control application . In the e ca e % a har"#are ignal cau e a ection o$ co"e to be triggere". Inter$acing #ith har"#are "e!ice i generally con"ucte" u ing interrupt or polling. +olling in!ol!e checking a "ata regi ter continually to check #hether "ata i a!ailable. An interrupt "ri!en approach "oe not re'uire" polling% a the interrupt han"ling routine i triggere" #hen an interrupt occur .

,2

,5

3.3. Data structures

3.3.1.

'((re(ate -ata types

3.3.1.1. 'rrays 3.3.1.1.1. Stan-ar- 'rrays

Array are the $un"amental "ata tructure that i u e" #ithin thir"/generation language $or toring collection o$ "ata. An array contain multiple "ata item o$ the ame type. ;ach item i re$erre" to by a number% kno#n a the array in"e&. In"e&e are integer !alue an" may tart at 0% 1% or ome other !alue "epen"ing on the "e$inition an" the language. Array can ha!e multiple "imen ion . 3or e&ample% "ata in a t#o/"imen ional array

,7

#oul" be in"e&e" u ing t#o in"epen"ent number . A t#o "imen ional array i imilar to a gri" layout o$ "ata% #ith the ro# an" column number being u e" to re$er to an in"i!i"ual "ata item. Array can generally contain any "ata type% uch a Acce tring % integer an" tructure . to an array element may be e&tremely

$a t% an" may be only lightly lo#er than acce ing an in"i!i"ual "ata !ariable. Array are al o kno#n a table . Thi particularly applie to an array o$ tructure % #hich may be imilar to a table #ith ro# o$ the ame $ormat but "i$$erent "ata in each column. A table al o re$er to an array o$ "ata that i u e" $or re$erence #hile a program e&ecute . In ome ca e the in"e& entry o$ the array may repre ent an in"epen"ent "ata !alue% an"

,:

the array may be acce e" "irectly u ing a "ata item. In other ca e an array i imply u e" to tore

a li t o$ item % an" the in"e& !alue "oe not ha!e any particular igni$icance. In ca e #here the array i u e" to tore a li t o$ "ata% the or"er o$ the item may or may not be igni$icant% "epen"ing on the type an" u e o$ the "ata. The $ollo#ing "iagram illu trate a t#oJ "imen ional array.

*0

3.3.1.1.2. Ra((e- 'rrays

Stan"ar" array are 'uare. In a t#o/ "imen ional ca e% e!ery ro# ha the ame number o$ column % an" e!ery column ha the ame number o$ ro# . A ragge" array i an array tructure #here the in"i!i"ual column % or another "imen ion% may ha!e !arying iAe . Thi coul" be implemente" u ing a one/ "imen ional array $or one "imen ion an" linke" li t $or each column. Alternati!ely% a ingle large array coul" be u e"% an" the ro# an" column po ition coul" be calculate" ba e" on a table o$ column length . The $ollo#ing "iagram illu trate a ragge" array.

*1

3.3.1.1.3. Sparse 'rrays

A par e array i a large array that contain many unu e" element . Thi can occur #hen a "ata item i u e" a an in"e& into the array% o that item can be acce e" "irectly% ho#e!er the "ata item contain gap bet#een in"i!i"ual !alue . 8here entire ro# or column are mi ing% thi tructure coul" be implemente" a a compacte" array. Alternati!ely% the in"e& !alue coul" be combine" into a ingle te&t key% an" the "ata

*2

item coul" be tore" by key u ing a tructure uch a a ha h table or tree. Another approach may in!ol!e u ing a tan"ar" array $or one "imen ion% an" linke" li t to tore" the actual "ata an" o a!oi" the unu e" element in the econ" "imen ion. A par e array i ho#n belo#

" " " "

" "

" " "

" "

3.3.1.1.4. 'ssociative 'rrays

An a ociati!e array i an array that u e a tring !alue% rather than an integer a the in"e& !alue.

*3

A ociati!e array can be implemente" u ing tructure uch a tree or ha h table .

A ociati!e array may be u e$ul $or a"/hoc program % a co"e can 'uickly an" ea ily be #ritten u ing an a ociati!e array that #oul" re'uire canning array an" other proce ing u ing tan"ar" co"e. 1o#e!er% "ue to the u e o$ tring an" the earching in!ol!e" in locating element % the e tructure #oul" ha!e lo#er acce time than other "ata tructure .

3.3.1.2. Structures

A tructure i a collection o$ in"i!i"ual "ata item . Structure are al o kno#n a recor" in ome language . A programming tructure i to a "ataba e recor". imilar in $ormat

*,

Array o$ tructure are !i ually imilar to a gri" layout o$ "ata #ith each ro# ha!ing the ame type% but "i$$erent column containing "i$$erent "ata type .

3.3.1.3. /b3ects

In ob<ect orientate" programming% a "ata tructure kno#n a an ob<ect i u e". An ob<ect i a tructure type% an" contain a collection o$ in"i!i"ual "ata item . 1o#e!er% ubroutine kno#n a metho" are al o "e$ine" #ith the ob<ect "e$inition% an" metho" can be e&ecute" by u ing the metho" name #ith a "ata !ariable o$ that ob<ect type.

**

3.3.2.

#in2e- Data Structures

6inke" "ata tructure con i t o$ no"e containing "ata an" link . A no"e can be implemente" a a tructure type. Thi may contain in"i!i"ual "ata item % together #ith link that are u e" to connect to other no"e . 6ink can be implemente" u ing pointer % #ith "ynamically create" no"e % or no"e coul" be tore" in an array an" array in"e& !alue coul" be u e" a the link . I ing "ynamic memory allocation an" pointer re ult in imple co"e% an" "oe not in!ol!e "e$ining the iAe o$ the tructure in a"!ance. An array implementation may re ult in more comple& co"e% although it may be $a ter a allocating an" "eallocating memory #oul" not be re'uire".

*2

Inlike "ynamic "ata allocation% the array entrie are acti!e at all time . ;ntrie that are not currently u e" #ithin the "ata tructure may be linke" together to $orm a $ree li t% #hich i u e" $or allocation #hen a ne# no"e i re'uire".

3.3.2.1. #in2e- #ists

A linke" li t i a tructure #here each no"e contain a link to the ne&t no"e in the li t. Item can be a""e" to li t an" "elete" $rom li t in a ingle operation% regar"le o$ the iAe o$ the li t. Al o% #hen "ynamic memory allocation i u e" the iAe o$ the li t i not $i&e" an" can !ary #ith the a""ition an" "eletion o$ no"e . 1o#e!er% element in a linke" li t cannot be acce e" at ran"om% an" in general the li t

*5

mu t be earche" to locate an in"i!i"ual item.

3.3.2.2. Doubly #in2e- #ists

A "oubly linke" li t contain link to both the ne&t no"e an" the pre!iou no"e in the li t. Thi allo# the li t to be canne" in either "irection. Al o% a no"e can be a""e" to or "elete" $rom a li t be re$erring to a ingle no"e. In a ingly linke" li t% a pointer to the pre!iou no"e mu t be eparately a!ailable in or"er to per$orm a "eletion.

*7

3.3.2.3. 4inary Trees

A binary tree i a tructure in #hich a no"e contain a link to a le$t no"e an" a link to a right no"e. Thi may $orm a tree tructure that branche out at each le!el. Binary tree are u e" in a number o$ algorithm uch a par ing an" orting.

The number o$ le!el in a $ull an" balance" binary tree i e'ual to log2(nC1) $or -n. item .

*:

3.3.2.4. 4trees

A B/tree i a tree tructure that contain multiple branche at each no"e. A B/tree i more comple& to implement than a binary tree or other tructure % ho#e!er a B/tree i el$ balancing #hen item are a""e" to the tree or "elete" $rom the tree. B/tree are u e" $or implementing "ataba e in"e&e .

20

3.3.2.5. Sel 54alancin( Trees

A el$/balancing tree i a tree that retain a balance" tructure #hen item are a""e" an" "elete"% an" remain balance" regar"le the or"er o$ the input "ata. o$

3.3.3.

#inear Data Structures

3.3.3.1. Stac2s

A tack i a "ata tructure that tore a erie o$ item .

21

8hen item are remo!e" $rom the tack% they are retrie!e" in the oppo ite or"er to the or"er in #hich they #ere place" on the tack. Thi i al o kno#n a a 6I3@% 6a t/In/3ir t/ @ut tructure. The $un"amental operation #ith a tack are +IS1% #hich place a ne# "ata item on the top o$ the tack% an" +@+% #hich remo!e the item that i on the top o$ the tack. A tack can be implemente" u ing an array% #ith a !ariable recor"ing the po ition o$ the top o$ the tack #ithin the array. Stack are u e" $or e!aluating e&pre ion % toring temporary "ata% toring local !ariable "uring ubroutine call an" in a number o$ "i$$erent algorithm .

22

3.3.3.2. 6ueues

A 'ueue i u e" to tore a number o$ item . Item that are remo!e" $rom the 'ueue appear in the ame or"er that they #ere place" into the 'ueue. A 'ueue i al o kno#n a a 3I3@% 3ir t/In/ 3ir t/@ut tructure. Kueue are u e" in tran $erring "ata bet#een in"epen"ent proce e % uch a inter$ace #ith har"#are "e!ice an" inter/proce communication.

23

3.3.4.

Co$pacte- Data Structures

Memory u age can be re"uce" #ith "ata that i not mo"i$ie" by placing the "ata in a eparate table% an" replacing "uplicate" entrie #ith a ingle entry.

3.3.4.1. Co$pacte- 'rrays

A compacte" array can ometime be u e" to re"uce torage re'uirement $or a large array% particularly #hen the "ata i $or a $inite tate automaton. In the ca e o$ a t#o "imen ional array% a a""itional one/"imen ional array #oul" be create". tore" a a rea"/ only re$erence% uch a tate tran ition table

2,

;ntrie

uch a blank an" "uplicate" ro#

coul" be remo!e" $rom the main array% an" the remaining "ata compacte" to remo!e the unu e" ro# . Thi may in!ol!e orting the array ro# o that a"<acent i"entical ro# coul" be replace" #ith a ingle ro#. The econ" array #oul" then be u e" a an in"irect in"e& into the main array. The original array in"e&e #oul" be u e" to in"e& the ne# array% #hich #oul" contain the in"e& into the compacte" main array. An in"irectly a""re e" compacte" array i ho#n belo#

2*

3.3.4.2. Strin( Tables

3or e&ample% #here a et o$ tring i recor"e" in a "ata tructure% a eparate tring table can be create". The tring table #oul" be an array containing the tring % #ith one entry $or each uni'ue tring. The main "ata table #oul" then contain an in"e& into the tring table.

ab c

i$ integer #hile

3.3.5.

/t1er Data Structures

3.3.5.1. .as1 tables

22

A ha h table i a "ata tructure that i "e igne" $or toring "ata that i acce e" u ing a tring !alue rather than an integer in"e&. A ha h table can be implemente" u ing an array% or a combination o$ an array an" a linke" tructure. Acce ing an entry in a ha h table i "one u ing a ha h $unction. The ha h $unction i a calculation that generate a number in"e& $rom the tring key. The ha h $unction i cho en o that the in"e&e that are generate" #ill be e!enly prea" throughout the array% e!en i$ the tring key are clu tere" into group . 8hen the ha h !alue i calculate" $rom the input key% the "ata item may be tore" in the array element in"e&e" by the ha h !alue. I$ the entry i alrea"y in u e% another ha h !alue

25

may be calculate" or a earch may be per$orme". Eetrie!ing item $rom the ha h table i "one by per$orming the ame calculation on the input key to "etermine the location o$ the "ata. Acce ing a ha h table i lo#er than

acce ing an array% a a calculation i in!ol!e". 1o#e!er% the ha h $unction ha a $i&e" o!erhea" an" the acce pee" "oe not re"uce a the iAe o$ the table increa e . Acce to a ha h table can lo# a the table

become $ull. 1a h table pro!i"e a relati!ely $a t #ay to acce "ata by a tring key. 1o#e!er% item in a ha h table can only be acce e" in"i!i"ually% they cannot be retrie!e" in e'uence% an" a ha h table i more comple& to implement than alternati!e "ata tructure uch a tree .

27

3.3.5.2. .eap

A heap i an area o$ memory that contain memory block o$ "i$$erent iAe . The e block may be linke" together u ing a linke" li t arrangement. 1eap are u e" $or "ynamic memory allocation. Thi may inclu"e memory allocation $or tring % an" memory allocate" #hen ne# "ata item are create" a a program run . Implementing a heap can be "one u ing pointer an" a large block o$ memory. Thi re'uire acce ing the memory a a binary block% an" creating link an" pace #ithin the block% rather than treating the memory pace a a program !ariable.

2:

Inu e" block are linke" together to $orm a $ree li t% #hich i u e" #hen ne# allocation are re'uire".

ab c

3.3.5.3. 4u er

A bu$$er i an area o$ memory that i "e igne" to be treate" a a block o$ binary "ata% rather than an in"i!i"ual "ata !ariable. Bu$$er are u e" to hol" "ataba e recor" % tore "ata "uring a con!er ion proce that in!ol!e acce ing in"i!i"ual byte #ithin the block% an" a a tran $er location #hen 50

tran $erring "ata to other proce e or har"#are "e!ice . Bu$$er can be acce e" u ing pointer . In ome language % a bu$$er may be han"le" a an array "e$inition #ith the array containing mall integer "ata type % #ith the a umption that the memory block occupie a contiguou ection o$ memory.

3.3.5.4. Te$porary Database

Although "ataba e are generally u e" $or the permanent torage o$ "ata% in ome ca e it may be u e$ul to u e a "ataba e a a "ata tructure #ithin a program. +er$ormance #oul" be igni$icantly lo#er than "irect memory acce e ho#e!er the u e o$ a "ataba e a program element #oul" ha!e e!eral a"!antage

51

A "ataba e ha !irtually unlimite" iAe% either tring or numeric !ariable can be u e" a an in"e& !alue% ran"om acce e are rapi"% large gap bet#een numeric in"e& !alue are automatically han"le" an" no co"e nee" to be #ritten to implement the y tem.

3.3.6.

#an(ua(e5Speci ic Structures

Some language inclu"e "ata tructure #ithin the ynta& o$ the language% in a""ition to the commonly implemente" array an" tructure type . In the language 6IS+% $or e&ample% all "ata i tore" #ithin li t % an" program co"e i #ritten a in truction containe" #ithin li t . The e li t are implemente" "irectly #ithin the ynta& o$ the language.

52

3.3.!.

Data Structure Co$parison

Structur e

Acce Metho"

Ean"om Acce Time

A""ition L 4eletion Time

3ull Scan

Memor y I age

Array

4irect In"e& Search ( orte") Search (un orte")

1 6og2(n) J 1 nN2

1 nN2 1

Me

1 item

6inke" 6i t

Search

nN2

Me

1 item C1 link

Binary Tree

Search (3ully Balance") Search (3ully Inbalance ")

log2(n) J 1

log2(n) J 1 (a""ition)

Me

1 item C2 link

nN2

nN2 (a""ition)

1a h Table

String

1 ha h $unction

1 ha h $unction

0o

1 item C imple

53

mentat ion o!erhe a"

5,

3.". #lgorithms
An algorithm i a tep by tep metho" $or calculating a particular re ult or per$orming a proce . 3or e&ample% the $ollo#ing tep "e$ine the orting algorithm kno#n a a bubble ort.

1. Scan the li t an" elect the malle t item. 2. Mo!e the malle t item to the en" o$ the ne# li t. 3. Eepeat tep 1 an" 2 until all item ha!e been place" into the ne# li t.

In many ca e

e!eral "i$$erent algorithm

can be u e" to per$orm a particular proce . The algorithm may !ary in the comple&ity o$ implementation% the !olume o$ "ata u e"

5*

or generate"% an" the e&ecution time nee"e" to complete the proce .

3.4.1.

Sortin(

Sorting i a lo# proce

that con ume a

igni$icant proportion o$ all proce ing time. Sorting i u e" #hen a report or "i play i pro"uce" in a orte" or"er% an" #hen a proce ing metho" or algorithm in!ol!e the proce ing o$ "ata in a particular or"er. Sorting i al o u e" in "ata tructure an" "ataba e to tore "ata in a $ormat that allo# in"i!i"ual item to be locate" 'uickly. A range o$ "i$$erent orting algorithm can be u e" to ort "ata.

52

3.4.1.1. 4ubble Sort

The bubble ort metho" in!ol!e rea"ing the li t an" electing the malle t item. The li t i then rea" a econ" time to elect the econ" malle t item% an" o on until the entire li t i orte". Thi proce item . 1o#e!er% the bubble ort techni'ue i ine$$icient an" in!ol!e an or"er o$ n2 compari on to ort a li t o$ -n. item . Sorting an array o$ one million "ata item #oul" re'uire a trillion in"i!i"ual compari on u ing the bubble ort metho". 8hen more than a $e# "oAen item are in!ol!e"% alternati!e algorithm 'uick ort metho" can be u e". uch a the i imple to implement an" may

be u e$ul #hen a li t contain only a $e#

55

3.4.1.2. 6uic2sort

The e algorithm in!ol!e u ing an or"er o$ nDlog2(n) compari on to complete the orting proce . In the pre!iou e&ample% thi #oul" be e'ual to appro&imately 20 million compari on $or the li t o$ one million item . The 'uick ort algorithm in!ol!e electing

an element at ran"om #ithin the li t. All the item that ha!e a lo#er !alue than the pi!ot element are mo!e" to the beginning o$ the li t% #hile the item #ith a !alue that i greater than the pi!ot element are mo!e" to the en" o$ the li t. Thi proce proce li t i i then applie" eparately to

each o$ the t#o part o$ the li t% an" the continue recur i!ely until the entire orte".

57

subroutine qsort(start_item as integer, end_item as integer) pivot_item as integer bottom_item as integer top_item as integer pivot_item = start_item + (Rnd * (end_item start_item)) bottom_item = start_item top_item = end_item !hile bottom_item " top_item !hile data(bottom_item) " data(pivot_item) bottom_item = bottom_item + # end if bottom_item " pivot_item tmp = data(bottom_item) data(bottom_item) = data(pivot_item) data(pivot_item) = tmp pivot_item = bottom_item end !hile data(top_item) $ data(pivot_item) top_item = top_item end if top_item $ pivot_item tmp = data(top_item) data(top_item) = data(pivot_item) data(pivot_item) = tmp pivot_item = top_item #

5:

end end if pivot_item $ start_item + # qsort start_item, pivot_item end if pivot_item " end_item end end # #

qsort pivot_item + #, end_item

3.4.2.

4inary Tree Sort

A binary tree ort in!ol!e in erting the li t !alue into a binary tree% an" canning the tree to pro"uce the orte" li t. Item are in erte" by comparing the ne# item #ith the current no"e. I$ the item i le than the current no"e% then the le$t path i taken% other#i e the right path i taken. The compari on continue at each no"e until an en" point i reache" #here a ub/tree "oe 70

not e&i t% an" the item i a""e" to the tree at that point. Scanning the tree can be "one u ing a recur i!e ubroutine. Thi call it el$ to proce it el$ to proce ubroutine #oul" the le$t ub tree% output

the !alue in the current no"e% an" then call the right ub/tree. imple to implement.

A binary tree ort i

8hen the input !alue appear in a ran"om or"er% thi algorithm pro"uce a balance" tree an" the orting time i o$ the or"er o$ nDlog2(n). 1o#e!er% #hen the input "ata i alrea"y orte" or i clo e to orte"% the binary tree "egenerate into a imple linke" li t. In thi ca e% the orting time increa e to an or"er o$ n2.
subroutine insert_item if insert_value " current_value if left_node_e%ists ne%t_node = left_node

71

else insert item as ne! left node end else if right_node_e%ists ne%t_node = right_node else insert item as ne! right node end end end

subroutine tree_scan if left node e%ists call tree_scan on left node end output current node value if right node e%ists call tree_scan on right node end end

72

3.4.3.

4inary Searc1

A earch on a orte" li t can be con"ucte" u ing a binary earch. Thi i a $a t an" imple techni'ue that re'uire appro&imately log2(n)/1 compari on to locate an item. In a li t o$ one million item % thi corre pon" to appro&imately 1: compari on . In contra t a "irect can o$ the li t #oul" re'uire an a!erage o$ hal$ a million compari on . A binary earch i per$orme" by comparing the earch tring #ith the item in the centre o$ the li t. I$ the earch tring ha a lo#er !alue than the central item% then the $ir t hal$ o$ the li t i hal$ i electe"% other#i e the econ" electe".

73

The proce

then repeat % "i!i"ing the i

electe" hal$ in hal$ again. Thi proce repeate" until the item i locate".

&ubroutine binar'_search
found as integer top_item as integer bottom_item as integer middle_item as integer found = (alse bottom_item = start_item top_item = end_item !hile not found )nd bottom_item " top_item middle_item = (bottom_item + top_item) * + if search_val = data(middle_item) found = True else if search_val " data(middle_item) top_item = middle_item else bottom_item = middle_item + # end end end if not found Then if search_val = data(bottom_item) #

7,

found = True middle_item = bottom_item end end binar'_serach = middle_item end

3.4.4.

Date Data Types

Some language "o not "irectly upport "ate "ata type % #hile other language "ata range. 4ate may be recor"e" internally a te&t tring % ho#e!er thi may make compari on bet#een "ata !alue "i$$icult. Alternati!ely% "ata !ariable may be implemente" a a numeric !ariable that recor" the number o$ "ay bet#een a ba e "ate an" the "ata !alue it el$. upport "ate "ata type but implement a re tricte"

7*

8hen a "ate !ariable i implemente" a a t#o byte igne" integer !alue% thi "ate !alue co!er a ma&imum "ata range o$ 7: year . 4epen"ing on the election o$ the ba e "ate% the earlie t an" late t "ate that can be recor"e" may be le current "ate. 4ate implemente" in thi #ay cannot be u e" to repre ent a "ate in a long erie o$ hi torical "ata% an" the e "ate range may be in u$$icient to recor" long/term calculation in ome application . The Fulian calen"ar i ba e" on the number o$ "ay that ha!e elap e" ince the 1 t o$ Fanuary% ,513 B). Fulian "ata !alue can be tore" in a $our/ byte integer !ariable. Integer !ariable are con!enient to u e an" operation #ith integer "ata type e&ecute than 30 year $rom the

72

'uickly. T#o "ate

tore" a Fulian !ariable

can be "irectly compare" to "etermine #hether one "ate i earlier than the other "ate. )on!er ion bet#een a <ulian !alue an" a y tem "ate u ing a t#o byte !alue can be "one by ub tracting a number e'ual to the number o$ "ay bet#een the y tem ba e "ate an" the <ulian ba e "ate. The $ollo#ing algorithm can be u e" to calculate a <ulian "ate.

,date = -./ * 'ear 0 int( / * ('ear + int((month + 1) * #+)) * 2) / int( - * (int(( 'ear + (month 0 1) * /) * #33) + #) * 2) + int( +/4 * month * 1) + da' + #/+#3+564

75

3.4.5.

Solvin( %7uations

In ome ca e % the !alue o$ a !ariable in an e'uation cannot be "etermine" by "irect calculation. 3or e&ample% in the e'uation -y ? & C &2.% the !alue o$ -&. cannot be calculate" "irectly $rom the e'uation. In the e ca e % an iterati!e approach can be u e". Thi in!ol!e u ing an initial gue o$ the

olution% an" then repeate"ly calculating the re ult an" "etermining a more accurate e timate o$ the olution #ith each iteration. The $ollo#ing metho" u e t#o e timate o$ the re ult% an" calculate a traight line bet#een the !alue to "etermine an impro!e" e timate o$ the olution.

77

Thi proce

continue % #ith the t#o mo t/

recent !alue being carrie" $or#ar" a ne# e timate are pro"uce". =i!en rea onable initial gue e % thi metho" may generate a olution #ith an accuracy o$ i& igni$icant $igure #ithin $i!e to ten iteration . Thi metho" "oe not u e the "eri!ati!e o$ the $unction or e timate the lope o$ the line $rom in"i!i"ual !alue . 8hen a cur!e "i play a <agge" hape% problem can ari e #ith metho" that u e the lope o$ the cur!e. Fagge" cur!e ha!e a mooth hape at large cale % but the "etail o$ mall ection o$ the cur!e may "i play harp mo!ement . Thi can occur in practical ituation #here the cur!e i "eri!e" $rom a large number o$ in"i!i"ual !alue that are relate" in a broa"

7:

#ay% but #here mall change in the pattern o$ !alue may re ult in mall ran"om mo!ement in the cur!e. The $ollo#ing co"e outline a ubroutine u ing thi metho".

7 ' = f(%) is the function being evaluated6 7 7 8nsure that %=3 or some other value for 7%9 does not 7 generate a divide b' :ero 7 7 '_result is the kno!n ;'< value 7 %_result is the value of ;%< that is calculated for ;'_result<

subroutine solve_f%( '_result as floating_point, %_result as floating_point) define attempts as integer define %#, %+, %-, '#, '+, '-, m, c as floating_point constant =)>_)TT8=?T& = #333 attempts = 3 7 use estimates that are reasonable and are likel'

:0

7 to be on either side of the correct result %# = # %+ = #3 '# = f(%#) '+ = f(%+)

repeat !hile ;'+< is further than 3633333# from ;'_target< !hile (absolute_value( '_target 0 '+ ) $ 3633333# )@A attempts " =)>_)TT8=?T&) 7 line bet!een %#,'# and %+,'+ Bf %+ %# "$ 3 then

m = ('+ 0 '#)*(%+ 0 %#) c = '# 0 m * %# else 7 unstable f(%), %#=%+ but '#"$'+ attempts = =)>_)TT8=?T& end 7 calculate a ne! estimate of 7%9 %- = ('_target 0 c) * m '- = f(%-) 7 roll over to the t!o latest points

:1

%# = %+ '# = '+ %+ = %'+ = 'attempts = attempts + # end if attempts $= =)>_)TT8=?T& then to find solution solve_f% = false %_result = 3 else solve_f% = true %_result = %+ end end 7 failed

:2

3.4.6.

Ran-o$isin( Data +te$s

In ome application % !alue are electe" $rom a collection o$ item in a ran"om or"er. Thi can be implemente" ea ily u ing an array an" a ran"om number generator #hen the item can be repeate"ly electe". 1o#e!er% #hen each item mu t be electe" once% but in a ran"om or"er% thi proce be "i$$icult to implement e$$iciently. Selecting item $rom an array an" then compacting the array to remo!e the blank pace #oul" in!ol!e an or"er o$ n2 operation to mo!e element #ithin the array. Item can be "elete" "irectly $rom a linke" li t% ho#e!er link li t item cannot be "irectly may

:3

acce e" an" o cannot be electe" at ran"om. The $ollo#ing metho" ran"omi e an input li t o$ "ata item u ing a metho" that in!ol!e an or"er o$ nDlog2(n) operation . ;ach item i $ir t in erte" into a binary tree. The path at each no"e i cho en at ran"om% #ith a *0O probability o$ taking the le$t or the right path. The ran"om choice o$ path en ure that the tree #ill remain appro&imately balance"% regar"le o$ the or"er o$ the input "ata. ;ach in ertion into the tree #oul" in!ol!e appro&imately log2(n) compari on . 8hen the tree ha been con tructe"% a can o$ the tree i per$orme" to generate the output li t. Thi can be "one #ith a recur i!e ubroutine that call it el$ $or the le$t ubtree% output

:,

the !alue in the current no"e% then call it el$ $or the right ub/tree.

3.4.!.

Subco$ponent an- C1ain

%&pansion

In ome application % tructure may contain ub/ tructure or connection that ha!e the ame $orm a the main tructure. 3or e&ample% an engineering "e ign may be ba e" on a tructure that contain tructure. An in!e tment port$olio may contain e!eral in!e tment % inclu"ing in!e tment that are part o$ other in!e tment port$olio . In the e ca e % the !alue relating to the main tructure can be "etermine" recur i!ely. ub/ tructure #ith the ame $orm a the main

:*

The in!ol!e calling a ubroutine to proce each o$ the ub/ tructure % #hich in turn may in!ol!e the ubroutine calling it el$ to proce ub/ tructure #ithin the ub tructure. Thi proce continue until the en" o$ the

chain i reache" an" no $urther ub/ tructure are pre ent. 8hen thi occur % the calculation can be per$orme" "irectly. Thi return a re ult to the pre!iou le!el% #hich calculate the re ult $or that le!el an" return to the pre!iou le!el an" o $orth% until the proce un#in" to the main le!el an" the re ult $or the main tructure can be calculate". In ome ca e a loop may occur. Thi coul" not happen in a tan"ar" phy ical tructure% but in other application an inner ub tructure may al o contain the entire outer tructure. In the in!e tment port$olio e&ample% port$olio A may contain an in!e tment in

:2

port$olio B% #hich in!e t in port$olio )% #hich in!e t back into port$olio A. In a tructural e&ample% the "ata #oul" ugge t that a bo& A #a in i"e another bo& B% an" that bo& B #a al o in i"e bo& A. Thi may be "ue to a "ata or proce error

recor"ing a ituation that i phy ically impo ible or "oe not repre ent a "e$inable tructure. A chain uch a thi cannot be "irectly re ol!e"% an" the "ata #oul" nee" to be interprete" in the conte&t o$ the tructure a it applie" to the particular application being mo"elle".

3.4.".

C1ec2su$ & CRC

:5

)heck um an" )E) calculation can be u e" to "etermine #hether a block o$ "ata ha change". Thi may be u e" in application uch a "ata

tran $er through "ata link % checking #hether a block o$ memory ha been altere" "uring a "ebugging proce % an" !eri$ication o$ "ata #ithin har"#are "e!ice . A check um may in!ol!e umming the in"i!i"ual binary !alue #ithin the block an" recor"ing the total. The ame calculation coul" then be per$orme" at a $uture time% an" a "i$$erent re ult #oul" in"icate that the "ata ha" been change". A check um i a imple calculation that may "etect ome change % but it "oe not "etect change uch a t#o !alue being e&change".

:7

A )E) ()yclic Ee"un"ancy )heck) calculation can "etect a #i"er range o$ change % inclu"ing !alue that ha!e been tran po e". A check um or )E) calculation cannot guarantee that the "ata i unchange"% a thi #oul" only be po ible #ith a ran"om "ata block by comparing the entire block #ith the original !alue . 1o#e!er% a , byte )E) !alue can repre ent o!er $our billion !alue % #hich implie that a ran"om change to the "ata #oul" only ha!e a one in $our billion chance o$ generating the ame )E) !alue a the original calculation. The e $igure #oul" only apply in the ca e o$ a ran"om error. In ca e #here "i$$erence uch a tran po ing !alue may occur% thi #oul" cau e problem #ith ome calculation tran po e". uch a check um that #oul" generate the ame re ult i$ the "ata #a

::

3.4.8.

C1ec2 Di(its

In the ca e o$ tructure" number $ormat uch a account number an" cre"it car" number % a""itional "igit can be a""e" to the number to "etect keying error an" partially !ali"ate the number. Thi can be "one by calculating a re ult $rom the number% an" toring the re ult a a""itional "igit #ithin the number. 3or e&ample% the "igit may be umme" an" the re ult inclu"e" a the $inal t#o "igit #ithin the number. A more comple& calculation #oul" normally be u e" that coul" "etect "igit that #ere tran po e"% a tran po ition i a common error an" i not "etecte" by a imple um o$ the !alue .

100

9eri$ying a number #oul" be "one by per$orming the calculation #ith the main "igit % an" comparing the calculate" re ult #ith the remaining "igit in the number.

3.4.19. +n i& to Post i& %&pression Conversion 3.4.19.1.+n i& %&pressions

Mathematical e'uation an" $ormula are generally pre ente" in an in$i& $ormat. Binary operator #ithin in$i& e&pre ion appear bet#een the t#o !alue that they operate on. In thi conte&t% the term binary "oe not re$er to binary number % but re$er to operator that take t#o argument % uch a a""ition. Arithmetic e&pre ion u e arithmetic prece"ence% o that ome operation % uch a 101

multiplication% are per$orme" be$ore other operator uch a a""ition.

The tan"ar" le!el o$ arithmetic prece"ence areB 1. Bracket 2. ;&ponentiation 3. Inary minu uch a /3 or /(2D,) ,. Multiplication% 4i!i ion *. A""ition% Subtraction Bracket may be u e" to group operation an" change the or"er o$ operation . 4ue to the i ue o$ operator prece"ence% an" the u e o$ bracket % an in$i& e&pre ion cannot be "irectly e!aluate" by per$orming the operation in a "irect or"er% uch a $rom le$t to right in the e&pre ion. In$i& e&pre ion mu t be par e" be$ore they can be e!aluate". Thi can be "one by u ing &y. 0egati!e !alue

102

a par er uch a a recur i!e "e cent metho"% an" e!aluating the e&pre ion a it i par e" or generating interme"iate co"e.

3.4.19.2.Post i& %&pressions

A po t$i& e&pre ion i an alternati!e $ormat $or e&pre ing an e&pre ion% that place the operator a$ter the !alue that they operate on. I ing thi $ormat% bracket are not re'uire"% an" operator prece"ence "oe not nee" to be applie" to the e&pre ion a the prece"ence i implie" in the or"er o$ the ymbol . 3or e&ample% the in$i& e&pre ion -2 C 3 D *. #oul" be con!erte" to a po t$i& e&pre ion o$ -3 * D 2 C. +o t$i& e&pre ion can be e!aluate" "irectly $rom le$t to right.

103

Thi can be "one u ing a tack% #here a !alue in the e&pre ion i pu he" on to the tack% an" an operator pop the argument $rom the tack% calculate the re ult% an" pu he the re ult on to the tack. 8hen a !ali" e&pre ion i e!aluate"% a ingle re ult houl" remain on the tack a$ter the e&pre ion e!aluation i complete% an" thi houl" e'ual the re ult o$ the e&pre ion.

;&pre ion may be tore" internally in a po t$i& $ormat% o that they can be "irectly e!aluate". )o"e generation e$$ecti!ely generate co"e to e!aluate e&pre ion in a po t$i& or"er.

3.4.19.3.+n i& to Post i& conversion

10,

)on!er ion $rom an in$i& $ormat to a po t$i& $ormat can be "one u ing a binary tree. 4uring the par e% a tree i built o$ the e&pre ion containing a no"e $or each operator an" !alue. A binary operator no"e #oul" ha!e t#o ubtree % #ith one argument appearing in the le$t ub tree an" one argument appearing in the right ub tree. The e ub tree may them el!e be complete e&pre ion . The par e tree can be built "uring the par e% #ith a no"e create" at each le!el an" returne" to the ne&t highe t le!el to be connecte" a a ubtree. Thi re ult in the tree being built u ing a bottom/up approach. =enerating the po t$i& e&pre ion can be "one by u ing a recur i!e ubroutine to can the tree. Thi proce ubroutine #oul" call it el$ to the le$t ub tree% then call it el$ to

10*

proce

the right ub tree% then output the

!alue in the current no"e. The output coul" be implemente" a a erie o$ in truction tore" in a table.

3.4.19.4.%valuation

The e&pre ion can be e!aluate" by rea"ing each in truction in e'uence. I$ the in truction i a pu h in truction% then the "ata !alue i pu he" on to the tack. I$ the in truction i an operator% then the operator pop the argument $rom the tack% calculate" the re ult% an" pu he the re ult on to the tack.

3or e&ample% the $ollo#ing in$i& e&pre ion may be the input tring
% = + * / + ((2 * 4) 0 -)

102

+ar ing thi e&pre ion an" buil"ing a bottom/up par e tree #oul" pro"uce a tructure imilar to the $ollo#ing "iagram.

/ D , * 3 2

D 5

=enerating the po t$i& e&pre ion by canning the par e tree lea" to the $ollo#ing e&pre ion.

% = 2 4 * - 0 + / * +

105

Thi e&pre ion coul" be "irectly tran late" into in truction % a in the $ollo#ing li t pu h , pu h * multiply pu h 3 ubtract pu h 2 pu h 5 multiply a""

;&ecuting the e&pre ion #oul" lea" to the $ollo#ing e'uence o$ tep . In thi e&ample the tack content are ho#n #ith the item on the top o$ the tack ho#n at the le$t i"e o$ the column.

Cperation push 2

&tack contents

2 push 4

107

4 2 multipl' +3 push - +3 subtract #/ push + + push / / + multipl' #2 add #/ #/ #/

Thi proce

en" #ith the tack containing

the re ult /3% #hich i the correct re ult o$ the original e&pre ion.

3.4.11. Re(ular %&pressions

A regular e&pre ion i a te&t pattern/ matching metho". Eegular e&pre ion $orm a imple language an" can be tran late" into a $inite tate automaton. Thi allo# the pattern #ithin 10:

the input te&t to be i"enti$ie" in a ingle pa % regar"le pattern . The operator #ithin a regular e&pre ion are li te" belo#. o$ the comple&ity o$ the te&t

a phra e i PabcQ PRabcQ aD aC aG phra e) . (a) a/A other range) aSb electe")

The letter A (or #hiche!er letter or Any one o$ the letter a% b or c (or other Any letter not being a% b or c (or other The letter -a. repeate" Aero or more The letter -a. repeate" one or more The letter -a. occurring optionally (or Any character The phra e or ub/pattern -a. Any letter in the range -a. to A. (or The pha e -a. or -b. (or other phra e)

letter #ithin bracket ) letter #ithin bracket ) time (or other phra e) time (or other phra e)

3or e&ample% the pattern peci$ying a !ariable name #ithin a programming 110

language may be "e$ine" u ing the $ollo#ing regular e&pre ion Pa/AA/TUQPa/AA/T0/:UQD Thi #oul" be interprete" a an initial character being a letter in the range a/A or A/ T% or an un"er core character% $ollo#e" by a character in the range a/A% A/T% 0/: or an un"er core% repeate" Aero or more time . Thi pattern #oul" match te&t item pattern uch a -3"c. or -aO .. uch a

-&.% -Uaa.% -"3.% but #oul" not match

Eegular e&pre ion can al o be u e" in te&t earching. 3or e&ample% the $ollo#ing e&pre ion #oul" match the #or" -te&t canning. or - canning te&t.% eparate" by an character repeate" Aero or more time . (te&t.D canning)S( canning.Dte&t)

111

A another e&ample% a earch $or the #or" - ub. in program co"e may e&clu"e #or" uch a - ubtract. an" - ub<ect. by u ing a pattern uch a - ubPRa/AQ.. Thi #oul" match any te&t that containe" the letter - ub. an" #a $ollo#e" by a character that #a not another letter.

3.4.12. Data Co$pression

4ata compre ion i u e" to re"uce torage pace% an" to increa e the rate o$ "ata tran $er through communication channel . A #i"e range o$ "ata compre ion techni'ue an" algorithm are u e"% ranging $rom the tri!ial to the highly comple&. 4ata compre ion approache inclu"e i"enti$ying common pattern #ithin "ata% an" replacing common pattern #ith a maller "ata item .

112

In compre ing te&t% run length enco"ing in!ol!e replacing a tring o$ i"entical character % uch a pace % #ith a ingle character an" a number peci$ying the number o$ occurrence . 8ithin a te&t "ocument% entire #or" coul" be replace" #ith number co"e . 1u$$man enco"ing in!ol!e replacing $i&e" character iAe #ith !ariable bit co"e . In tan"ar" te&t% character may be repre ente" a eight/bit !alue . In a ection o$ te&t% ho#e!er% ome character may occur more o$ten than other . In thi ca e% $re'uent character coul" be replace" #ith * or 2 bit co"e % #ith le $re'uent character replace" #ith 10 an" 11 bit co"e .

113

)ompre ion techni'ue u e" #ith ample" "ata uch a graphic image an" oun" $all into t#o categorie . 6o le techni'ue pre er!e the original

"ata #hen they are "ecompre e". Thi coul" in!ol!e replacing a repeating ection o$ the "ata% uch a an area containing a ingle colour% #ith a ingle !alue an" co"e repre enting the location o$ the area. 8ithin "ata uch a !i"eo e'uence % multiple i"entical $rame coul" be replace" #ith a ingle $rame an" a count o$ the number o$ occurrence % an" $rame that "i$$er lightly coul" be replace" #ith a ingle $rame an" in$ormation i"enti$ying the "i$$erence to the ne&t $rame. )ompaction techni'ue coul" in!ol!e toring "ata uch a i& bit !alue acro byte boun"arie % rather than toring each i& bit !alue #ithin a tan"ar" eight bit byte an" lea!ing t#o bit unu e".

11,

6o y techni'ue o$$er a higher compre ion ratio% but #ith a lo in "etail o$ the "ata. 4ata compre e" u ing a lo y metho" permanently lo e "etail an" cannot be re tore" to the original "ata. 6o y metho" inclu"e re"ucing the number o$ bit u e" to recor" each "ata item% replacing a"<acent imilar area #ith a ingle !alue% an" $iltering "ata to remo!e component uch a barely !i ible or barely au"ible in$ormation. 3ractal techni'ue may in!ol!e !ery high compre ion ratio . A $ractal i an e'uation that can be u e" to generate repeating tructure % uch a clou" an" $ern lea!e . 3ractal compre ion in!ol!e $iltering "ata an" "e$ining an alternati!e et o$ "ata that can be u e" to generate a imilar image or in$ormation to the original "ata.

11*

112

3.$. Techni%ues

3.5.1.

)inite State 'uto$aton

A $inite tate automaton i a mo"el o$ a imple machine. The machine #ork by recei!ing input character % an" changing to a ne# tate ba e" on the current tate an" the input character recei!e". Thi i a imple but !ery po#er$ul techni'ue that can be u e" in a #i"e range o$ application . 3inite tate machine are able to "etect comple& pattern #ithin input "ata. 4ue to their imple operation% a $inite tate machine e&ecute e&tremely 'uickly. The 3SA con i t o$ a loop o$ co"e% an" a tate tran ition table that peci$ie the ne&t

115

tate to change to% ba e" on the current tate an" the ne&t input character. A comple& mo"el increa e the iAe o$ the "ata table% ho#e!er the co"e remain unchange" an" the e&ecution re'uire only a ingle array re$erence to proce character. +ar ing program co"e can be per$orme" by "e$ining a grammar o$ the language tructure% an" u ing an algorithm to con!ert the grammar "e$inition into a $inite tate automaton. Te&t pattern can be peci$ie" u ing regular e&pre ion % #hich can al o be tran late" into an 3SA. An e&ample o$ a $inite tate automaton i the $ollo#ing "e cription o$ a tate tran ition table that i"enti$ie a certain pattern #ithin te&t. each input

117

Thi i a pattern that "e$ine program comment that begin #ith the e'uence -ND. an" en" #ith the e'uence -DN..

11:

State comment 1

0e&t )haracter

0e&t State

8ithin a

not -N.. -N.

1 2 1 2 3 3 , 3 , 1

0o

not -D. or -N. -N. -D.

0o

not -D. -D.

Me

not -D. or -N. -D. -N.

Me

N N 2 0ot D or N 1 0ot D 0ot N or N N , D 120 D 3 0ot D

The y tem begin in tate 1% an" each character i rea" in turn. The ne&t tate i "etermine" $rom the current tate an" the input character. 3or e&ample% i$ the y tem #a in tate 2 at a certain point in the proce ing% an" the ne&t character #a a -N.% then the y tem #oul" remain in tate 2. I$ the character #a a -D.% the y tem #oul" change to tate 3% an" $or any other character the y tem change to tate 1. The current tate coul" be tore" a the !alue o$ an integer !ariable. The proce #oul" continue% changing tate

each time a ne# character #a rea" until the en" o$ the input #a reache".

121

4uring proce ing% any time that the current tate #a tate 3 or tate ,% thi #oul" in"icate that the proce ing #a #ithin a comment% other#i e the proce ing #oul" be out i"e a comment. Thi proce coul" be u e" to e&tract

comment $rom the co"e. 0o backtracking i re'uire" to han"le e'uence uch a -NDNDDN. that may appear #ithin the te&t

3.5.2.

S$all #an(ua(es

In ome application a language may be "e!elope" peci$ically $or a ingle application. Thi may in!ol!e "e!eloping a macro language $or peci$ying $ormula an" con"ition % #here the language co"e coul" be

122

tore" in a "ataba e te&t $iel" or u e" #ithin an application. Another e&ample may in!ol!e a language $or "e$ining the chemical tructure o$ molecule an" compoun" . Thi #oul" be a "eclarati!e language an" #oul" not in!ol!e generating co"e an" e&ecution% ho#e!er it #oul" in!ol!e le&ical analy i an" par ing to e&tract the in"i!i"ual item an" tructure #ithin the "e$inition. A language can be "e$ine" #ith tatement % "ata ob<ect an" operator that are peci$ic to the ta k being per$orme". 3or e&ample% #ithin a "ataba e management y tem a ta k language coul" be "e$ine" #ith "ata type repre enting a recor"% in"e& no"e% cache table entry etc% an" operator to mo!e recor" bet#een bu$$er % "ata page an" "i k torage. Eoutine coul" then be #ritten in the ta k language to implement proce"ure uch a

123

up"ating a recor"% creating a ne# in"e& an" o $orth. The broa" tep in!ol!e" in implementing a mall language areB 6e&ical analy i +ar ing )o"e =eneration ;&ecution

3.5.2.1. #e&ical 'nalysis

6e&ical analy i i the proce

o$ i"enti$ying

the in"i!i"ual element #ithin the input te&t% uch a number % !ariable name % comment % an" operator Thi proce uch a -C. an" ->?.. can be "one u ing proce"ural

co"e. Alternati!ely% the pattern can be "e$ine" a regular e&pre ion te&t pattern % an" an algorithm u e" to con!ert the regular

12,

e&pre ion into a $inite tate automaton that can be u e" to can the input te&t. The le&ical analy i pha e may pro"uce a erie o$ token % #hich are numeric co"e i"enti$ying the element in the input tream. The e'uence o$ token can be tore" in a table #ith the numeric co"e $or the token% an" any a ociate" "ata !alue uch a the actual !ariable name or number con tant.

3.5.2.2. Parsin(

+ar ing or ynta& analy i i the proce te&t. The language can be "e$ine" u ing a

o$

i"enti$ying the tructure #ithin the input

grammar "e$inition #hich #oul" peci$y the tructure o$ the language.

12*

@ne approach i to u e an algorithm to con!ert the grammar to a $inite tate automaton $or par ing% ho#e!er thi may be a comple& proce . Another alternati!e i to u e a recur i!e "e cent par er% #hich i a $a t an" imple par ing techni'ue that i relati!ely ea y to implement.

3.5.2.3. Direct %&ecution

8hen the language con i t o$ e&pre ion only% an" "oe not in!ol!e eparate tatement % the !alue o$ the e&pre ion can be calculate" a it i being par e". Thi #oul" in!ol!e calculating a re ult at each point in the recur i!e "e cent par er an" pa ing the re ult back up to the pre!iou le!el o$ the e&pre ion.

122

An a"!antage o$ thi metho" i that it i imple to implement% an" no $urther tage #oul" be re'uire" in the proce ing. 1o#e!er% thi metho" #oul" in!ol!e par ing the e&pre ion e!ery time it #a e!aluate". I$ a ingle $ormula #a applie" to many "ata item then thi approach #oul" be lo#er than continuing the proce generation tage. Al o% thi metho" may not be practical #hen the language inclu"e con"ition an" loop . tatement uch a to a co"e

3.5.2.4. Co-e ,eneration

)o"e generation may in!ol!e generating interme"iate co"e that i e&ecute" by a run/ time proce ing loop.

125

The interme"iate co"e coul" con i t o$ a table o$ in truction % #ith each entry containing an in truction co"e an" po ibly other "ata% uch a a !ariable name or !ariable re$erence. In truction #oul" be e&ecute" in e'uence% an" branch in truction coul" be a""e" to <ump to "i$$erent point #ithin the co"e ba e" on the re ult o$ e&ecuting e&pre ion #ithin -i$. tatement an" loop con"ition . A each tructure #ithin the co"e i par e"% interme"iate co"e in truction coul" be generate". Thi coul" in!ol!e a""ing a""itional entrie to the table o$ interme"iate co"e. I ing a tack to e&ecute e&pre ion % the ba ic operation o$ a imple thir"/generation language coul" be implemente" u ing the $ollo#ing in truction .

127

9ariable name re$erence +IS1 !ariable name on to the tack) (pu he a ne# !alue

A ignment operator +@+ !ariable name $rom the tack an" tore it in the !ariable) (remo!e a !alue

@perator (e.g. multiplication) MI6T top t#o tack !alue an" replace #ith the re ult) (e.g. multiply the

-i$. tatement Allocate label po ition V =enerate co"e $or the -i$. con"ition =enerate a T;ST <ump in truction to <ump to label V i$ tack re ult i $al e =enerate the co"e $or the tatement block #ithin the -i$. tatement

12:

4e$ine the po ition o$ label V a thi point in the co"e

6oop Allocate label po ition V Allocate label po ition M 4e$ine thi po ition in the co"e a the po ition o$ label M =enerate co"e $or the loop e&pre ion con"ition =enerate a T;ST <ump in truction to <ump to label V i$ tack re ult i $al e =enerate the co"e $or the loop tatement =enerate a <ump in truction to label M 4e$ine label V a thi po ition in the co"e

8hen the co"e ha been generate"% a econ" pa can be "one through the co"e to replace the label name #ith the po ition in the co"e that they re$er to. In thi co"e the MI6T operator i u e" a an e&ample an" imilar co"e coul" be generate" $or each arithmetic operation% $or compari on operator operator uch a ->.% an" $or Boolean uch a -A04..

130

0o proce ing i re'uire" $or bracket % a thi i automatically han"le" by the par ing tage. The par ing operation en ure that the co"e i generate" in the correct e'uence to be e&ecute" "irectly u ing a tack.

3.5.2.5. Run5Ti$e %&ecution

8hen the interme"iate co"e ha been generate"% it can be e&ecute" u ing a run time e&ecution routine. Thi routine #oul" rea" each in truction in turn an" per$orm the operation. The operation coul" inclu"e retrie!ing a !ariable( !alue an" pu hing it on to the tack% popping a re ult $rom the tack an" toring it in a !ariable% per$orming an operation% uch a MI6T or 6;SST1A0% an" placing the re ult on the tack% an"

131

changing the po ition o$ the ne&t in truction ba e" on a <ump in truction. In the ca e #here all !alue #ere numeric% inclu"ing in truction % <ump location an" !ariable location re$erence % e&ecution pee" coul" be 'uite high.

3.5.3.

Recursion

Eecur ion i a imple but po#er$ul techni'ue that in!ol!e a ubroutine calling it el$. Thi ubroutine call "oe not era e the ubroutine call% but $orm a chain o$

pre!iou

call that return to the pre!iou le!el a each call terminate . Eecur ion i u e" $or proce ing recur i!ely "e$ine" "ata tructure recur i!e component . uch a tree . Many algorithm are al o recur i!e or inclu"e

132

3or e&ample% the 'uick ort algorithm ort li t by electing a central pi!ot element% an" then mo!ing all item that are le that the pi!ot element to the tart o$ the li t% an" the item that are larger than the pi!ot element to the en" o$ the li t. Thi operation i then per$orme" on each o$ the t#o ubli t . 8ithin each ubli t% t#o other ubli t #ill be create" an" o the proce orte". Thi algorithm can be implemente" u ing a recur i!e ubroutine that per$orm a ingle le!el o$ the proce % an" then call it el$ to operate on each o$ the ub part . The recur i!e "e cent par ing metho" i a recur i!e metho" #here a ubroutine i calle" $or each rule #ithin the language grammar% an" ubroutine may in"irectly call them el!e in ca e uch a bracket % #here continue until the entire li t i

133

an e&pre ion may e&i t #ithin another e&pre ion. A can o$ a binary tree #oul" generally be "one u ing a recur i!e routine that proce e a ingle no"e an" then call it el$ to proce each o$ the ub tree . Eecur i!e co"e can be igni$icantly impler than alternati!e implementation that u e loop . In ome language a ubroutine call era e the pre!iou !alue o$ the ubroutine( !ariable an" recur ion i not "irectly upporte". In the e ca e % a loop can be u e" #ith a tack "ata tructure implemente" a an array. In thi ca e a ne# !alue i pu he" on to the tack #hen a ubroutine call #oul" occur% an" poppe" $rom the tack #hen a ubroutine call #oul" terminate.

13,

3.5.4.

#an(ua(e ,ra$$ars

Some programming language u e a ynta& that i ba e" on a combination o$ peci$ic te&t layout "etail % an" $ormal tructure $or e&pre ion . In other ca e % the language tructure can be completely peci$ie" by u ing a $ormal tructure uch a a B03 (Backu 0aur 3orm) grammar. Thi i a impler an" more $le&ible approach than u ing a layout "e$inition% both $or par ing an" $or u ing the language it el$. The u e o$ a B03 grammar ha the a"!antage that a par er can be pro"uce" "irectly $rom the grammar "e$inition u ing e!eral "i$$erent metho" .

13*

3or e&ample% a recur i!e "e cent par er can be con tructe" by #riting a ubroutine $or each le!el in the grammar "e$inition. A B03 grammar con i t o$ terminal an" non/terminal item . Terminal repre ent in"i!i"ual input token uch a a !ariable name% operator or con tant. 0on/terminal peci$y the $ormat o$ a

tructure #ithin the language% uch a a multiplication e&pre ion or an -i$. tatement. 0on/terminal may be "e$ine" #ith e!eral alternati!e $ormat . ;ach $ormat can contain a combination o$ terminal an" non/terminal item . The "e$inition $or each rule peci$y the tructure that are po ible #ithin the grammar% an" may re ult in the prece"ence o$ "i$$erent operator uch a multiplication

132

an" a""ition being re ol!e" though the u e o$ "i$$erent non/terminal rule . The e&ample belo# ho# a B03 grammar $or a imple language that inclu"e e&pre ion an" ome tatement .

statementlistD "statementlist$ statementD

"statement$ "statement$

B( "e%pression$ TE8@ FEBG8 "e%pression$

"statementlist$ 8@A "statementlist$ 8@A variable_name = "e%pression$ e%pressionD "e%pression$ "adde%pression$ CR "e%pression$ adde%pressionD "adde%pression$ "multe%pression$ "adde%pression$ "multe%pression$ + "adde%pression$ )@A

135

multe%pressionD "unar'e%pression$ * " multe%pression $ "unar'e%pression $ * " multe%pression $ unar'e%pressionD constant variable_name "e%pression$ ( "e%pression$ )

3.5.5.

Recursive -escent parsin(

Eecur i!e "e cent par ing i a par ing metho" that i imple to implement an" e&ecute 'uickly. Thi metho" i a top/"o#n par ing techni'ue that begin #ith the top/le!el tructure o$ the language% an" progre i!ely e&amine maller element #ithin the language tructure.

137

Bottom/up par ing metho" #ork by "etecting mall element #ithin the input te&t an" progre i!ely buil"ing the e up in to larger tructure o$ the grammar. Bottom/up techni'ue may be able to proce more comple& grammar than top/"o#n metho" but may al o be more "i$$icult to implement. Some programming language can be par e" u ing a top/"o#n metho"% #hile other u e more comple& grammar an" re'uire a bottom/up approach Eecur i!e "e cent par ing in!ol!e a ubroutine $or each le!el in the language grammar. The ubroutine u e the ne&t input token to "etermine #hich o$ the alternati!e rule applie % an" then call other ubroutine to proce the component o$ the tructure.

13:

3or e&ample% the non/terminal ymbol - tatement. may be "e$ine" in a grammar u ing the $ollo#ing ruleB
statementD B( "e%pression$ TE8@ FEBG8 "e%pression$ "statementlist$ 8@A variable_name = "e%pression$

"statementlist$ 8@A

The ubroutine that proce e a tatement #oul" check the ne&t token% #hich may be an -I3.% a -81I6;.% a !ariable name% or another token #hich may re ult in a ynta& error being generate". A$ter "etecting the appropriate rule% the ubroutine $or -e&pre ion. an" - tatementli t. #oul" be calle". )o"e coul" then be generate" to per$orm the <ump in the co"e ba e" on the con"ition in the -i$. tatement or loop% or in the ca e o$ the a ignment operator% co"e coul" be generate"

1,0

to copy the re ult o$ the e&pre ion into the !ariable. =rammar can ometime be a"<u te" to make them uitable $or top/"o#n par ing by altering the or"er #ithin rule #ithout a$$ecting the language it el$. 3or e&ample% changing the rule $or an -a""e&pre ion. in the $ollo#ing #ay coul" be u e" to make the rule uitable $or top/ "o#n par ing #ithout altering the language.

Initial ruleB
adde%pressionD "multe%pression$ "adde%pression$ +

A"<u te" rule


adde%pressionD "adde%pression$ "multe%pression$ +

1,1

In the a"<u te" rule the ne&t le!el o$ the grammar% -multe&pre ion.% can be calle" "irectly. 8hen a language i being create"% a"<u tment can be ma"e to the grammar to make it uitable $or par ing u ing thi metho". Thi may inclu"e in erting ymbol in po ition to eparate element o$ the language. 3or e&ample% the $ollo#ing rule may not be able to be par e" a the par er may not be able to "etermine #here an -e&pre ion. en" an" a - tatementli t. begin .
statementD B( "e%pression$

"statementlist$ 8@A

Thi language coul" be altere" by in erting a ne# key#or" to eparate the element in the $ollo#ing #ayB

1,2

statementD

B( "e%pression$ TE8@

"statementlist$ 8@A

A recur i!e "e cent par e may in!ol!e generating interme"iate co"e% or e!aluating the e&pre ion a it i being par e". 8hen the e&pre ion i "irectly e!aluate"% the calculation can be per$orme" #ithin each ubroutine% an" the re ult pa e" back to the pre!iou le!el $or $urther calculation. The tructure o$ the ubroutine call automatically han"le i ue uch a arithmetic prece"ence% #here multiplication are per$orme" be$ore a""ition .

3.5.6.

4it$aps

Bitmap in!ol!e the u e o$ in"i!i"ual bit #ithin a numeric !ariable. 1,3

Thi may be u e" #hen "ata i proce e" a pattern o$ bit % rather than number . Thi occur #ith application uch a the proce ing o$ graphic "ata% encryption% "ata compre ion an" har"#are inter$acing. Typically "ata i compo e" o$ byte % #hich each contain eight in"i!i"ual bit . Integer !ariable may con i t o$ 1% 2% or , byte o$ "ata. In ome language a continuou block o$ memory can acce e" u ing a metho" uch a an array o$ integer % #hile in other language the !ariable in the array are not guarantee" to be contiguou in memory an" there may be pace bet#een the in"i!i"ual "ata item . Bitmap can al o be u e" to tore "ata compactly. 3or e&ample% a Boolean !ariable may be implemente" a an integer !alue% but in $act only a ingle bit i re'uire" to repre ent a Boolean !alue.

1,,

Storing e!eral Boolean $lag u ing "i$$erent bit #ithin a !ariable allo# 12 in"epen"ent Boolean !alue to be recor"e" #ithin a 2/ byte integer !ariable. Storing $lag #ithin bit allo# tructure a a ingle !ariable. Bit manipulation i "one u ing the bit#i e operator A04% @E an" 0@T. The bit#i e operator ha!e the $ollo#ing re ult
A04 re ult i 0 @E 0@T V@E 1 i$ either one bit or both bit are et to 1 i$ the bit i 0 an" 0 i$ the bit i 1 1 i$ one bit i 1 an" the other bit i 0% 1% other#i e the re ult i 0 1 i$ both bit are et to 1% other#i e the

e!eral $lag

to be pa e" into ubroutine an" "ata

other#i e the re ult i 0

1,*

The operation per$orme" on a bit are te ting to check #hether the bit i et% etting the bit to 1% an" clearing the bit to 0. A bit can be checke" u ing an A04 operation #ith a te t !alue that contain a ingle bit et% #hich i the bit being te te". 3or e&ample
9alue Te t 9alue 9alue A04 Te t 9alue 01011011 00001000 00001000

I$ the re ult i non/Aero then the bit being checke" i et.

)on tant may be #ritten u ing he&a"ecimal number or "ecimal number . In the ca e o$ "ecimal !alue % the !alue #oul" be t#o rai e" to the po#er o$ the po ition o$ the bit% #ith po ition commencing at Aero in the rightmo t place an" increa ing to the le$t o$ the number. 1,2

In the ca e o$ he&a"ecimal number % each group o$ $our bit corre pon" to a ingle he&a"ecimal "igit. The $ollo#ing number #oul" be e'ui!alent
Binary 1e&a"ecimal 01011011 *B

A bit can be et u ing the @E operator #ith a te t !alue than contain a ingle bit et. 3or e&ample
9alue Te t 9alue 9alue @E Te t 9alue 01011011 00000100 01011111

A bit can be cleare" by u ing a combination o$ the 0@T an" A04 operator #ith the te t !alue

1,5

3or e&ample

9alue Te t 9alue 0@T Te t 9alue 9alue A04 0@T Te t 9alue

01011111 00000100 11111%11 01011%11

3.5.!.

,enetic 'l(orit1$s

=enetic algorithm are u e" $or optimi ation problem that in!ol!e a large number o$ po ible olution % an" #here it i not practical to e&amine each olution in"epen"ently to "etermine the optimum re ult. 3or e&ample% a y tem may control the che"uling o$ tra$$ic ignal . In thi e&ample% each ignal may ha!e a !ariable "uty cycle% being either re" or green $or a $i&e" proportion o$ time% ranging $rom 10O to :0O

1,7

o$ the time. Thi repre ent nine po ible !alue $or the "uty cycle. @ne approach #oul" be to et all tra$$ic ignal to a *0O "uty cycle% ho#e!er thi may impe"e natural tra$$ic $lo#. In a city/#i"e tra$$ic net#ork #ith 1000 tra$$ic ignal % there #oul" be :1000 po ible combination o$ tra$$ic ignal e'uence . Thi i an e&ample o$ an optimi ation problem in!ol!ing a large number o$ in"epen"ent !ariable . A genetic algorithm approach in!ol!e generating e!eral ran"om olution % an" creating ne# olution by combining e&i ting olution . In thi e&ample% a ran"om et o$ ignal e'uence coul" be create"% an" then a imulation coul" be u e" to "etermine the

1,:

appro&imate tra$$ic $lo# rate ba e" on the ignal e'uence an" typical roa" u age. A$ter the ran"om olution are checke"% a ne# et o$ olution i generate" $rom the e&i ting olution . Thi may in!ol!e "i car"ing the olution #ith the lo#e t re ult % an" combining the remaining olution to generate ne# olution . 3or e&ample% t#o remaining olution coul" be combine" by electing a ignal e'uence $or each tra$$ic ignal at ran"om $rom one o$ the t#o e&i ting olution . Thi #oul" re ult in a ne# olution #hich #a a combination o$ the t#o e&i ting olution . 0e# ran"om olution coul" then be generate" to re tore the total number o$ olution to the pre!iou le!el.

1*0

Thi cycle #oul" be repeate"% an" the proce i continue" until a olution that meet a thre hol" re ult i $oun"% or olution may be "etermine" #ithin the proce ing time a!ailable. In ome ca e a genetic algorithm approach can locate a uperior olution in a horter perio" o$ time than alternati!e techni'ue that u e a ingle olution that i continually re$ine".

1*1

3.&. Code !odels


)o"e can be tructure" in !ariou #ay . In ome ca e % "i$$erent co"e mo"el can be combine" #ithin a ingle ection o$ co"e. In other ca e % changing the co"e mo"el in!ol!e a $un"amental change #hich turn the co"e in i"e/out% an" in!ol!e completely re#riting the co"e to per$orm the ame $unction a the original program. )hanging co"e mo"el can ha!e a "ra tic e$$ect on the !olume o$ co"e% e&ecution pee" an" co"e comple&ity.

3.6.1.

Process Driven Co-e

+roce

"ri!en co"e in!ol!e u ing

proce"ural tep to per$orm peci$ic proce ing.

1*2

Thi approach lea" to clear co"e that i ea y to rea" an" maintain. +roce ea y to "ebug. 1o#e!er% large !olume o$ co"e may be pro"uce". Al o% y tem #ritten in thi #ay may be in$le&ible% an" large ection o$ co"e may nee" to be re#ritten #hen a $un"amental change i ma"e to a "ataba e tructure or a proce . "ri!en co"e can be "e!elope" 'uickly an" i relati!ely

3.6.2.

)unction Driven Co-e

3unction "ri!en co"e in!ol!e "e!eloping a et o$ mo"ule that per$orm general $unction #ith et o$ "ata.

1*3

The application it el$ i #ritten u ing co"e that call the general $acilitie to per$orm the actual proce e an" calculation . 3unction "ri!en co"e may in!ol!e maller co"e !olume than proce "ri!en co"e% ho#e!er the co"e may be more comple&. 3unction "ri!en co"e may $ollo# a "e$initional pattern. 3or e&ample% a proce "ri!en approach to

printing a report may in!ol!e calling ubroutine to rea" the "ata% calculate $igure % ort the re ult % $ormat the output an" print the report. ;ach ubroutine #oul" per$orm a ingle tep in the proce . In a $unction "ri!en approach% ubroutine may be calle" to "e$ine the "ata et% "e$ine the calculation % peci$y the ort or"er% elect

1*,

a $ormatting metho"% an" $inally generate an" print the report. The report generation an" printing #oul" be "one u ing a general routine% ba e" on the "e$inition that ha" been pre!iou ly electe".

3.6.3.

Table Driven Co-e

Table "ri!en co"e can be u e" in proce e that in!ol!e repeate" call to the ame ubroutine or proce . Table "ri!en co"e in!ol!e creating a table o$ con tant % an" #riting a loop o$ co"e that rea" the table an" per$orm a $unction $or each entry in the table. 3or e&ample% the te&t item on a menu or creen "i play coul" be tore" in a table.

1**

A loop o$ co"e #oul" then rea" the table an" call the menu or creen "i play $unction $or each entry in the table. Thi approach i al o u e" in circum tance uch a e!aluating e&ternally/"e$ine" $ormula % #here the $ormula may be par e" an" interme"iate co"e may be tore" in an array. ;ach in truction in the array #oul" then be e&ecute" in e'uence u ing a loop o$ co"e. Table "ri!en co"e can lea" to a large "rop in co"e !olume an" an increa e in con i tency in circum tance #here it i applicable. Table entrie can be tore" in program !ariable a array o$ tructure type % or in "ataba e table . Table "ri!en co"e i a large/"ata% mall co"e mo"el% rather tan"ar" proce"ural co"e #hich i a large co"e% mall "ata mo"el.

1*2

Small co"e mo"el % uch a u ing table "ri!en co"e or run/time routine to e&ecute e&pre ion % are generally impler to #rite an" "ebug an" more con i tent in output than mall "ata mo"el .

3.6.4.

/b3ect /rientate- Co-e

@b<ect orientate" co"e i a "ata/centre" mo"el rather than a $unction/centre" mo"el @b<ect are "e$ine" that contain both "ata an" ubroutine % kno#n a metho" . Metho" are attache" to a "ata !ariable% an" a metho" can be e&ecute" by re$erring to the "ata !ariable an" the metho" name. Thi i a $un"amentally "i$$erent approach to $unction/centre" co"e% #hich in!ol!e "e$ining ubroutine eparately to the "ata item that they may proce .

1*5

@b<ect orientate" co"e can be u e" to implement $le&ible $unction/"ri!en co"e% an" i particularly u e$ul $or ituation that in!ol!e ob<ect #ithin other ob<ect . 1o#e!er% ob<ect orientate" co"e can become e&tremely comple& an" can be "i$$icult to "ebug an" maintain. 3or e&ample% many ob<ect orientate" y tem upport a hierarchical y tem kno#n a inheritance% #here ob<ect can be ba e" on other ob<ect. The ob<ect inherit the "ata an" metho" o$ the original ob<ect% a #ell a any "ata an" metho" that are implemente" "irectly. In an ob<ect mo"el containing many le!el % "ata an" metho" may be implemente" at each le!el an" interpreting the tructure o$ the co"e may be "i$$icult.

1*7

Al o% an ob<ect mo"el ba e" on the application ob<ect % rather than an in"epen"ent et o$ concept % can be comple& an" re'uire e&ten i!e change #hen ma<or change are ma"e to the tructure o$ the application ob<ect . Thi i ue al o applie to "ataba e tructure ba e" on peci$ic "etail general concept . uch a peci$ic pro"uct or peci$ic account % rather than

3.6.5.

De$an- Driven Co-e

4eman" "ri!en co"e take the re!er e approach to control $lo# compare" to tan"ar" proce /"ri!en co"e. Stan"ar" proce "ri!en co"e operate u ing i

a $ee"/$or#ar" mo"el% #here a proce

per$orme" by calling each ubroutine in

1*:

or"er% $rom the $ir t tep in the proce $inal tage.

to the

4eman" "ri!en co"e operate by calling the $inal ubroutine% #hich in turn call the econ"/la t ubroutine to pro!i"e input% an" o $orth back through the chain o$ tep . Thi lea" to a chain o$ ubroutine call that e&ten" back#ar" to the earlie t ubroutine % an" then a chain o$ e&ecution that e&ten" $or#ar" to the $inal re ult. Thi approach can imply control $lo# in a comple& y tem #ith many cro / connection bet#een proce e . 4eman"/"ri!en co"e applie to e!ent/"ri!en y tem % $unctional y tem % an" y tem that are $ocu e" on generating a particular output% rather than per$orming a peci$ic proce . Thi may apply to o$t#are tool $or e&ample.

120

In an e&ample o$ "i playing a 3/"imen ional image o$ a con truction mo"el% a $unction may be calle" to "i play the image. Be$ore "i playing the "ata% thi ubroutine

may call another ubroutine to generate the "ata% #hich initially call a ubroutine to con truct the mo"el% #hich initially call a ubroutine to loa" the mo"el "e$inition. 8hen the en" o$ the chain #a reache"% the e&ecution #oul" begin #ith loa"ing the mo"el "e$inition% then return to con truct the mo"el% $ollo#e" by generating the "ata% an" $inally the original co"e o$ "i playing the image. In ome ca e % a proce may alrea"y ha!e

been per$orme" an" a $lag coul" be checke" to "etermine #hether another ubroutine call #a nece ary.

121

In ca e #here there #ere multiple cro / connection % each ubroutine coul" be "e$ine" in"epen"ently% an" a call to any ubroutine #oul" generate a chain o$ e&ecution that #oul" lea" to the correct re ult being pro"uce". Thi approach allo# a #i"e range o$ $unction to be per$orme" by a et o$ general $acilitie . 4i a"!antage #ith "eman"/"ri!en co"e inclu"e that $act that the e&ecution path i not "irectly relate" to a et o$ proce"ural tep % #hich may make checking an" "ebugging the co"e more "i$$icult.

122

3.6.6.

'ttribute Driven Co-e

Attribute "ri!en co"e i an e&ten ion o$ a $unction/"ri!en approach% #here each $unction per$orm action that are "e$ine" by a et o$ $lag an" option . I"eally the $lag an" option #oul" be orthogonal% #hich each $lag an" option being electe" in"epen"ently% an" each combination upporte" by the $unction. The e $unction can be implemente" by implementing each $lag an" option a a eparate tage in the co"e% rather than implementing eparate co"e $or peci$ic combination o$ $lag an" option . 8here thi approach i taken% the number o$ co"e ection re'uire" i e'ual to the number o$ $lag an" option % #hile the number o$ $unction that can be per$orme" i e'ual to the pro"uct o$ the number o$ !alue that each $lag an" option can take.

123

3or e&ample% i a reporting mo"ule implemente" t#o orting or"er % $i!e layout type % an" three ubtotalling metho" % then three ection o$ co"e #oul" be re'uire" to implement the three in"epen"ent option . 1o#e!er% the number o$ po ible output $ormat #oul" be 2&*&3% #hich #oul" be 30 po ible output $ormat . Attribute "ri!en co"e can be u e" to combine e!eral relate" proce e or $unction into a ingle general $unction. 8hen the co"e to implement in"i!i"ual combination o$ option i replace" by co"e to implement each option in"epen"ently% thi may lea" to a re"uction in the co"e !olume% an" al o an increa e in the number o$ $unction that are a!ailable.

12,

3.6.!.

/ut*ar- loo2in( co-e

@ut#ar" looking co"e applie at a ubroutine an" mo"ule le!el. @ut#ar" looking co"e make in"epen"ent "eci ion to generate the re ult that ha been re'ue te" by calling the $unction. 3or e&ample% a ubroutine may be calle" to "i play a particular ob<ect on the creen. In a tan"ar" proce /"ri!en or $unction/"ri!en approach% thi may imply per$orm a "irect action uch a "i playing the ob<ect. 1o#e!er% an out#ar" looking $unction may check the e&i ting creen "i play% to "i co!er that the ob<ect i alrea"y "i playe". In thi ca e no action nee" to be taken. Alternately% the ob<ect may be "i playe" but may be partially hi""en by another ob<ect% in #hich ca e the other ob<ect coul" be mo!e" to enable the main ob<ect to become $ully !i ible.

12*

)o"e #ritten in thi #a i ea ier to u e an" more $le&ible than co"e that "irectly per$orm a peci$ic proce . Thi allo# the calling program to call a ubroutine to achie!e a particular outcome% #ith the ubroutine it el$ taking a range o$ "i$$erent action to per$orm the action "epen"ing on current circum tance . Thi approach mo!e the logic that check the current con"ition $rom #ithin the calling program into the out#ar" looking mo"ule. 8hen the mo"ule i calle" $rom "i$$erent part o$ the co"e% an" in "i$$erent circum tance % thi lea" to a net re"uction in co"e iAe an" comple&ity. Thi al o locali e the co"e that check the con"ition #ith the operation #ithin the ubroutine

122

@ut#ar" looking co"e may impli$y program "e!elopment% a the calling program co"e may be impler% an" the out#ar" looking mo"ule coul" be "e!elope" in"epen"ently o$ other co"e. Another e&ample may in!ol!e printing multiple ub/hea"ing le!el on a report% #here ome ection may be blank an" the hea"ing may not be re'uire". In thi ca e% a ubroutine coul" be calle" "irectly to print a line o$ "ata. Thi ubroutine coul" then check #hether the correct ubhea"ing #ere alrea"y acti!e% an" i$ not then a call to a ubroutine coul" be ma"e to print the hea"ing be$ore printing the "ata it el$. @ut#ar" looking co"e re$er to e&ternal "ata an" thi may intro"uce a e'uence "epen"ence e$$ect. 1o#e!er% e'uence in"epen"ence i maintaine" i$ the parameter to the ubroutine $ully peci$y the outcome o$ the proce % e!en through the ubroutine may

125

take "i$$erent action to achie!e the re ult % "epen"ing on the e&ternal circum tance . 3or e&ample% the ubroutine -ne&tUentry(). i e&plicitly e'uence "epen"ant% a it return the ne&t entry in a li t a$ter the pre!iou call to the ubroutine. 1o#e!er% a ubroutine that a"<u te" the creen layout to match a peci$ie" pattern% an" per$orme" !arying action "epen"ing on the current creen layout% #oul" arri!e at the ame re ult regar"le o$ pre!iou operation .

A "i a"!antage o$ thi approach i that the out#ar" looking mo"ule may take !arying an" une&pecte" action . Thi may cau e "i$$icultie #hen the action re ult in i"e e$$ect that may not ha!e occurre" i$ the ubroutine u e" a tan"ar" proce /"ri!en approach.

127

3.6.".

Sel Con i(urin( Co-e

Sel$/con$iguring co"e i co"e that automatically elect calculation metho" % proce ing metho" % output $ormat etc. 3or e&ample% a report mo"ule may automatically a"" ubtotal to any report that ha a large number o$ entrie % a creen "i play routine may automatically elect a "i play $ormat ba e" on the !alue o$ the number being "i playe"% an" a calculation engine may elect $rom a number o$ e'uation/ ol!ing techni'ue ba e" on the tructure o$ an e'uation. Thi approach re"uce the amount o$ e&ternal co"e that i re'uire" to u e a general $acility. 3or e&ample% a calculation engine that ol!e" an e'uation #ithout the nee" to peci$y other parameter may be a more u e$ul $acility than one that re'uire" e!eral tep an" option % uch a initiali ing the calculation%

12:

electing a ol!ing metho"% electing initial con"ition % electing a termination thre hol" an" per$orming the calculation. In ca e #here the automatically electe" approach i not the "e ire" outcome% an o!erri"e option coul" be u e" to peci$y that a peci$ic metho" houl" be u e" in that ca e.

3.6.8.

Tas25Speci ic #an(ua(es

In ome ca e a imple language can be create" purely $or a particular application or program. 3or e&ample% in an in"u trial proce control

en!ironment a language coul" be create" #ith tatement to open an" clo e !al!e % check en or % tart proce e an" o $orth. The proce it el$ coul" be #ritten u ing the

ne#ly/"e$ine" language.

150

Thi ne# program coul" then be compile" an" tore" in an interme"iate co"e $ormat% #ith a imple run/time interpreter loop u e" to e&ecute the in truction . Thi operation coul" be "one by #riting the entire application in the ta k language. 1o#e!er% a impler approach may in!ol!e u ing tan"ar" co"e $or the tructure o$ the program an" u ing a et o$ e&pre ion an" tatement in the ta k language $or peci$ic $unction . Thi approach may be u e" in ituation #here memory torage i e&tremely limite"% a the numeric in truction $or the ta k language may con ume le entire program. Thi metho" #oul" pro"uce a $le&ible y tem #here the proce mo"i$ie". it el$ coul" be ea ily memory pace than u ing tan"ar" program co"e $or the

151

1o#e!er% implementing thi

y tem #oul"

in!ol!e #riting a par er% co"e generator an" run/time interpreter in a""ition to "e!eloping the proce it el$.

Thi approach may al o make "ebugging more "i$$icult a there #oul" be e!eral tage bet#een the proce it el$ an" the re ult % #ith the po ibility that a bug may appear in any one o$ the tage .

3.6.19. 6ueue Driven Co-e

A 'ueue i a "ata channel that pro!i"e temporary torage o$ "ata. 4ata that i retrie!e" $rom a 'ueue i retrie!e" in the ame or"er in #hich it #a in erte" into the 'ueue.

152

4ata that i in erte" into a 'ueue accumulate until it i retrie!e"% up to the ma&imum capacity o$ the 'ueue. A ingle proce in many ca e 'ueue. Kueue can be u e" in communication bet#een in"epen"ent proce e an" bet#een program an" har"#are "e!ice . The generating proce may generate "ata may in ert "ata into a 'ueue eparate proce e in ert "ata

an" retrie!e the "ata at a later time% although into the 'ueue an" retrie!e "ata $rom the

in"epen"ently% or it may generate "ata in re pon e to a re'ue t $rom the recei!ing proce . Thi can be han"le" in a number o$ #ay . The e inclu"e the $ollo#ing metho" B )hecking a tatu $lag in the 'ueue to in"icate that "ata it re'ue te".

153

Being triggere" automatically #hen the 'ueue i empty an" a "ata re'ue t i ma"e. Eecei!ing a me age $rom the recei!ing proce . =enerating "ata continuou ly #hile the 'ueue i not $ull.

At the recei!ing en" o$ the 'ueue% the recei!ing proce may be triggere" #hen "ata arri!e in the 'ueue% or it may poll the 'ueue to continually check #hether "ata i pre ent. In or"er to re'ue t "ata% the recei!ing proce may en" a me age to the generating proce an" #ait $or "ata to appear in the 'ueue% or it may attempt to e&tract "ata $rom the 'ueue% #hich may automatically trigger the generating proce empty. #hen the 'ueue i

15,

8hen a recei!ing proce

attempt to retrie!e

"ata $rom the 'ueue an" the 'ueue i empty% thi may return an error con"ition or halt the recei!ing proce Thi proce until "ata arri!e .

may al o et a tatu $lag in the can check%

'ueue that the generating proce

automatically trigger the generating proce % or take no action until "ata arri!e in the 'ueue.

3.6.11. :ser +nter ace Structure-

In ome application the u er inter$ace $orm the backbone o$ the application. The menu y tem or ob<ect #ithin the u er inter$ace may $orm the tructure o$ the y tem% #ith ection o$ co"e attache" to each point in the proce . Thi tructure ha a"!antage in eparating

the co"e into eparate ection . In"er thi

15*

mo"el% the co"e may be broken in to a large number o$ mall ection that can be "e!elope" in"epen"ently. 3unction can be ea ily a""e" an" remo!e" #ith thi tructure. Thi tructure may be uitable $or application that in!ol!e" a large number o$ u er inter$ace item % #ith each item relating to a relati!ely mall !olume o$ proce ing. 4i a"!antage #ith thi approach inclu"e the $act that the u er inter$ace an" co"e #oul" be clo ely intert#ine"% an" thi coul" cau e problem i$ the y tem #a porte" to a "i$$erent operating en!ironment or u er inter$ace mo"el. Al o% the internal proce ing coul" not ea ily be acce e" in"epen"ently% $or ta k automate" proce ing an" te ting. There may be con i"erable "uplication bet#een "i$$erent proce e an" in ituation uch a

152

#here the internal proce ing i comple& an alternati!e mo"el uch a eparating the u er inter$ace an" proce ing co"e into eparate ection may be more e$$ecti!e.

155

3.6.12. Co-e 0o-el Su$$ary

157

Code &odel +roce "ri!en co"e

Structure Se'uential tatement u e" to per$orm proce e .

3unction "ri!en co"e

3unction that per$orm general operation #ith "ata an" per$orm con$igurable proce e

Table "ri!en co"e

Table o$ "ata u e" a input to $unction an" ubroutine .

@b<ect orientate" co"e

@b<ect containing "ata an" ubroutine to operate on the "ata.

4eman" "ri!en co"e

)o"e that call pre/re'ui ite $unction . A back#ar" chain o$ ubroutine call occur % $ollo#e" by a $or#ar" chain o$ e&ecution.

Attribute "ri!en co"e

=eneral $unction controlle" by $lag an" option .

@ut#ar" looking co"e

)o"e that i calle" #ith a peci$ie" target re ult.

re ult% an" take !arying action to achie!e th

Sel$ con$iguring co"e

)o"e that automatically elect calculation metho" % an" proce ing metho" % output $ormat etc.

15:

Ta k peci$ic language

A mall language "e!elope" $or the application% #ith application co"e #ritten in the ta k language

Kueue "ri!en co"e

In"epen"ent proce e me age .

en"ing "ata through

'ueue % an" triggere" automatically or by

I er Inter$ace Structure"

Section o$ co"e attache" to u e" inter$ace ob<ect uch a menu item .

170

3.'. Data Storage

3.!.1.

+n-ivi-ual )iles

So$t#are tool o$ten u e in"i!i"ual $ile $or toring "ata. 3or e&ample% an engineering "e ign mo"el may be tore" a an in"i!i"ual $ile. Thi approach allo# $ile to be copie"% mo!e" an" "elete" in"i!i"ually% ho#e!er thi approach become impractical #hen a large number o$ "ata ob<ect are in!ol!e".

3.!.2.

Docu$ent 0ana(e$ent Syste$s

4ocument torage y tem are u e" in en!ironment that in!ol!e a large number o$ "ocument . The e may imply be mail me age % memo an" #ork$lo# item % or 171

they coul" al o tore large !olume o$ canne" paper "ocument . 4ocument management y tem inclu"e $acilitie $or earching an" categori ing "ocument % "i playing li t o$ "ocument % e"iting te&t an" mailing in$ormation to other location . The e y tem may al o inclu"e programming language that can be u e" to implement application y tem . uch a #ork$lo#

3.!.3.

Databases

3.!.3.1. Database 0ana(e$ent Syste$s

A "ataba e management y tem i a program that i u e" to tore% retrie!e an" up"ate large !olume o$ "ata #ithin tructure" "ata $ile .

172

4ataba e management y tem typically inclu"e a u er inter$ace that upport a"/hoc 'uerie % report % up"ate an" the e"iting o$ "ata. +rogram inter$ace are al o upporte" to allo# program to retrie!e an" up"ate "ata by inter$acing #ith the "ataba e management y tem. Some operating y tem inclu"e "ataba e management y tem a part o$ the operating y tem $unctionality% #hile in other ca e a eparate y tem i u e".

3.!.3.2. Data Stora(e

4ataba e typically tore "ata ba e" on three tructure .

173

A $iel" i an in"i!i"ual "ata item% an" may be a numeric "ata item% a te&t $iel"% a "ate% or ome other in"i!i"ual "ata item. A recor" i a collection o$ $iel" . A table i a collection o$ "ata recor" o$ the ame type. A "ataba e may contain a relati!ely mall number o$ table ho#e!er each table may contain a large number o$ in"i!i"ual recor" . +rimary "ata i the "ata that ha been ource" e&ternally $rom the y tem. Thi inclu"e keye" input an" "ata that i uploa"e" $rom other y tem . 4eri!e" "ata i "ata than ha been generate" by the y tem an" tore" in the "ataba e. In ome ca e "eri!e" "ata can be "elete" an" re/generate" $rom the primary "ata.

17,

6ink bet#een recor" can be han"le" u ing a pointer y tem or a relational y tem. In the pointer mo"el% a parent recor" contain a pointer to the $ir t chil" recor". 3ollo#ing thi pointer locate the $ir t chil" recor"% an" pointer $rom that recor" can be $ollo#e" to can each o$ the chil" recor" . In the relational mo"el% the chil" recor" inclu"e a $iel" that contain the key o$ the parent recor". 0o "irect link are nece ary% an" each recor" can be up"ate" in"i!i"ually #ithout a$$ecting other recor" . The relational mo"el i a general mo"el that i ba e" imply on et o$ "ata% #ithout e&plicit connection bet#een recor" . In the relational mo"el% the chil" recor" re$er to the parent recor"% #hich i the oppo ite approach to the pointer y tem% in #hich the parent recor" re$er to the chil" recor".

17*

3.!.3.2.1. ;eys

The primary key o$ a recor" i a "ata item that i u e" to locate the recor". Thi can be an in"i!i"ual $iel"% or a compo ite key that i "eri!e" $rom e!eral in"i!i"ual $iel" combine" into a ingle !alue. A $oreign key i a $iel" on a recor" that contain the primary key o$ another recor". Thi i u e" to link relate" recor" . Hey $iel" are generally hort te&t $iel" uch a an account number or client co"e. )ompo ite key may be compo e" o$ in"i!i"ual key $iel" an" other $iel" "ate . The u e o$ a hort key re"uce torage uch a

re'uirement $or in"e&e % an" may al o a!oi" ome problem #hen multiple layer o$

172

o$t#are treat character "i$$erent #ay .

uch a

pace in

3.!.3.2.2. Relate- Recor-s

Eecor" in "i$$erent table may be unrelate"% or they may be relate" on a one/to/one% one/ to/many% or many/to/many ba i . A one/to/one link occur #hen a ingle recor" in one table i relate" to a ingle recor" in another table. Multiple recor" $ormat are an e&ample o$ thi % #here the common "ata i alternati!e $ormat i tore" in a main table% an" peci$ic "ata $or each tore" in eparate table .

Thi link can be implemente" by toring the primary key o$ the main recor" a a $oreign key $iel" in the other recor".

175

A one/to/many link occur #hen a ingle recor" in one table i relate" to e!eral recor" in another table. 3or e&ample% a ingle account recor" may be relate" to e!eral tran action recor" % ho#e!er a tran action recor" only relate to one account. Thi i al o kno#n a a parent/chil" connection. A one/to/many link can be implemente" by toring the primary key o$ the parent recor" a a $oreign key $iel" in each o$ the chil" recor" . A many/to/many link occur bet#een t#o "ata entitie #hen each recor" in one table coul" be relate" to e!eral recor" in the other table. 3or e&ample% the connection bet#een aircra$t route an" airport may be a many/

177

to/many connection. ;ach route may be relate" to e!eral airport % #hile each airport may be relate" to e!eral route . A many/to/many connection can be implemente" by creating a thir" table that contain t#o $oreign key % one $or each o$ the main table . ;ach recor" in the thir" table #oul" in"icate a link $rom a recor" in one table to a recor" in the other table. The recor" may imply contain t#o key % or a""itional in$ormation coul" be inclu"e"% uch a a "ate% an" a "e cription o$ the connection.

17:

The $ollo#ing "iagram illu trate a one/to/ one "ataba e link.

The $ollo#ing "iagram illu trate a one/to/ many "ataba e link.

1:0

The $ollo#ing "iagram illu trate a many/to/ many "ataba e link.

3.!.3.2.3. Re erential +nte(rity

A problem can occur #hen a primary key o$ a recor" i up"ate"% but the $oreign key o$ relate" recor" are not up"ate" to match the change. In thi ca e an" link bet#een the recor" #oul" be lo t.

1:1

Thi

ituation can be a""re e" by u ing a tructure i

ca ca"ing up"ate. 8hen thi

inclu"e" in the "ata "e$inition% the $oreign key #ill automatically be up"ate" #hen the primary key i up"ate". A imilar ituation ari e #ith "eleting recor" . I$ a recor" i "elete"% then recor" containing $oreign key that relate" to that recor" #ill re$er to a recor" that no longer e&i t . 4e$ining a ca ca"ing "elete #oul" cau e all the recor" containing a matching $oreign key to be "elete" #hen the main recor" #a "elete".

3.!.3.2.4. +n-e&es

4ataba e inclu"e "ata tructure kno# a in"e&e to increa e the pee" o$ locating

1:2

recor" . An in"e& may be a el$/balancing tree tructure uch a a B/tree. The in"e& i maintaine" internally #ithin the "ataba e. In the ca e o$ 'uery language the in"e& i generally tran parent to the caller% an" increa e acce a$$ect the re ult. In other ca e % in"e&e can be electe" in program co"e an" a earch can be per$orme" "irectly again t a "e$ine" in"e&. In"e&e are generally "e$ine" again t all primary key . Al o% #here recor" #ill be acce e" in a "i$$erent or"er to the primary key% a eparate in"e& may be "e$ine" that i ba e" on the alternati!e proce ing or"er. In"e&e may al o be "e$ine" on other $iel" #ithin the recor" #here a "irect acce i re'uire" ba e" on the !alue o$ another $iel". pee" but "oe not

1:3

3.!.3.3. Database -esi(n

In general each eparate logical "ata entity i "e$ine" a a eparate "ataba e table. Al o% "ata that i recor"e" in"epen"ently% uch a an in"i!i"ual "ata item that i recor"e" on "i$$erent "ate % may al o be "e$ine" a a eparate table

3.!.3.3.1. Data Types

4ata type

upporte" by "ataba e

management y tem are imilar to the "ata type u e" in programming language . Thi may inclu"e !ariou numeric "ata type % "ate % an" te&t $iel" .

1:,

Some "ataba e y tem

upport !ariable/

length te&t $iel" although in many ca e the length o$ the $iel" mu t be peci$ie" a part o$ the recor" "e$inition% particularly i$ the $iel" #ill be u e" a part o$ a key or in orting. Ine&pecte" re ult can occur i$ numeric !alue an" "ate are tore" in te&t $iel" rather than in their nati!e $ormat. 3or e&ample% the te&t tring -10. may be orte" a a lo#er !alue than -:.% a the $ir t character in the tring i a -1. an" thi may be lo#er in the collating e'uence than the character -:..

3.!.3.3.2. Re-un-ant Data

8hen a "ata !alue appear multiple time #ithin a "ataba e% thi may in"icate that the

1:*

"ata repre ent a eparate logical entity to the table or table that it i recor"e" in. In thi ca e% the "ata coul" be plit into a eparate "ata table. Thi #oul" re ult in a one/to/many link $rom the ne# table to the original table. Thi #oul" be implemente" by toring the primary key o$ the ne# recor" a a $oreign key #ithin the original recor" . Thi proce #oul" generally be "one a part

o$ the original "ataba e "e ign% rather than appearing "ue to actual "uplicate" in$ormation. 3or e&ample% i$ a ingle cu tomer name appeare" on e!eral in!oice % thi #oul" be re"un"ant "ata an" #oul" in"icate that the cu tomer "etail an" in!oice "etail #ere in"epen"ent "ata entitie .

1:2

In thi ca e a eparate cu tomer table coul" be create"% an" the primary key o$ a cu tomer recor" coul" be tore" a a $oreign key in the in!oice recor".

3.!.3.3.3. 0ultiple Recor- )or$ats

In ome ca e a ingle logical entity may inclu"e more than one recor" $ormat% uch a a client table #hich inclu"e both in"i!i"ual client an" corporate client . Some "etail #oul" be the ame% uch a name an" a""re % #hile other #oul" "i$$er uch a "ate o$ birth an" primary contact name. In thi ca e% the common $iel" can be tore" in the main recor"% an" a one/to/one link e tabli he" to other table containing the peci$ic "etail o$ each $ormat.

1:5

1o#e!er% thi

tructure complicate the

"ataba e "e ign an" al o the proce ing% replacing one table #ith three #ith no increa e in $unctionality. In ca e #here the number o$ peci$ic $iel" i not e&ce i!e% a impler olution may be to combine all the $iel" into a ingle recor". Thi #oul" re ult in ome $iel" being unu e"% ho#e!er thi #oul" impli$y the "ataba e "e ign an" may increa e proce ing pee" lightly. Thi may al o re"uce the "ata torage iAe #hen the o!erhea" o$ e&tra in"e&e an" internal tructure i taken into account. Some "ataba e management y tem allo# multiple recor" $ormat to be "e$ine" $or a ingle table. In the e ca e % the primary key an" a et o$ common $iel" are the ame in each recor"% #hile the peci$ic $iel" $or a particular recor" $ormat u e the ame torage

1:7

pace a the alternati!e $iel" $or other recor" $ormat .

3.!.3.3.4. Co-e- & )ree )or$at )iel-s

A co"e" $iel" i a $iel" that contain a !alue that i one o$ a $i&e" et o$ co"e . Thi "ata item coul" be tore" a a numeric "ata $iel"% or it may be a te&t $iel" o$ e!eral character containing a numeric or alphabetic co"e. 3ree $ormat $iel" are te&t $iel" that tore any te&t input. )o"e" $iel" can be u e" in proce ing% in contra t to $ree/$ormat $iel" #hich can only be u e" $or manual re$erence% or inclu"e" in printe" output. 8here a "ata item may be u e" in $uture proce ing% it houl" generally be tore" in a

1::

numeric or co"e" $iel"% rather that a general te&t $iel".

3.!.3.3.5. Date5Driven Data

Many "ata item are relate" to e!ent that occur on a particular "ate% uch a tran action . Al o% many "ata erie are ba e" on mea urement or "ata that $orm a time erie o$ in$ormation. In the e ca e the primary key o$ the "ata recor" may con i t o$ main key an" a "ate. 3or e&ample% the primary key o$ a tran action may be the account number an" the "ate. In ca e #here multiple e!ent can occur on a ingle "ay% a "i$$erent arrangement% uch a a uni'ue tran action number% can be u e" to i"enti$y the recor".

200

1i torie may al o be kept o$ "ata that i change" #ithin the "ataba e. 3or e&ample% the um in ure" !alue o$ an in urance policy may be tore" in a "ata/ "ri!en table% u ing the policy number an" the e$$ecti!e "ate a the primary key. Thi #oul" enable each "i$$erent !alue% an" the "ate that it applie" $rom% to be tore" a a eparate recor". A hi tory recor" may be manually entere" #hen a change to a "ata item occur % or in other ca e the main recor" i mo"i$ie" an" the hi tory recor" i automatically generate" ba e" on the change. 1i torie are u e" to re/pro"uce calculation that applie" at pre!iou point in time% uch a re/printing a tatement $or a pre!iou perio". 1i torie may be tore" o$ "ata that i kept $or output or recor"/keeping purpo e only%

201

uch a name an" a""re e % but hi tory particularly applie to "ata item that are u e" in proce ing. 4ate/"ri!en "ata i al o u e" #hen a calculation co!er a perio" o$ time. 3or e&ample% i$ the um in ure" !alue o$ an in urance policy change" mi"/#ay through a perio"% the premium $or the perio" may be calculate" in t#o part % u ing the initial um/ in ure" $or the $ir t part o$ the perio" an" the up"ate" um/in ure" $or the econ" part o$ the perio". In ome ca e % change to a main "ata recor" are recor"e" by toring multiple copie o$ the entire "ata recor". In other ca e each "ata item that i #ith a hi tory i tore"

plit into an in"i!i"ual table.

Thi can be implemente" by creating a primary key in the hi tory recor" that i

202

compo e" o$ the primary key o$ the main recor"% an" the e$$ecti!e "ate o$ the "ata.

3.!.3.3.6. 'ttributes an- Separate )iel-s

4ata tructure can be impler an" more $le&ible #here "i$$erent "ata item are i"enti$ie" by attribute $iel" % rather than being tore" in eparate "ata item . 3or e&ample% the $ollo#ing table may recor" "ata ample #ithin a meteorological y tem.

6ocation 1umi"ity 123,*2 23,.21

4ate

Temperature

+re ure

1N1N70

1.23

31.2

1o#e!er% an alternati!e implementation may be to tore each "ata item in a eparate recor"% an" i"enti$y the "ata item u ing a 203

eparate attribute $iel"% rather than by a $iel" name. Thi coul" be implemente" in the $ollo#ing #ay
6ocation 9alue 123,*2 1.23 123,*2 31.2 123,*2 23,.21 1N1N70 1IMI4ITM 1N1N70 +E;SSIE; 1N1N70 T;M+E;TIE; 4ate Type

0e# attribute % uch a -MI0UT;M+E;TIE;.% coul" be a""e" #ithout changing the "ataba e tructure or program co"e. 4ata entry an" "i play ba e" on thi mo"el #oul" not nee" to be up"ate". 1o#e!er% creen entry or reporting that "i playe" e!eral !alue a be mo"i$ie". 20, eparate $iel" may nee" to

In thi e&ample% there #oul" be no re triction on each location recor"ing the ame attribute % an" a larger et o$ attribute coul" be "e$ine" #ith a !arying ub/ et o$ attribute recor"e" $or "i$$erent et o$ "ata. Al o% the program co"e may be impler an" more general% a the proce ing #oul" in!ol!e a -location.% -"ate.% -attribute. an" -!alue.% rather than peci$ic in$ormation relate" to the ample them el!e . 8hen a large number o$ attribute are tore"% thi approach may igni$icantly impli$y the co"e. In the ca e o$ a mall number o$ attribute % thi metho" allo# general routine an" proce ing to be u e" in place o$ eparate $iel"/ peci$ic co"e. Thi co"e coul" al o be applie" to other "ata area #ithin the y tem that coul" be recor"e" u ing a imilar approach.

20*

Eecor"

tore" in the econ" $ormat coul" be uch a ubtotalling an"

proce e" by general y tem $unction that per$orme" proce e a!eraging. 4i a"!antage #ith the econ" $ormat inclu"e the larger number o$ in"i!i"ual recor" % the po ibility o$ ynchroni ation problem #hen a matching et o$ recor" i not $oun"% an" the greater "i$$iculty in tran lating the "ata recor" into a ingle creen or report layout that containe" all the in$ormation $or one et o$ !alue .

3.!.3.3.!. Ti$esta$ps

A time tamp i a $iel" containing a "ate% time an" po ibly other in$ormation uch a a u er logon an" program name. Time tamp may be tore" a "ata item in a recor" to i"enti$y the con"ition un"er #hich

202

a recor" #a create"% an" the "etail o$ #hen it #a la t change". Time tamp can be u e" $or "ebugging an" a"mini trati!e purpo e % uch a reconciling account % tracing "ata problem % an" re/ e tabli hing a e'uence o$ e!ent #hen in$ormation i una!ailable or con$licting.

3.!.3.4. Data 'ccess

3.!.3.4.1. 6uery #an(ua(es

Some "ataba e management y tem 'uery language .

upport

The e language allo# group o$ recor" to be electe" $or retrie!al or up"ating. Kuery language are imple an" $le&ible.

205

Kuery language are generally "eclarati!e% not proce"ural language . Although the language may contain tatement that are e&ecute" in e'uence% the actual election o$ recor" in ba e" on a "e$inition tatement% rather than a et o$ tep . The u e o$ a 'uery language allo# many o$ the "etail o$ the "ataba e implementation to become tran parent to the calling program% uch a the in"e&e "e$ine" in the "ata ba e% the actual collection o$ $iel" in a table% an" o on. 3iel" can be a""e" to table #ithout a$$ecting a 'uery that electe" other e&i ting $iel" % an" in"e&e can be a""e" to increa e acce pee" #ithout re'uiring a change in the 'uery "e$inition. In theory a "ataba e y tem coul" be replace" #ith an alternati!e y tem that upport the ame 'uery language% uch a #hen "ata !olume gro# ub tantially an" an

207

alternati!e "ataba e management y tem i re'uire". 1o#e!er% there are al o "i a"!antage #ith 'uery language The ma<or "i a"!antage relate to per$ormance. A the 'uery language i a $ull te&t/ba e" language% there may be a igni$icant o!erhea" in!ol!e" in compiling the 'uery into an internal $ormat% "etermining #hich in"e&e to u e $or the operation% an" per$orming the actual proce . Thi "elay may be re"uce" in ome ca e by u ing a pre/compile" 'uery% ho#e!er thi i till likely to be lo#er that a "irect ubroutine call to a "ataba e $unction. Thi "elay may be a particular i ue $or algorithm that in!ol!e a large number o$ in"i!i"ual ran"om recor" earche .

20:

3.!.3.4.2. +n-e&54ase- 'ccess

Some "ataba e management y tem

upport

"irect recor" earche ba e" on in"e&e . Thi may in!ol!e electing a table an" an in"e&% creating a primary key an" per$orming the earch. Thi approach i le $le&ible than u ing a

'uery language. The tructure o$ the in"e&e mu t be inclu"e" in the co"e% an" the co"e may be more comple& an" le portable.

1o#e!er% "ue to the lo#er internal o!erhea" in!ol!e" in a "irect in"e& earch% the per$ormance o$ in"e&/ba e" operation may be ub tantially $a ter than "ata 'uerie .

210

3.!.3.4.3. :ser +nter aces

Many "ataba e management y tem inclu"e a "irect u er inter$ace. Thi may allo# "ata to be "irect e"ite"% an" may upport a"/hoc 'uerie % reporting an" "ata up"ate . Kuerie may be per$orme" u ing a 'uery language% or u ing a et o$ menu/"ri!en $unction an" report option . Some y tem al o inclu"e an internal macro language that can be u e" to per$orm comple& operation % inclu"ing "e!eloping complete application .

211

3.(. )umeric Calculations

3.".1.

<u$eric Data Types

Many language

upport e!eral "i$$erent

numeric "ata type . 4ata type !ary in the amount o$ memory pace u e"% the pee" o$ calculation % an" the preci ion an" range o$ number that can be tore". Integer "ata type recor" #hole number only. 3loating point !ariable recor" a number o$ "igit o$ preci ion% along #ith a eparate !alue to in"icate the magnitu"e o$ the number. Integer an" $loating point "ata type are #i"ely u e". )alculation #ith the e "ata

212

type may be implemente" "irectly a har"#are in truction . 3i&e" point "ata type recor" a $i&e" number o$ "igit be$ore an" a $i&e" number o$ "igit a$ter the "ecimal point. Scale" "ata type recor" a $i&e" number o$ "igit % an" may u e a $i&e" or !ariable "ecimal point po ition. Arbitrary preci ion !ariable ha!e a range o$ preci ion that i !ariable% #ith a large upper limit. The preci ion may be electe" #hen the !ariable i "e$ine"% or may be automatically electe" "uring calculation . )obol u e an unu ual $ormat #here a !ariable i "e$ine" #ith $i&e" et o$ character po ition % an" each po ition can be peci$ie" a alphabetic% alphanumeric% or numeric

213

3.".2.

<u$eric Data Stora(e

Integer are generally tore" a binary number . 3loating point !ariable tore the manti a

an" e&ponent o$ the !alue eparately. 3or e&ample% the number 1230000 i repre ente" a 1.23 & 102 in cienti$ic notation% an" 0.00,*2 #oul" be ,.*2 & 10/3. In the $ir t e&ample% a !alue repre enting the 123 may be tore" in one part o$ the !ariable% #hile a !alue repre enting the 2 may be tore" in a eparate part o$ the !ariable. Actual "etail !ary #ith the torage $ormat u e". The preci ion o$ the $ormat i the number o$ "igit o$ accuracy that are recor"e"% #hile the range peci$ie the "i$$erence bet#een the malle t an" large t !alue that can be tore".

21,

Thi $ormat i ba e" on the cienti$ic notation mo"el% #here large an" mall number are recor"e" #ith a eparate manti a an" e&ponent. 3or e&ample
22*,000000 10: 0.00000753 ? 7.53 & 10/2 ? 2.2*, &

;&ample o$ integer "ata type B


Storage iAe 2 byte , byte C2%1,5%,73%2,5 0umber range /32%527 to C32%525 /2%1,5%,73%2,7 to

21*

;&ample o$ $loating point "ata type B


Storage SiAe Eange , byte appro& 10 7 byte appro& 10
/32, /,*

+reci ion

appro& 5 "igit to 10
37

appro& 1* "igit to 10
307

3i&e" point number may al o be tore" a binary number % #ith the po ition o$ the "ecimal point taken into account #hen calculation are per$orme". B)4 (Binary )o"e" 4ecimal) number are tore" #ith each "ecimal "igit recor"e" a a eparate ,/bit binary co"e. @ther numeric type may be tore" a te&t tring o$ "igit % or a tructure" binary block containing ection $or the number it el$ an" a cale i$ nece ary.

212

3.".3. Spee-

0e$ory :sa(e an- %&ecution

=enerally calculation #ith integer are the $a te t numeric calculation % an" integer u e the lea t amount o$ memory pace. 3loating point number may al o e&ecute 'uickly #hen the calculation are implemente" a har"#are in truction . Both integer an" $loating point number may be a!ailable in e!eral $ormat % #ith the range an" preci ion o$ the "ata type relate" to the amount o$ memory torage u e". 8hen the calculation $or a numeric "ata type are implemente" internally a ubroutine % the per$ormance may be igni$icantly lo#er than imilar operation u ing har"#are/ upporte" "ata type .

215

3.".4.

<u$eric /perators

Although the ymbol an" #or" !ary% mo t programming language "irectly upport the ba ic arithmetic operation B C / D N mo" R a""ition ubtraction multiplication "i!i ion mo"ulu ;&ponentiation% y&

8hen calculation are per$orme" #ith integer !alue % the $ractional part i u ually truncate"% o that only the #hole/number part o$ the re ult i retaine".

217

6anguage that are orientate" to#ar" numeric proce ing may inclu"e other numeric operator % uch a operator $or matri& multiplication% operation #ith comple& number % etc.

3.".5.

0o-ulus

The mo"ulu operator i u e" #ith integer arithmetic to capture the $ractional part o$ the re ult. The mo"ulu i the "i$$erence bet#een the numerator in a "i!i ion operation% an" the !alue that the numerator #oul" be i$ the "i!i ion e'ualle" the e&act integer re ult. 3or e&ample% 13 "i!i"e" by * e'ual 2.2. Truncating thi re ult to pro"uce an integer !alue lea" to a re ult o$ 2.

21:

1o#e!er% 10 "i!i"e" by * i e&actly e'ual to 2. In thi e&ample% the mo"ulu #oul" be e'ual to the "i$$erence bet#een 13 an" 10% or in thi ca e 3. Thi coul" be e&pre e" a 13 mo" * ? 3

An e'ui!alent calculation o$ -a M@4 b. i -a J b D int( a N b ).% #here the -int. operation pro"uce the truncate" integer re ult o$ the "i!i ion. Thi operator may be u e$ul in mapping a large number range onto an o!erlapping maller range. 3or e&ample% i$ -total/line . #a the total number o$ line in a long "ocument% then the $ollo#ing re ult #oul" occurB

220

page/number ? total/line N line /per/page (integer "i!i ion) line/on/page ? total/line Mo" line /per/page

In thi e&ample% the -total line . !alue increa e through the "ocument% #hile the -line/on/page. !alue #oul" re et to Aero a it cro e" o!er into each ne# page.

3.".6.

Roun-in( %rror

Some number cannot be repre ente" a a $inite erie o$ "igit . @ne "i!i"e" by three% $or e&ample% i W #hen e&pre e" a a $raction% but i 0.333333333X. #hen e&pre e" a a "ecimal. +rogramming language "o not generally upport e&act $raction % apart $rom ome peciali t mathematical package . 221

In thi ca e% the 3 a$ter the "ecimal point repeat $ore!er% but the preci ion o$ the tore" number i limite". @ne/thir" plu t#o thir" e'ual one. I ing number #ith 1* "igit o$ preci ion% ho#e!er% the re ult #oul" be 0.333333333333333 C ? 0.222222222222222 0.:::::::::::::::

I$ a check #a "one in the program co"e to ee #hether the re ult #a e'ual to 1% thi te t #oul" return $al e% not true% a the number tore" i 0.:::::::::::::::% #hich i "i$$erent $rom 1.000000000000000. The ma&imum roun"ing error that can occur in a number i e'ual to one/hal$ o$ the malle t !alue repre ente" in the manti a.

222

3or e&ample% #ith 1* "igit o$ preci ion% the ma&imum roun"ing error #oul" be a !alue o$ * in the i&teenth place. 4uring a erie o$ a""ition an" ubtraction % the ma&imum total error #oul" be e'ual to the number o$ operation % multiplie" by a !alue o$ one/hal$ o$ the malle t manti a !alue. In the ca e o$ -n. a""ition or ubtraction operation % the number o$ igni$icant $igure lo t i e'ual to log10(* D n) 8hen multiplication an" "i!i ion are per$orme"% the ma&imum error #oul" increa e in the or"er o$ one/hal$ o$ the malle t manti a !alue rai e" to the po#er o$ the number o$ operation . Eoun"ing problem can be re"uce" i$ ome o$ the $ollo#ing tep are taken.

223

A number torage $ormat #ith an a"e'uate number o$ "igit o$ preci ion i u e". )haining o$ calculation $rom one re ult to the ne&t i a!oi"e"% an" re ult are calculate" in"epen"ently $rom input $igure #here po ible. The $ull le!el o$ preci ion i carrie" through all interme"iate re ult % an" roun"ing only occur $or printing% "i play% "ata torage% or #hen the $igure repre ent an actual number% uch a #hole cent . )alculation are tructure" to a!oi" ubtracting imilar number . 3or e&ample% -32**.,3,22, J 32**.,3,120 ? 0.00010,.% an" ten "igit o$ preci ion "rop to three "igit o$ preci ion.

8hen calculation ha!e been per$orme" #ith number % comparing !alue "irectly may not generate the e&pecte" re ult .

22,

Thi i ue can be a""re e" by comparing the number again t a mall "i$$erence tolerance. 3or e&ample
Bf (absolute_value( num# 0 num+ ) " 3633333# then

;rror in numeric calculation may al o appear "ue to proce ing i ue that are not "irectly relate" to the torage preci ion. 3or e&ample% one y tem may roun" number to t#o "ecimal place be$ore toring the "ata in a "ataba e% #hile another y tem may "i play an" print number to t#o "ecimal place but tore the number #ith a $ull preci ion. In the e ca e % comparing total o$ the t#o li t may re ult in roun"ing error in the thir"

22*

"ecimal place% rather than the la t igni$icant "igit.

3.".!.

+nvali- /perations

I$ a calculation i attempte" that #oul" pro"uce a re ult that i larger than the ma&imum !alue that a "ata type can tore% then an o!er$lo# error may occur. 6ike#i e% i$ the re ult #oul" be le than the

minimum iAe $or the "ata type% but greater than Aero% then an un"er$lo# error may occur. 4i!i"ing a number by Aero i an un"e$ine" mathematical operation% an" attempting to "i!i"e a number by Aero may re ult in a "i!i"e/by/Aero error. The han"ling o$ in!ali" numeric operation !arie #ith "i$$erent programming

222

language % but $re'uently a program termination #ill re ult i$ the error i not trappe" by an error/han"ling routine #ithin the co"e. The e problem can be re"uce" by checking that the "enominator i non/Aero be$ore per$orming a "i!i ion or mo"ulu % an" by u ing a "ata type that ha an a"e'uate range $or the calculation being per$orme".

3.".".

Si(ne- & :nsi(ne- 'rit1$etic

In ome language numeric "ata type can be "e$ine" a either igne" or un igne" "ata type . I ing un igne" "ata type allo# a #i"er range o$ number to be tore"% ho#e!er thi i a minor "i$$erence in compari on to the !ariation bet#een "i$$erent "ata type .

225

Mi&ing igne" an" un igne" number in e&pre ion can occa ionally lea" to une&pecte" re ult % e pecially in ca e #here !alue marker uch a /1 are u e" to repre ent uch a the en" o$ a li t.

3or e&ample% i$ a negati!e !alue #a u e" in an un igne" compari ion% it #oul" be treate" a a large po iti!e !alue% a negati!e !alue are the e'ui!alent bit/pattern to the large t hal$ o$ the un igne" number range. In the ca e o$ a 2 byte integer% the range o$ number #oul" be a
4ata Type 2 byte C32%525 2 byte un igne" C2**32 0 to igne"

ho#n belo#.
Eange /32%527 to

227

3.".8. Types

Conversion bet*een <u$eric

8hen numeric !ariable o$ "i$$erent type are mi&e"% ome language automatically con!ert the type % other language allo# con!er ion #ith an operator or $unction% an" other language "o not allo# con!er ion . I$ t#o item in an arithmetic e&pre ion ha!e "i$$erent numeric type % the !alue #ith the lo#er le!el o$ preci ion may be con!erte" to the ame le!el o$ preci ion a the other !alue be$ore the calculation i per$orme". 1o#e!er% the "etail o$ "ata type promotion !arie #ith each language.

3.".19. Strin( & <u$eric conversion

0umeric "ata type cannot be "i playe" "irectly an" mu t be con!erte" to te&t tring o$ "igit be$ore they can be printe" or "i playe". 22:

Al o% In$ormation "eri!e" $rom creen entry or te&t uploa" $ile may be in a te&t $ormat% an" mu t be con!erte" to a numeric "ata type be$ore calculation can be per$orme". 6anguage generally inclu"e operator or ubroutine $or con!erting bet#een numeric "ata type an" tring . Thi con!er ion i a relati!ely lo# operation% an" per$ormance problem may be re"uce" i$ the number o$ con!er ion i kept to a minimum.

230

3.".11. Si(ni icant )i(ures

The number o$ igni$icant $igure in a number i the number o$ "igit that contain in$ormation. 3or e&ample% the number *023000000 an" 0.000000*023 both contain $our igni$icant "igit . The $igure -*023. peci$y in$ormation concerning the number% #hile the Aero peci$y the number( iAe.

Mea urement may be recor"e" #ith a $i&e" number o$ igni$icant $igure % rather than a $i&e" number o$ "ecimal place . 3or e&ample% a mea urement that i accurate to 1 part in 1000 #oul" be accurate to three igni$icant "igit . Eoun"ing can be per$orme" to a $i&e" number o$ "ecimal place % or a $i&e" number o$ igni$icant $igure . 8hen a #i"e range o$ number are "i playe" in a narro# pace% a $loating "ecimal point can be u e" #ith a $i&e" number o$

231

igni$icant $igure . 3or e&ample% the number - 320,.7. an" - 3.52**. both contain $i!e igni$icant "igit .

3.".12. <u$ber Syste$s

0umber are u e" $or e!eral purpo e #ith program . @ne u e i to recor" co"e % uch a a number that repre ent a letter% or a number that repre ent a election $rom a li t o$ option . 0umber are al o u e" to repre ent a 'uantity o$ item . The "ecimal number 12% the roman numeral VII% an" the binary number 1100 all repre ent the ame number% an" #oul" repre ent the ame 'uantity o$ item .

232

3.".12.1.Ro$an <u$erals

In the Eoman number y tem% ma<or number are repre ente" by "i$$erent ymbol . I i 1% 9 i *% V i 10% 6 i *0% ) i 100 an" o on. 0umeral are a""e" together to $orm other number . I$ a lo#er !alue appear to the le$t o$ another !alue% it i a""e" to the main !alue% other#i e it i ubtracte".

233

The $ir t ten roman numeral are I II III I9 9 9I 9II 9III IV V 1 2 3 , * 2 5 7 : 10 $i!e plu one $i!e plu t#o $i!e plu three ten minu one $i!e minu one

Although thi

y tem can recor" number up y tem.

to large !alue % it i "i$$icult to per$orm calculation #ith number u ing thi

3.".12.2.'rabic <u$ber Syste$s

23,

An Arabic number y tem u e a $i&e" et o$ ymbol . ;ach po ition #ithin a number contain one o$ the ymbol . The !alue o$ each po ition increa e by a multiple o$ the ba e o$ the number y tem% mo!ing $rom the right/mo t po ition to the le$t. The !alue o$ each po ition in a particular number i gi!en by the !alue o$ the po ition it el$% multiplie" by the !alue o$ the ymbol in that po ition.

3or e&ample
31*0, 3 & 10000 C 1 & 103 C 1 & 1000 C * & 102 C * & 100 C 0 & 101 C 0 & 10 C , & 100 C,&1 ? 3 & 10, ?

23*

The "ecimal number y tem i an Arabic number y tem #ith a ba e o$ 10. The "igit ymbol are the tan"ar" "igit 0% 1% 2% 3% ,% *% 2% 5% 7 an" :. @ther ba e can be u e" $or alternati!e number y tem . 3or e&ample% in a number y tem #ith a ba e o$ three% the number 21302 #oul" be e'ui!alent to the number 217 in "ecimal.

213023 ? 2 & 7110

2 & 3, C 1 & 33 C 1 & 2510 C 3 & 32

C 3 & :10 C 0 & 31 C 0 & 310 C 2 & 30 C2&1

? 21710

232

In thi notation% the ub cript repre ent the ba e o$ the number. The ba e/three repre entation 21302 an" the ba e/ten repre entation 217 both repre ent the ame 'uantity.

3.".12.2.1. 4inary <u$ber Syste$

The Arabic number y tem #ith a ba e o$ 2 i the kno#n a the binary number y tem. The "igit u e" in each po ition are 0 an" 1. In computer har"#are% a !alue i repre ente" electrically #ith a !alue that i either on or o$$. Thi !alue can repre ent t#o tate % uch a 0 an" 1. ;ach in"i!i"ual torage item i kno#n a a bit% an" group o$ bit are u e" to tore number in a binary number $ormat.

235

)omputer memory i commonly arrange" into byte % #ith a eparate memory a""re $or each byte. A byte contain eight bit . An e&ample o$ a binary number i
1011012 ? 1 & 3210 C 0 & 2, C 0 & 1210 C 1 & 23 C 1 & 710 C 1 & 22 C 1 & ,10 C 1 & 21 C 0 & 210 C 1 & 20 C1&1 1 & 2* ?

? ,*10

In thi e&ample% the binary number 101101 i e'ui!alent to the "ecimal number ,*. A the ba e o$ the binary number y tem i t#o% each po ition in the number repre ent a

237

number that i a multiple o$ 2 time larger than the po ition to it right. The !alue o$ a number po ition i the ba e rai e" to the po#er o$ the po ition% $or e&ample% the "igit one in the $ourth po ition $rom the right in a "ecimal number ha a !alue o$ 103 ? 1000. In a binary number% a "igit in thi po ition #oul" ha!e a !alue o$ 23 ? 7.

3.".12.2.2. .e&a-eci$al <u$bers

The he&a"ecimal number y tem i the Arabic number y tem that u e a ba e o$ 12. Thi i u e" a a horthan" #ay o$ #riting binary number . A the ba e o$ 12 i a "irect po#er o$ t#o% each he&a"ecimal "igit "irectly corre pon" to $our binary "igit .

23:

1e&a"ecimal number are u e" $or #riting con tant in co"e that repre ent a pattern o$ in"i!i"ual bit rather than a number% uch a a et o$ option #ithin a bitmap. 4ue to the $act that the ba e o$ the number y tem i 12% there are 12 po ible ymbol in each po ition in the number. A there are only ten tan"ar" "igit ymbol % letter are al o u e". The character u e" in a he&a"ecimal number are 0% 1% 2% 3% ,% *% 2% 5% 7% :% A% B% )% 4% ; an" 3. The character A through to 3 ha!e the !alue 10 through to 1*.

3or e&ample%
743312 ,0:210 C 4 & 122 C 1310 & 2*210 C 3 & 121 C 3 & 1210 ? 7 & 123 ? 7 &

2,0

C 3 & 120 C 1*10 & 1

? 321*:10

? 10001101001111112

There i a "irect corre pon"ence bet#een each he&a"ecimal "igit an" each group o$ $our binary "igit . 3or e&ample%
7 3 ? 1111 1000 1101 0011 4 3

In thi e&ample% the econ" group o$ bit ha the !alue 1101% #hich corre pon" to 13 in "ecimal an" 4 in he&a"ecimal.

2,1

The $ollo#ing table inclu"e the $ir t eight po#er o$ t#o an" ome other number % repre ente" in e!eral "i$$erent ba e .

2,2

1e&a"ecimal 4ecimal 01 1 02 2 0, , 07 7 10 12 20 32 ,0 2, 70 127 03 1* 30 2,0 33 2**

Binary 9alue 00000001 20 00000010 21 00000100 22 00001000 23 00010000 2, 00100000 2* 01000000 22 10000000 25 00001111 11110000 11111111

2,3

3.*. S+stem Securit+

Sy tem ecurity i implemente" in mo t large y tem to pre!ent the the$t o$ program an" "ata% to pre!ent the unauthori e" u e o$ y tem % an" to re"uce the chance o$ acci"ental or "eliberate "amage to "ata.

3.8.1.

'ccess Control

Acce

control i implemente" at the

operating y tem le!el% #hich applie to running program an" acce ing "ata. Similar approache are u e" #ithin application program % an" #ithin "ataba e . Acce control generally in!ol!e "e$ining a!ailable $or each $unction. le!el % or on type $or each

the type o$ acce

Thi may be ba e" on acce group o$ $unction .

pro$ile #hich "e$ine the acce

2,,

Type o$ acce 0o acce

may inclu"e

9ie#/only acce 9ie# an" Ip"ate acce 4elete acce Eun rea"/only program Eun up"ate program

Acce

can al o be limite" to certain group

o$ recor" % uch the pro"uct "e!elope" #ithin a particular "i!i ion. Thi i le commonly "one% but can be u e" #hen a common proce ing y tem i u e" by e!eral in"epen"ent organi ation .

2,*

3.8.2.

:ser +-enti ication an-

Pass*or-s

6ogging into a y tem generally in!ol!e a u er I4 an" a pa #or". The u er I4 i"enti$ie the u er to the y tem% an" may be compo e" o$ the u er( initial or ome other co"e. +a #or" may be ran"omly generate"% either initially or permanently. +a #or" may be re tricte" to pre!ent the u e o$ common pa #or" uch a per onal name an" account number . The may inclu"e re'uiring a minimum number o$ character % an" po ibly at lea t one "igit an" one alphabetic character in the pa #or". +a #or" may e&pire a$ter a certain time perio"% a$ter #hich they mu t be change"% po ibly to a ne# pa #or" that ha not been pre!iou ly u e".

2,2

+a #or" may be encrypte" be$ore being tore" in a "ataba e or "ata $ile% to pre!ent the te&t $rom being !ie#e" u ing an e&ternal program. A logon e ion may terminate automatically a$ter a perio" o$ time #ithout acti!ity% to re"uce the chance o$ acce logge" in. being gaine" till through an unatten"e" terminal that i

3.8.3.

%ncryption o Data

4ata can be encrypte". Thi in!ol!e changing the "ata into another $ormat o that the in$ormation cannot be !ie#e" or i"enti$ie". ;ncryption i not #i"ely u e" in tan"ar" y tem . 1o#e!er% encryption i u e" in high/ ecurity "ata tran $er % an" in general/

2,5

u e $acilitie

uch a net#ork y tem an"

"igital mobile telephone communication . 9ariou algorithm are a!ailable $or encryption. The e range $rom imple techni'ue to comple& calculation . @ne imple approach i to map each input character to a "i$$erent output character. Thi i a imple metho"% ho#e!er it coul" be u e" $or toring mall item uch a pa #or" .

3or e&ample% input "ata coul" be tran late" to output "ata u ing a $ormula or a lookup table. Thi #oul" be a one/to/one mapping. A table #oul" contain 2*2 entrie $or one byte o$ "ata% an" coul" be u e" to encrypt te&t or binary "ata. The $ollo#ing table ho# the $ir t $e# entrie in a mapping table.

Input )haracter

@utput )haracter

2,7

A B ) 4 0 1 2 D Y G

F L 4 ; : ) > B 3

4ata #oul" be unencrypte" by u ing the table in re!er e.

3.8.4.

+n-ivi-ual )iles

Small in"i!i"ual $ile % uch a a "ata $ile create" by a o$t#are tool or a con$iguration $ile% may ha!e a pa #or" embe""e" #ithin the $ile. The o$t#are tool #oul" generally prompt $or the pa #or" #hen an attempt #a ma"e

2,:

to open the $ile% an" #oul" "i allo# acce unle the correct pa #or" #a entere".

3.8.5.

%&ternal 'ccess

4ata can generally be acce e" in other% o$ten impler% #ay that are e&ternal to an application. Thi inclu"e copying $ile an" acce ing the "ata at another location% or acce ing "ataba e "irectly through a "ataba e 'uery inter$ace. The e other metho" #oul" al o be a""re e" in a ecurity arrangement. 3or e&ample% acce to a "ataba e 'uery inter$ace may be limite" to rea"/only acce % #ith the table toring the u er account an" pa #or" ha!ing no acce .

2*0

3.1,. Speed - Efficienc+

3.19.1. %&ecution Spee3.19.1.1.'ccessin( -ata

A igni$icant proportion o$ proce ing time i in!ol!e" in acce ing "ata. Thi may inclu"e earching li t locate a "ata item% or e&ecuting a earch $unction #ithin a "ata tructure.

3.19.1.1.1. 'ccess 0et1o-s

The $un"amental acce $ollo#ing.

metho" inclu"e the

2*1

3.19.1.1.1.1. Direct 'ccess

4irect acce

in!ol!e u ing an in"i!i"ual "ata.

"ata !ariable or in"e&ing an array element. Thi i the $a te t #ay to acce

In a $ully compile" program% both the e operation re'uire only a $e# machine co"e in truction . In contra t% a earch o$ a li t o$ 1%000 item may in!ol!e thou an" o$ machine co"e operation .

3.19.1.1.1.2. Se$i5Direct 'ccess

4ata can be acce e" "irectly u ing mall integer !alue a array in"e&e . 1o#e!er% "ata cannot be acce e" "irectly by u ing a tring% $loating point number or #i"e/

2*2

ranging integer !alue to re$er to the "ata item. 4ata tore" u ing tring an" other key can be acce e" in e!eral tep by u ing a "ata tructure uch a a ha h table. Acce time to a ha h table entry i lo#er

than acce

to an array% a the ha h $unction

!alue mu t be calculate". 1o#e!er% thi i a $i&e" "elay an" i not a$$ecte" by the number o$ item Acce tore" in the table. time can lo# a a ha h table

become $ull.

3.19.1.1.1.3. 4inary Searc1

A binary earch can locate an item in a orte" array in an a!erage o$ appro&imately log2(n)/ 1 compari on .

2*3

Thi i generally the imple t an" $a te t #ay to locate "ata u ing a tring re$erence. Inle the "ata iAe i e&tremely large% uch

a o!er one million array element % then the o!erhea" in calculating a ha h table key i likely to be higher than the number o$ compari on in!ol!e" in a binary earch. A binary earch i uitable $or a tatic li t

that ha been orte". 1o#e!er% i$ item are a""e" to the li t or "elete" $rom the li t% thi approach may not be practical. ;ither a complete re/ ort #oul" be re'uire"% or an in ertion into a orte" li t coul" be u e" #hich #oul" in!ol!e an nN2 a!erage up"ate time. In the e ca e % a ha h table or a el$/ balancing tree coul" be u e".

2*,

3.19.1.1.1.4. %&1austive Searc1

An e&hau ti!e earch in!ol!e until the "ata item i locate".

imply

canning the li t $rom the $ir t item on#ar"

Thi take an a!erage o$ nN2 compari on to locate an item.

3.19.1.1.1.5. 'ccess 0et1o- Co$parison

The a!erage number o$ compari on in!ol!e" in locating a ran"om element i li te" in the table belo#.

;ntrie 3ull Scan

4irect In"e&

Binary Search ( orte")

(un orte") 100 *0 1%000 *00 1 :.0 1 *.2

2**

10%000 *%000 100%000 *0%000 1%000%000 *00%000 10%000%000 *%000%000

1 1 1 1

12.3 1*.2 17.: 22.3

The "irect in"e& metho" can be u e" #hen the item i re$erence" by an in"e& number. 8hen the item i re$erence" by a tring key% an alternati!e metho" can be u e". The ha h table acce i not ho#n. o!erhear" that

1o#e!er% it ha a $i&e" acce

coul" be o$ the appro&imate or"er o$ the 20/ compari on binary earch operation. The binary earch metho" can only be u e" #ith a orte" li t. Sorting i a lo# operation. Thi metho" #oul" be uitable $or "ata that i rea" at the beginning o$ program e&ecution an" can be orte" once.

2*2

The $ull earch i e&tremely lo# an" #oul" not be practical $or li t o$ more than a $e# hun"re" item #here repeate" can #ere in!ol!e".

3.19.1.1.2. Ta(s

Searching by tring !alue can be a!oi"e" in ome ca e by a igning temporary numeric tag to "ata item $or internal proce ing. 3or e&ample% the primary an" $oreign key o$ "ataba e recor" may be ba e" on tring $iel" % or #i"ely/ranging numeric co"e . 8hen !alue are rea" into array $or internal calculation % each entry coul" be a igne" a mall number% uch a the array in"e&% a a tag.

2*5

@ther "ata tructure #oul" then u e the tag to re$er to the "ata% rather than the tring key. Thi #oul" allo# that "ata to be acce e" "irectly u ing a "irect array in"e&.

3.19.1.1.3. +n-irect '--ressin(

In ca e #here a "ata item cannot be acce e" "irectly u ing a numeric in"e& or a binary earch on a orte" array% an in"irect acce ing metho" may be able to be u e". Thi approach #oul" apply #hen there #a a nee" to earch a table by more than one $iel"% or #hen a numeric in"e& !alue "i" not map "irectly to an array entry% uch a an in"e& into a compacte" table. Thi metho" in!ol!e "e$ining an a""itional array that i in"e&e" by the earch item% an" contain an entry that peci$ie the in"e& into the main array.

2*7

In the ca e o$ an in"irect in"e&% uch a a mapping into a compacte" table% the array #oul" be in"e&e" by the original in"e& an" #oul" contain the in"e& !alue $or the compacte" table. In the ca e o$ a tring earch% the array #oul" be orte" by the tring $iel". Thi #oul" be earche" u ing a binary earch metho" an" #oul" contain the in"e& into the main table. Thi approach coul" al o be u e" #hen the main table containe" large block o$ "ata% an" mo!ing the "ata "uring a ort operation #oul" be a lo# proce .

2*:

3.19.1.1.4. Sublists

In ca e #here earching li t i una!oi"able% the earch time may be re"uce" i$ the "ata i broken into ub/ ection . Thi i e$$ecti!ely a partial ort o$ the "ata. 3or e&ample% a et o$ "ata may contain ten ample $rom ten location % $or a total o$ 100 "ata item . Searching thi "ata #oul" in!ol!e an a!erage o$ *0 compari on . 1o#e!er% i$ the ample #ere allocate" to in"i!i"ual location % then earching the location #oul" take an a!erage o$ * compari on % an" earching the ample #oul" al o in!ol!e an a!erage o$ $i!e compari on % $or a total o$ 10 a!erage compari on . A""itionally% although one o$ the other approache uch a "irect in"e&ing may not

220

be practical $or the $ull "ata et% it may be applicable to one o$ the tage in the ub/li t tructure.

3.19.1.1.5. ;eys

8here "ata i locate" by earching $or e!eral "i$$erent "ata item % the "ata item can be combine" into a ingle te&t key. Thi key can then be u e" to locate the "ata u ing one o$ the tring in"e& metho" % uch a a ha h table or a binary earch on a orte" array.

221

3.19.1.1.6. 0ultiple 'rray +n-e&es

8here "ata i i"enti$ie" by e!eral in"epen"ent numeric item % a multiple "imen ion array can be u e" to tore the "ata% #ith each numeric item being u e" to in"e& one o$ the array "imen ion . Thi allo# $or "irect in"e&ing% ho#e!er a large !olume o$ memory may be u e". The memory con ume" i e'ual to the iAe o$ the array item multiplie" by the iAe o$ each o$ the "imen ion . 3or e&ample% i$ the $ir t "imen ion co!ere" a range o$ 3000 !alue % the econ" "imen ion co!ere" 70 !alue an" the thir" "imen ion co!ere" *00 !alue % then the array #oul" contain 120 million entrie . Thi problem may be re"uce" by compacting the table to remo!e blank entrie an" u ing a eparate array to in"irectly in"e& the main table% or by u ing numeric !alue $or ome

222

"imen ion an" locating other !alue by earching the "ata.

3.19.1.1.!. Cac1in(

)aching i u e" to tore "ata temporarily $or $a ter acce . Thi i u e" in t#o conte&t . )aching may be u e" to tore "ata that ha been retrie!e" $rom a lo#er acce a "ataba e or "i k $ile. Al o% caching can be u e" to tore pre!iou ly calculate" !alue that may be u e" in $urther proce ing. Thi particularly applie to calculation that re'uire" rea"ing "ata $rom "i k in or"er to calculate the re ult. A tructure" et o$ re ult can be tore" in an array. 8here a large number o$ "i$$erent torage% uch a toring "ata in memory that ha been retrie!e" $rom

223

type o$ "ata are tore"% a tructure uch a a ha h table can be u e". )aching o$ calculate" re ult can al o be tore" in temporary "ataba e . 8here input $igure ha!e change"% the cache" re ult #ill not longer be !ali" an" houl" be "i car"e"% other#i e incorrect !alue may be u e" in other calculation .

3.19.1.2.'voi-in( %&ecution

;&ecution pee" can be increa e" by a!oi"ing e&ecuting tatement unnece arily.

3.19.1.2.1. 0ovin( co-e

Mo!ing co"e in i"e -i$. tatement an" out i"e loop may increa e e&ecution pee".

22,

I$ the re ult o$ a tatement are only u e" in certain circum tance % then placing an -i$. tatement aroun" the co"e may re"uce the number o$ time that the co"e i e&ecute". Thi coul" al o in!ol!e mo!ing the tatement in i"e an e&i ting -i$. tatement. Mo!ing co"e out i"e a loop ha a imilar e$$ect. I$ a tatement return the ame re ult $or each iteration o$ the loop% then the co"e coul" be mo!e" out i"e the loop to a pre!iou po ition. Thi #oul" re ult in the tatement being e&ecute" only once% rather than e!ery time that the loop #a repeate".

3.19.1.2.2. Repeate- Calculation

In ome ca e a calculation i repeate" but it cannot be mo!e" out i"e a loop.

22*

Thi can occur #ith ne te" loop $or e&ample. 8here a tatement #ithin the inner loop re$er to the inner loop !ariable% it cannot be mo!e" out i"e the inner loop a it !alue may be "i$$erent #ith each iteration o$ the loop. 1o#e!er% i$ thi tatement "oe not re$er to

the outer loop !ariable% then the entire cycle o$ !alue #ill be repeate" $or each iteration o$ the outer loop. Thi ituation can be a""re e" by inclu"ing

a eparate loop be$ore the ne te" loop% to cycle through the inner loop once an" tore the re ult o$ the tatement in a temporary array. The e array !alue coul" then be u e" in the inner ne te" loop.

222

Thi may ha!e igni$icant impact on the e&ecution time #hen the tatement inclu"e a ubroutine call to a lo# $unction an" the outer loop i e&ecute" a large number o$ time .

3.19.1.3.Data types 3.19.1.3.1. Strin(s

+roce ing #ith tring i !ariable .

igni$icantly

lo#er than proce ing #ith numeric

)opying tring $rom one !ariable to another% an" per$orming tring operation may in!ol!e memory allocation an" copying in"i!i"ual character #ithin the tring In contra t% etting a numeric !alue can be "one #ith a ingle in truction.

225

In general e&ecution pee" may be igni$icantly increa e" i$ numeric !alue are u e" $or internal proce ing rather than tring co"e . 3or e&ample% "ate % tag to i"enti$y recor" % $lag an" proce ing option coul" all be repre ente" u ing numeric !ariable rather than tring co"e . 0umeric "ata an" "ate rea" into a y tem may be in a tring $ormat% in #hich ca e the "ata can be con!erte" to a numeric "ata type $or torage an" proce ing.

3.19.1.3.2. <u$eric Data

Integer "ata type generally pro!i"e the $a te t e&ecution pee".

227

3loating point number calculation may al o be $a t% a har"#are generally upport $loating point calculation "irectly. 1o#e!er% many language upport other

numeric "ata type that may be 'uite lo#% i$ the arithmetic i implemente" internally a a et o$ ubroutine . The numeric "ata type that are compile" into "irect har"#are in truction !arie #ith the language% har"#are plat$orm an" language implementation.

3.19.1.4.'l(orit1$s

The choice o$ algorithm can ha!e a igni$icant impact on e&ecution pee". In ca e #here thi a!ailable memory i re tricte"% the choice o$ algorithm can al o

22:

impact on the !olume o$ memory u e" $or "ata torage. In ome ca e % alternati!e algorithm to pro"uce the ame re ult may "i$$er in e&ecution pee" by many or"er o$ magnitu"e. Sorting i an e&ample o$ thi . Sorting an array o$ one million item u ing the bubble ort algorithm #oul" in!ol!e appro&imately one trillion operation % #hile u ing the 'uick ort algorithm may in!ol!e appro&imately 20 million operation . In many ca e e!eral "i$$erent algorithm

can be u e" to calculate a particular re ult. Algorithm that can input "ata #ithout backtracking may be $a ter than algorithm that in!ol!e backtracking. 3or e&ample% a te t earching metho" that u e" a $inite tate automaton to can the te&t

250

in a ingle pa backtracking.

may be $a ter than an

alternati!e algorithm that in!ol!e"

Some algorithm make a ingle pa pa e .

through

the input "ata% #hile other in!ol!e multiple

I$ the complete proce e can be per$orme" "uring a ingle pa then $a ter e&ecution may be achie!e"% particularly #hen "ataba e acce e are in!ol!e". 1o#e!er% in ome ca e a proce #ith e!eral imple pa e that u e a may be $a ter than a proce ingle comple& pa .

3.19.1.5.Run5ti$e processin(

In ome ca e % a tructure can be compile" or tran late" into another tructure that can be proce e" more 'uickly.

251

3or e&ample% a te&t $ormula may peci$y a particular calculation. +roce ing thi $ormula may in!ol!e i"enti$ying the in"i!i"ual element #ithin the $ormula% par ing the tring to i"enti$y bracket an" the or"er o$ operator % an" $inally calculating the re ult. I$ the calculation #ill be applie" to many "ata item % then the e&pre ion can be tran late" into a po t$i& e&pre ion an" tore" in an internal numeric co"e $ormat. Thi #oul" enable the e&pre ion to be "irectly e&ecute" u ing a tack. Thi #oul" be a relati!ely $a t operation an" #oul" be igni$icantly $a ter than calculating the original e&pre ion $or each "ata item. Thi proce coul" be e&ten"e" to the ca e o$

a macro language u ing !ariable an" control $lo#% by generating internal interme"iate co"e an" e&ecuting the co"e u ing a imple loop an" a tack.

252

Another e&ample o$ eparate run/time proce ing #oul" in!ol!e algorithm that generate $inite tate automaton $rom pattern uch a language grammar or te&t earch pattern . @nce the $inite tate automaton ha been generate"% it can be u e" to proce the input at a high rate% a a ingle tran ition i per$orme" $or each input character an" no backtracking i in!ol!e".

3.19.1.6.Co$ple& Co-e

8hen a ection o$ co"e ha been ub<ect to a large number o$ change an" a""ition % the proce ing can become !ery comple&. Thi may in!ol!e" multiple ne te" loop % re/ canning o$ "ata tructure an" comple& control $lo#. The e change may lea" to a igni$icant "rop in e&ecution pee".

253

In the e ca e % re/#riting the co"e an" changing the "ata tructure may lea" to a "ra tic re"uction in comple&ity an" an increa e in e&ecution pee"

3.19.1.!.<u$eric Processin(

0umeric proce ing i generally $a ter #hen the "ata i loa"e" into program array be$ore the calculation commence . 4ata may be loa"e" $rom "ataba e % "ata $ile % or more comple& program "ata tructure . ;&ecution pee" may be increa e" i$ calculation are not repeate" multiple time . Thi ituation can al o ari e #ithin e&pre ion . 3or e&ample% an e&pre ion o$ the $orm -& ? a D b D c. may appear #ithin an inner proce ing loop. 1o#e!er% i$ part o$ the

25,

e&pre ion "oe not change #ithin the inner loop% uch a the -b D c. component% then thi calculation can be mo!e" out i"e the loop. Thi may lea" to an e&pre ion o$ -" ? b D c. in an outer loop% an" -& ? a D ". in the inner loop. 8here a calculation #ithin an inner loop i e$$ecte" by the inner loop but not the outer loop% then a eparate loop can be a""e" be$ore the main loop to generate the et o$ re ult once% an" tore then in a temporary array $or u e #ithin the inner loop. Special ca e #ithin the tructure o$ the calculation an" "ata may enable the number o$ calculation to be re"uce". 3or e&ample% i$ a matri& i triangular% o that the "ata !alue are ymmetrical aroun" the "iagonal% then only the "ata on one i"e o$ the "iagonal nee" to be calculate".

25*

A another e&ample% ome part o$ the calculation may be able to be per$orme" u ing integer rather than $loating point operation . 1o#e!er% the con!er ion time bet#een the integer an" $loating point $ormat #oul" al o a$$ect the "i$$erence in e&ecution time . I$ the "ata i likely to contain a large number o$ !alue e'ual to Aero or one% then the e input !alue can be checke" be$ore per$orming unnece ary multiplication or a""ition . Integer operation that in!ol!e multiplication or "i!i ion by po#er o$ t#o can be per$orme" u ing bit hi$t in tea" o$ $ull arithmetic operation . An integer "ata item can be multiplie" by a po#er o$ t#o by hi$ting the bit to the le$t% by a number o$ place that i e'ual to the e&ponent o$ the multiplier.

252

In language that upport pointer arithmetic% tepping through an array by incrementing a pointer may be $a ter than u ing a loop #ith an array in"e&. In ca e #here an e&tremely large number o$ calculation are per$orme" on a et o$ numeric "ata% e!eral tep may lea" to light per$ormance increa e . Acce ing e!eral ingle/"imen ional array may be lightly $a ter than acce ing a multiple "imen ional array% a one le calculation i in!ol!e" in locating an element po ition. 8hen multiple "imen ional array are u e"% acce may be lightly $a ter i$ the array iAe are po#er o$ t#o. Thi i "imen ion

"ue to the $act that the multiplication re'uire" to locate an element po ition can be per$orme" u ing a bit hi$t% #hich may be $a ter than a $ull multiplication.

255

3.19.1.".#an(ua(e an- %&ecution %nviron$ent

In e&treme ca e an increa e in e&ecution pee" may in!ol!e changing the program to a "i$$erent programming language or "e!elopment en!ironment. 3ully compile" co"e that pro"uce an e&ecutable $ile i generally the $a te t #ay to e&ecute a program. Some language an" "e!elopment plat$orm are ba e" on interpreter or u e partial compilation an" a run/time interpreter to e&ecute the co"e. The e approache may be ub tantially lo#er than u ing a $ull compiler.

257

)ompiler o$ten implement optimi ing $eature to increa e e&ecution pee" by per$orming action uch a con!erting multiplication by po#er o$ t#o into bit hi$t % automatically mo!ing co"e out i"e loop % an" generating peci$ic machine co"e in truction $or peci$ic ituation . The le!el an" type o$ optimi ation may be electable #hen a compilation i per$orme".

3.19.1.8.Database 'ccess

+roce e that are tructure" to a!oi" re/ rea"ing "ataba e recor" #ill generally e&ecute more 'uickly than proce e that rea" recor" more than once. 8here a recor" #oul" be rea" many time "uring a proce % the recor" can be rea" once an" tore" in a recor" bu$$er or program !ariable .

25:

8hen a one/to/many link i being proce e"% i$ the chil" recor" are rea" in the or"er o$ the parent recor" key% not the chil" recor" key% then each parent recor" #oul" only nee" to be rea" once. +roce ing the chil" recor" in the or"er o$ the chil" recor" key may re'uire re/rea"ing a parent recor" $or e!ery chil" recor". Selecting a proce ing or"er that re'uire only a ingle pa alternati!e proce through the "ata #oul" that u e" multiple pa e generally re ult in $a ter e&ecution that an through the "ata% or that re/rea" recor" #hile proce ing one ection o$ the "ata.

3.19.1.19. Re-un-ant Co-e

In co"e that ha been hea!ily mo"i$ie"% there may be ection o$ co"e that calculate a

270

re ult or per$orm proce ing that i ne!er u e". A""itionally% ome re ult may be pro"uce" an" then o!er#ritten at a later tage by other $igure % #ithout the original re ult ha!ing been acce e". Eemo!ing re"un"ant co"e can impli$y the co"e an" increa e e&ecution pee".

3.19.1.11. 4u(s

+er$ormance problem may ometime be "ue to bug . A bug may not a$$ect the re ult o$ a proce % but it may re ult in a "ataba e recor" being re/rea" multiple time % a loop e&ecuting a larger number o$ time than i nece ary% cache" "ata being ignore"% or ome other problem.

271

I ing an e&ecution pro$iler or a "ebugger may i"enti$y per$ormance problem in une&pecte" ection o$ co"e "ue to bug .

3.19.1.12. Special Cases

In ome calculation or proce e % there i a particular proce than coul" be "one more 'uickly u ing an alternati!e metho". In the e ca e % the alternati!e approach may al o be inclu"e"% an" u e" $or the particular ca e that it applie to. 3or e&ample% a ubroutine to calculate &y coul" implement a tan"ar" numerical metho" to calculate the re ult. 1o#e!er% thi may be a lo# calculation% an" in a particular application it may be the ca e that the !alue o$ -y. i o$ten 2% to calculate the 'uare o$ a number.

272

In thi ca e the !alue o$ -y. coul" be checke" in the ubroutine% an" i$ it i e'ual to 2 then a imple multiplication o$ -y D y. coul" be u e" in place o$ the general calculation. Another e&ample concern li t i ometime orting. In a

comple& application it may be the ca e that a orte" #hen it i alrea"y in a orte" or"er. The ort routine coul" check $or the pecial ca e that the input "ata #a alrea"y orte"% in #hich ca e the $ull orting proce be nece ary. Special ca e may al o apply to caching% rather than a particular $igure or et o$ "ata. 3or e&ample% a ubroutine to return the ne&t item in a li t a$ter a peci$ie" po ition coul" retain the !alue o$ the la t po ition returne"% a in many ca e a imple can o$ the li t #oul" not

273

#oul" be "one an" thi #oul" a!oi" the nee" to re/e tabli h the tarting po ition.

3.19.1.13. Per or$ance 4ottlenec2s

In ome ca e the ma<ority o$ the proce ing time may be pent in a mall ection o$ co"e. Thi may occur #ith ne te" loop $or e&ample. I$ an outer loop iterate 1000 time an" the inner loop al o iterate 1000 time % then the co"e #ithin the inner loop #ill be e&ecute" one million time . In"irect ne te" loop can occur #hen a ubroutine i calle" $rom #ithin a loop% an" the ubroutine it el$ contain a loop. Thi #oul" initially appear to be t#o ingle/ le!el loop % ho#e!er becau e the ubroutine i calle" $rom #ithin one o$ the loop % the number o$ time that the co"e #oul" be

27,

e&ecute" #oul" be the pro"uct o$ the number o$ loop iteration % not the um. In ome "e!elopment en!ironment an e&ecution pro$iling program can be u e" to "etermine the proportion o$ e&ecution time that i pent #ithin each ection o$ the co"e.

In ome ca e a ne te" loop may be a!oi"e" by changing the or"er o$ ne ting. 3or e&ample% i$ an array i loop an" another array i canne" u ing a canne" #ithin that

loop% i$ the $ir t array can be "irectly acce e" u ing an array in"e&% then a ne te" loop coul" be a!oi"e" by canning the econ" array $ir t% an" u ing the "irect in"e& to acce the $ir t array.

Al o% ub/li t coul" be e&pan"e" to pro!i"e a ingle complete et o$ "ata combination % rather than inclu"ing a main et o$ "ata an" multiple ub/li t o$ relate" in$ormation.

27*

3.19.2. 0e$ory :sa(e 3.19.2.1.Data :sa(e 3.19.2.1.1. +n-ivi-ual variables

0umeric !ariable u e le

memory pace

than tring . 8here po ible% replacing tring !alue in table an" array #ith a number co"e may re"uce memory u age. Integer numeric !ariable generally occupy le memory pace than other numeric "ata type . Al o% $loating point "ata type may be a!ailable in e!eral le!el o$ preci ion. )hanging an array o$ "ouble/preci ion $loating point !alue to ingle/preci ion !ariable may hal!e the memory u age% although thi #oul" only be practical #hen the ingle/preci ion $ormat containe" an

272

a"e'uate number o$ "igit o$ preci ion $or the "ata being tore". 4ata type uch a "ate may be able to be

tore" a numeric !ariable rather than u ing a "i$$erent internal $ormat that con ume more memory.

3.19.2.1.2. 4it$aps

8here e!eral Boolean $lag are u e"% the e can be tore" a in"i!i"ual bit u ing a bitmap metho"% rather than u ing a $ull integer !ariable $or each in"i!i"ual $lag. In ome application % uch a graphic proce ing% in"i!i"ual "ata item may not u e a number o$ bit that i a multiple o$ a tan"ar" eight/bit byte. 3or e&ample% eight eparate !alue can be repre ente" u ing a et o$ three bit . I$ a large

275

!olume o$ "ata con i te" o$ number #ith three/bit patten % then e!eral "ata item coul" be tore" #ithin a particular byte. Thi #oul" in!ol!e a calculation to "etermine the location o$ a three/bit !alue #ithin a block o$ "ata% an" the u e o$ bitmap to e&tract the three/bit co"e $rom an eight/bit "ata item.

3.19.2.1.3. Co$pactin( Structures

In ca e #here tructure contain "uplicate" entrie or blank entrie % the tructure may be able to be compacte". Thi can be "one by replacing the multiple "uplicate" entrie #ith a ingle entry% remo!ing blank entrie % an" u ing a eparate array to map the original array in"e&e to the in"e& !alue into the compacte" array.

277

Thi i an in"irect in"e&ing metho".

3.19.2.1.4. Strin( tables

In ca e #here a particular tring !alue may appear multiple time #ithin a et o$ "ata% the tring can be tore" in a eparate array% an" the entrie in the original "ata tructure can be change" to numeric in"e&e into the tring table array. Thi may al o increa e proce ing pee" #hen entrie are mo!e" an" copie" in the main "ata tructure.

3.19.2.2.Co-e Space :sa(e 3.19.2.2.1. Tas2 lan(ua(es

27:

In ome ca e a imple language may be able to be "e!elope" that contain in truction relating to the ta k being per$orme". Statement in thi language coul" then be compile" into numeric co"e an" tore" a "ata. At run time% a imple loop coul" then proce proce . 3or e&ample% in an in"u trial control application% a et o$ in truction $or opening !al!e % rea"ing en or etc coul" be "e!elope". The proce control it el$ coul" be #ritten u ing the e in truction % an" a mall run/time interpreter coul" e&ecute the in truction to operate the proce . Thi i the approach u e" in central proce ing unit that u e microco"e. In thi ca e% the program in truction are e&ecute" by a imple language #ithin the chip it el$. the in truction to e&ecute the

2:0

3.19.2.2.2. Table -riven co-e

Table "ri!en co"e can be u e" to re"uce co"e !olume in ome application . An increa e in "ata u age #oul" occur% ho#e!er thi #oul" generally be le in truction . A table "ri!en routine in!ol!e toring a li t tring $or than the "ecrea e in the memory pace u e" $or the program

o$ $i&e" !alue in an array% uch a

a menu "i play or !alue $or a ubroutine call% an" u ing a loop o$ co"e to can the array an" call a ubroutine $or each entry in the array. Thi replace multiple in"i!i"ual line o$ co"e.

2:1

". The Craft of Programming ".1. Programming Languages

4.1.1.

'sse$bler

Machine co"e i the internal co"e that the computer( proce or e&ecute . In pro!i"e only ba ic operation % uch a arithmetic #ith number % mo!ing "ata bet#een memory location % comparing number an" <umping to "i$$erent point in the program ba e" on AeroNnon/Aero con"ition . A embly co"e i the "irect repre entation o$ machine co"e in a rea"able% te&t $ormat. A embler ha no ynta& an" i e'uence o$ in truction . A embly co"e i the $a te t #ay to implement a proce"ure ho#e!er it ha e!ere limitation . 2:2 ome imply a

;ach proce or u e a "i$$erent et o$ machine co"e in truction % o an a embly language program mu t be completely re/ #ritten to run on a computer that u e a "i$$erent internal proce or. A embler i a !ery ba ic language an" a large !olume o$ co"e mu t be #ritten to accompli h a particular $unction. A embly language i ometime u e" in

controlling har"#are an" in"u trial machine control% an" in application #here pee" i critical% $or e&ample the routing o$ "ata packet in a high/ pee" net#ork.

4.1.2.

T1ir- ,eneration #an(ua(es

Thir"/generation language (3=6)% re$er to a range o$ programming language that are

2:3

imilar in tructure an" are in #i"e prea" u e. The e language operate at the le!el o$ "ata !ariable % ubroutine % -i$. tatement % loop etc. A large proportion o$ all program are #ritten u ing thir" generation language .

4.1.2.1. )ortran

3ortran an" )obol #ere the $ir t #i"ely/u e" programming language % #ith )obol being u e" $or bu ine "ata proce ing an" 3ortran $or numeric calculation in engineering an" cienti$ic application . 3ortran i an acronym $or -3@Emula TEA0 lator. 3ortran ha le trong $acilitie $or calculation an" #orking #ith number % but i u e$ul $or tring an" te&t proce ing.

2:,

4.1.2.2. 4asic

Ba ic #a initially "e igne" $or teaching 3ortran. Ba ic i an acronym $or -Beginner All +urpo e Symbolic In truction )o"e.. Ba ic ha $le&ible tring han"ling $acilitie an" rea onable numeric capabilitie .

4.1.2.3. C

) #a original "e!elope" a a y tem /le!el language an" #a a ociate" #ith the "e!elopment o$ the I0IV operating y tem. ) i $a t an" po#er$ul% an" make e&ten i!e u e o$ pointer . ) i u e$ul $or "e!eloping comple& "ata tructure an" algorithm . 1o#e!er% proce ing tring in ) i cumber ome.

2:*

4.1.2.4. Pascal

+a cal #a initially "e!elope" $or teaching computer cience cour e . +a cal i name" a$ter the mathematician Blai e +a cal% #ho in!ente" the $ir t mechanical calculating machine o$ mo"ern time . +a cal i a highly tructure" language that ha trict type checking an" multiple le!el o$ ubroutine an" "ata !ariable cope.

4.1.3.

4usiness /rientate- #an(ua(es

4.1.3.1. Cobol

)obol operate at a imilar le!el to thir"/ generation language % ho#e!er it i generally groupe" eparately a the tructure o$ cobol i 'uite "i$$erent $rom other language .

2:2

)obol i an acronym $or -)@mmon Bu ine @rientate" 6anguage.. )obol i "e igne" $or "ata proce ing% uch a per$orming calculation an" generating report #ith large !olume o$ "ata. 9a t amount o$ cobol co"e ha!e been #ritten an" are particularly u e" in banking% in urance an" large "ata proce ing en!ironment . In cobol% "ata $iel" are "e$ine" a a tring o$ in"i!i"ual character % an" each po ition in the !ariable may be "e$ine" a an alphabetic% alphanumeric or numeric character. Arithmetic can be per$orme" on numeric item . +roce ing i accompli he" #ith proce"ural tatement . )obol tatement u e ;ngli h/ like entence an" cobol co"e i ea y to rea"% ho#e!er a cobol program can $ill a larger !olume o$ te&t pace that an e'ui!alent program in an alternati!e language.

2:5

)obol i clo ely intert#ine" #ith main$rame operating y tem an" "ataba e y tem % re ulting in e$$icient proce ing o$ large !olume o$ "ata.

4.1.3.2. )ourt1 ,eneration #an(ua(es =4,#>

3ollo#ing the increa ing comple&ity o$ computer y tem in the 1:50( an" 70( % attempt #ere ma"e to "e$ine ne# higher/ le!el language that coul" be u e" to "e!elop "ata proce ing application u ing $ar le co"e than pre!iou language . The e language in!ol!e "e$ining creen an" report layout % an" inclu"e a minimum amount o$ co"e $or peci$ying $ormula . 3ourth/generation language % al o kno#n a application generator % are #i"ely u e" $or

2:7

the "e!elopment o$ bu ine large/ cale en!ironment .

application in

1o#e!er% #hile thir"/generation language can be a"apte" to any programming ta k% $ourth/generation language are peci$ic to bu ine "ata proce ing application .

=enerating the application may in!ol!e running a proce that pro"uce ource co"e in a language uch a )obol or ). Thi output co"e #oul" then be compile" to pro"uce the application it el$. Alternati!ely% the $ormat may be compile" into binary "ata $ile an" a run/time $acility may be u e" to "i play the creen an" operate the application.

4.1.4.

/b3ect5/rientate- #an(ua(es

2::

@b<ect/orientate" language ha!e e&i te" ince the earlie t "ay o$ computing in the 1:20( % ho#e!er they only gre# into #i"e prea" u e in the 1::0( . Many ob<ect/orientate" language are e&ten ion o$ thir"/generation language .

4.1.4.1. C??

)CC i a ma<or @@ language. )CC i an e&ten ion o$ ). Some o$ the $acilitie o$ )CC inclu"e the ability to "e$ine ob<ect % kno#n a cla e % containing "ata an" relate" ubroutine % kno#n a metho" . The e cla e may operate at e!eral le!el an" ub/cla e can be "e$ine" that inclu"e the "ata an" operation o$ other cla ob<ect .

300

)CC al o upport operator o!erloa"ing% #hich allo# operator uch a a""ition to be applie" to ne#ly/create" "ata type .

4.1.4.2. @ava

Fa!a i an ob<ect orientate" language "e!elope" $or u e in internet application . It ha a ynta& that i imilar to )% but i not ba e" on a pre!iou language "e ign. Fa!a inclu"e "ynamic memory allocation $or creating an" "eallocating ob<ect % an" a trictly "e$ine" et o$ cla acro librarie ( ubroutine ) that i inten"e" to be portable all operating en!ironment .

Fa!a generally run in a -!irtual machine. en!ironment $or portability an" ecurity rea on .

301

4.1.5.

Declarative #an(ua(es

4.1.5.1. Prolo(

+rolog i a "eclarati!e language. A prolog program con i t o$ a et o$ $act % rather than a et o$ tatement that are e&ecute" in or"er. +rolog i u e" in "eci ion/making an" goal/ eeking application . @nce the program ha been "e$ine"% the prolog interpreter then u e the "e$ine" $act in an attempt to ol!e the problem that i pre ente". 3or e&ample% a prolog program may inclu"e the mo!e o$ a che game. The prolog interpreter #oul" then u e the $act that #ere "e$ine" in the program to "etermine the mo!e in a computer che game.

302

4.1.5.2. S6#

SK6% Structure" Kuery 6anguage% i a "ata 'uery language that i u e" in relational "ataba e . SK6 i a "eclarati!e language an" group o$ recor" are "e$ine" a a et% #hich can be retrie!e" or up"ate". SK6 tatement may be e&ecute" in e'uence ho#e!er the actual election o$ recor" i ba e" on the tructure o$ the election tatement.

4.1.5.3. 4<) ,ra$$ars

A Backu 0aur 3orm grammar i a language that i u e" to peci$y the tructure o$ other language .

303

The ynta& o$ ome programming language can be $ully peci$ie" u ing a et o$ tatement #ritten a a B03 grammar. B03 grammar are "eclarati!e an" peci$y the tructure an" pattern o$ a language.

4.1.6.

Special5Purpose #an(ua(es

4.1.6.1. #isp

6i p i a highly unu ual language that #a "e!elope" early in the hi tory o$ computing% an" u e" in arti$icial intelligence re earch. All "ata item in 6i p are tore" a li t . All proce ing in 6i p in!ol!e canning li t .

The ynta& o$ 6i p i !ery imple% but in!ol!e ma i!e amount o$ bracket a li t are "e$ine" #ithin li t #hich are #ithin other li t .

30,

The program co"e it el$ i al o tore" in li t % a #ell a the "ata item .

4.1.6.2. 'P#

-A +rogramming 6anguage.% A+6 i a language that #a "e!elope" $or actuarial calculation in!ol!ing in urance an" $inance calculation . A+6 i highly mathematical an" inclu"e operator $or matri& calculation etc. A+6 co"e i !ery "i$$icult to rea" an" the A+6 character et inclu"e a #i"e range o$ pecial character % uch a re!er e arro# Z% that are not u e" in other programming language or general te&t. A+6 make e&ten i!e u e o$ a large number o$ operator an" ymbol an" contain $e# key#or" .

30*

4.1.6.3. Sy$bolic Calculation #an(ua(es

Some package $or e!aluating an" "i playing mathematical $unction inclu"e ymbolic calculation language . The e package recogni e mathematical e'uation % an" can re/arrange e'uation an" ol!e the e'uation $or a particular !ariable. In contra t% tan"ar" programming language "o not recogni e $ull mathematical e'uation % but recogni e e&pre ion in tea". 3or e&ample% the tatement -y ? & D 2 C *. #oul" be interprete" a -"etermine the !alue o$ -&.% multiply it by t#o% a"" $i!e an" then copy the re ult into the !ariable -y. in mo t thir"/generation language

302

The e'ual

ign i "ecepti!e a it "oe not

repre ent a tatement o$ $act% a in an e'uation% but it repre ent an action to be per$orme". The -?. ign i the a ignment operator. In ome language a "i$$erent ymbol uch a -B?. i u e" $or the a ignment operator. Although the e&pre ion on the right han" i"e o$ the -?. ign i e!aluate" a an e&pre ion% the !alue on the le$t/han" i"e o$ the -?. ign i imply a !ariable name. uch a -y / * ?

True mathematical e'uation programming language .

& D 2. are not recogni e" by tan"ar"

1o#e!er% a language that upport

ymbolic

calculation #oul" recogni e thi e'uation an" #oul" be able to calculate the !alue o$ any !ariable #hen gi!en the !alue o$ the other !ariable .

305

Al o% ome ymbolic calculation language upport calculation #ith true $raction . In mo t programming language W i treate" a one "i!i"e" by three% #ith a re ult o$ 0.333333. Multiplying thi re ult by 3 #oul" pro"uce 0.::::::% not 1. I ing true $raction % ho#e!er% W D 3 ? 1.

4.1.!.

.oste- #an(ua(es

1o te" language are compile" an" e&ecute" #ithin an application. The application may pro!i"e a "e!elopment en!ironment% #hich may inclu"e e"iting an" "ebugging $acilitie . The application al o upplie the in$ra tructure nece ary to "i play creen in$ormation% print% loa" "ata etc. A range o$

307

built/in $unction #oul" al o be inclu"e"% "epen"ing on the particular $unction upporte" by the application

4.1.!.1. 0acro #an(ua(es

Application may inclu"e a language $or peci$ying $ormula or "e!eloping $ull program co"e #ithin macro . The e language may be peci$ically "e!elope" $or the application% or they may be implementation o$ tan"ar" programming language . Acce ing "ata an" $unction in other part o$ the application may be lo#% a multiple layer o$ o$t#are may be in!ol!e". 1o#e!er% acce ing "ata an" !ariable #ithin the program it el$ may be rea onably $a t% "epen"ing on the interpreter u e" to run the co"e an" the le!el o$ compilation u e".

30:

4.1.!.2. Database #an(ua(es

Some "ataba e y tem inclu"e programming language that can be u e" to "e!elop complete application . In ome ca e the e language are interprete" an" may e&ecute relati!ely lo#ly% #hile in other ca e a $ull compiler i a!ailable.

4.1.".

%&ecution Script lan(ua(es

Eunning program % coping $ile an" per$orming other operating y tem $unction can be "one #ith language uch a hell cript an" <ob control language . Statement in cript language inclu"e program an" $ile name % an" may al o

310

upport !ariable an" ba ic operation inclu"e pattern/matching $acilitie $or earching te&t an" matching multiple $ilename .

uch

a -i$. tatement . Script language may

Although compiler may be a!ailable in ome ca e % in general a cript language i interprete" an" run on a tatement/by/ tatement ba i by the operating y tem or comman" line interpreter.

4.1.8.

Report ,enerators

Eeport generator allo# a report to be automatically pro"uce" once the layout an" $iel" ha!e been "e$ine". 3ormula can be a""e" $or calculation % ho#e!er co"e i not re'uire" to pro"uce the report it el$.

311

Eeport generator are u e$ul $or pro"ucing report that appear in a ro# an" column $ormat. 4ocument output% uch a a page #ith graph an" table o$ $igure % coul" be pro"uce" by u ing a tan"ar" language in a graphical printing en!ironment. Alternati!ely% the "ocument coul" be ho te" in an application uch a a #or" proce or% #ith macro co"e u e" to up"ate "ata $rom e&ternal ource .

".2. Development Environments

4.2.1.

Source Co-e Develop$ent

The three $un"amental element o$ a "e!elopment en!ironment are an e"itor% a compiler an" a "ebugger.

312

An e"itor i u e" to !ie# an" mo"i$y the ource co"e. )ompiler compile the ource co"e an" pro"uce an e&ecutable $ile. Alternati!ely% interpreter or !irtual machine may pro!i"e the run/time in$ra tructure nee"e" to e&ecute the program. A "ebugger i a program that i u e" to a i t in "ebugging. 4ebugger allo# the program to be toppe" "uring e&ecution% an" the !alue o$ "ata !ariable can be e&amine". In ome en!ironment all three program may be integrate" into a ingle u er inter$ace% #hile in other en!ironment program are u e". eparate

4.2.2.

Version Control

313

9er ion control or ource/co"e control y tem per$orm t#o main $unction . They generally allo# pre!iou !er ion o$ a $ile to be acce e"% o that change can be checke" #hen "ebugging or "e!eloping ne# co"e. Al o% the e y tem allo# a ource $ile to be locke"% o that problem "o not occur #here t#o people attempt to mo"i$y the ame ource co"e $ile at the ame time.

4.2.3.

+n rastructure

+rogram are generally "e!elope" u ing other co"e $acilitie in a""ition to the language operation . Thi coul" inclu"e ubroutine librarie % $unctional engine % an" acce y tem $unction . to operating

31,

The co"e element may be ource" $rom pre!iou pro<ect % a et o$ common routine acro pro<ect % tan"ar" language librarie an" $rom e&ternal ource .

4.2.3.1. C1an(es to Co$$on Co-e

)hange to e&i ting common co"e can be han"le" in e!eral #ay . 3or y tem that are currently in "e!elopment% or #here $uture change are e&pecte"% the y tem u ing the ubroutine or $unction can be up"ate" to re$lect the change. 3or ol" y tem #here a large number o$ change are not e&pecte"% a eparate copy o$ the common co"e may be tore" #ith the y tem. Thi a!oi" the nee" to continually up"ate the y tem to imply re$lect change in the common co"e.

31*

Alternati!ely% in ome ca e the e&i ting co"e can be le$t intact an" a ne# ubroutine can be a""e" #ith a lightly "i$$erent name. Thi i impractical #hen a large number o$ change are ma"e% but may be u e" #hen e&ternal program u e the inter$ace an" the e&i ting "e$inition mu t be le$t unchange" $or compatibility rea on .

4.2.3.2. Develop$ent o Co$$on )unctions

)ommon $unction are u ually re er!e" $or $unction that per$orm general calculation an" operation that are likely to be u e" in other pro<ect . 3uture change can be re"uce" i$ the ubroutine upport the $ull calculation or $unction that i in!ol!e"% rather than the

312

peci$ic ca e that may be u e" in the current pro<ect. ;rror han"ling in common co"e may in!ol!e returning error con"ition rather than "i playing me age % a the co"e may be calle" in "i$$erent #ay in $uture pro<ect . Al o% the co"e may a!oi" input an" output $unction uch a $ile acce % creen "i play an" printing. Thi #oul" allo# the $unction to be u e" by "i$$erent pro<ect in "i$$erent circum tance .

315

".3. S+stem Design


Sy tem "e ign i largely ba e" on breaking connection % an" u ing "i$$erent approache $or "i$$erent component o$ the "e ign. Thi inclu"e connection bet#een the $ollo#ing component B +roce e per$orme" an" the internal y tem "e ign.

The y tem "e ign an" the co"ing mo"el. The u er inter$ace tructure an" the co"e control $lo# mo"el. The application "ata ob<ect an" the y tem ob<ect . 4ataba e entitie an" program tructure % an" the peci$ic "ata. The e'uence o$ $unction call an" the outcome. The outcome o$ a ubroutine call an" pre!iou e!ent . 317

The outcome o$ a ubroutine call an" e&ternal "ata. )onnection bet#een ma<or co"e mo"ule .

4.3.1.

Conceptual 4asis

A y tem #ill generally be built on the concept that un"erlie a particular $iel" or proce . 3or e&ample% a -$uture . tran action i a $inancial/market tran action that in!ol!e $i&ing $uture price $or buying or elling a commo"ity. An accounting y tem may treat thi a a contract% #ith a et o$ payment an" a $ini hing "ate. An in!e tment management y tem may treat thi a an a et that ha" a tra"ing !alue. Thi

31:

!alue #oul" ri e an" $all each "ay a the $inancial market mo!e". Thi ame in trument i recor"e" in

completely "i$$erent #ay un"er "i$$erent conceptual mo"el . @ne mo"el recor" a !alue that ri e an" $all "aily% #hile the other mo"el recor" a et o$ payment o!er time. In ome ca e the ba ic concept an" tructure are clearly "e$ine"% an" a y tem coul" be "irectly built on the ame $oun"ation . 1o#e!er% "e igning a eparate et o$ concept $or the y tem may lea" to a more $le&ible internal tructure that coul" be more ea ily a"apte" to "i$$erent proce ing. In other ca e % a y tem may inclu"e $unction that relate to more than one conceptual $rame#ork. In the e ca e % a

320

eparate et o$ concept an" mo"el may nee" to be "e!elope" to implement both $rame#ork . 3or e&ample% in the pre!iou ca e o$ the $uture tran action% a y tem that per$orm both accounting an in!e tment management $unction #oul" nee" to u e an internal concept o$ a $uture tran action that allo#e" the implementation o$ both the accounting !ie#% o$ regular payment % an" the in!e tment !ie#% o$ a tra"e" a et. 3or e&ample% one internal approach #oul" be to break the link bet#een -account . an" -tran action .% an" imply recor" ca h$lo# . An account coul" be a collection o$ ca h$lo# that matche" a certain criteria. Al o% the link bet#een a et an" tra"ing !alue coul" be broken% re ulting in a mo"el ba e" on -actual ca h$lo# . (hi torical tran action )% -pre"icte" ca $lo# . ($oreca t

321

payment ) an" -potential ca h$lo# . (market !alue).

4.3.2.

#evel o 'bstraction

@ne approach to y tem "e ign i to "irectly tran late the proce e % "ata ob<ect an" $unction that the application upport into a y tem "e ign an" co"e. The lea" to traight$or#ar" "e!elopment% an" co"e that i clear an" ea ily maintaine". 1o#e!er% thi approach can al o lea" to a large !olume o$ co"e% an" pro"uce a y tem tructure that i "i$$icult to mo"i$y. A higher le!el o$ ab traction may be pro"uce" by "e$ining a maller number o$ more general ob<ect % an" u ing the e ob<ect an" $unction to implement the $ull application.

322

Thi approach may re"uce co"e !olume an" create a more $le&ible internal tructure. 1o#e!er% the initial "e ign an" "e!elopment may be more comple& an" the y tem may be more "i$$icult to "ebug. 3or e&ample% rather than "e!eloping a et o$ eparate report or proce e % a general report $unction or proce ing $unction coul" be "e!elope"% #ith the actual re ult being "epen"ant on the $lag an" option At a higher le!el o$ ab traction% an implementation may inclu"e internal macro language $or calculation % $un"amental operation on ba ic ob<ect uch a calculation on block o$ "ata% an" a complete "i connection bet#een the application ob<ect an" proce e an" the internal co"e tructure. Thi proce may lea" to e!en maller co"e electe".

!olume an" more $le&ible internal

323

operation % #ith the "i a"!antage o$ longer initial "e!elopment time an" comple& tran $ormation bet#een internal ob<ect an" application proce e . 6o# le!el o$ ab traction are u e$ul #hen there i little o!erlap bet#een proce e % #hile high le!el o$ ab traction are u e$ul $or y tem uch a o$t#are tool % an" $or proce ing y tem that inclu"e a large number o$ imilar operation . 6o# le!el o$ ab traction in!ol!e mainly application co"ing an" little in$ra tructure "e!elopment% #hile high le!el o$ ab traction in!ol!e mainly in$ra tructure "e!elopment #ith little application co"ing. @utput i generally more con i tent #ith highly ab tracte" y tem . In lo# ab traction y tem % minor "i$$erence in $ormatting an" calculation metho" can ari e bet#een "i$$erent proce e .

32,

4.3.3.

Data +n or$ation vs. Structure

+n or$ation

In general% y tem tructure are impler an" more $le&ible% co"e !olume are maller% an" co"e i impler #hen in$ormation i recor"e" #ithin a y tem a "ata rather than a tructure. 3or e&ample% a y tem may in!ol!e e!eral pro"uct #ith a eparate "ataba e table an" program tructure $or each pro"uct. The tructure o$ the "ataba e table an" program ob<ect #oul" peci$y part o$ the in$ormation concerning the application element . A impler approach #oul" be to u e a ingle pro"uct table an" tructure% an" recor" the "i$$erent pro"uct a "ata recor" an" table entrie .

32*

A $urther generali ation #oul" be to remo!e pro"uct/ peci$ic $iel" an" proce ing% an" tore a et o$ general $iel" that coul" be u e" to peci$y option $or a general et o$ proce ing. In ome ca e an application may contain a large number o$ tructure % ob<ect an" $unction % #hile the "ataba e "e$inition an" co"e tructure may implement a mall number o$ general tructure . The application "etail #oul" then relate to the "ata tore" #ithin the "ataba e an" co"e table . In general a impler y tem may re ult $rom u ing the minimum number o$ "ataba e table an" program tructure .

322

4.3.4.

/rt1o(onality

8hen a et o$ option i a!ailable $or a proce % $unctionality may be increa e" i$ the option are in"epen"ent an" all combination o$ the option are a!ailable. 3or e&ample% a report mo"ule may "e$ine a ort or"er% layout type an" a ubtotalling metho". I$ each option #a implemente" a a eparate tage in the co"e% rather than implementing each combination in"i!i"ually% thi #oul" lea" to orthogonal $unctionality. In the ca e o$ t#o ort or"er % $i!e layout type an" three ubtotalling metho" % there #oul" be three ma<or ection o$ co"e an" 2C*C3 ? 10 total co"e ection . 1o#e!er% the number o$ po ible output combination #oul" be 2D*D3 ? 30 output report $ormat .

325

Thi $unction may ha!e been "eri!e" $rom $i!e eparate report $ormat . By combining the report $ormat % o!erlapping co"e #oul" be eliminate" lea"ing to a re"uction in co"e !olume% an" the number o$ output $ormat #oul" ri e $rom * to 30. A another e&ample% i$ a graphic engine upporte" three type o$ light an" three type o$ !ie# $rame % then in an orthogonal y tem any light coul" be u e" #ith any !ie# $rame. In practice ome combination may not be upporte"% either becau e they #oul" be particularly "i$$icult to implement% they #oul" take an e&tremely long time to e&ecute% or becau e they peci$ie" logical contra"iction .

327

3or e&ample% a li t can be orte" in a cen"ing or "e cen"ing or"er% but cannot be orte" in both or"er imultaneou ly.

8hen electe" option con$lict% one outcome may be electe" by "e$ault.

4.3.5.

,enerality

=enerality in!ol!e $unction that per$orm $un"amental operation % rather than peci$ic proce e . 3or e&ample% a calculation routine that e!aluate" any $ormula #oul" be a more general $acility than a calculation metho" that implemente" a $i&e" et o$ $ormula . A "ata tructure that tore" "etail o$ pro"uct #oul" be a more general tructure

32:

than creating a eparate "ata tructure $or each pro"uct. +er$orming proce ing ba e" on attribute % $lag an" number i a more general approach than implementing peci$ic combination o$ option #ithin the co"e. 3or e&ample% toring a $ormula on a recor" #oul" be a more general approach than toring a !ariable that in"icate" that calculation metho" A houl" be u e". In ca e #here the ame $ormula may appear on multiple recor" % a eparate table coul" be create" to repre ent a "i$$erent "ataba e ob<ect% rather than inclu"ing $i&e" option #ithin the co"e. =enerality al o applie to $unction that accept !ariable input $or proce ing option % rather than a !alue that i $i&e" li t o$ option . electe" $rom a

330

3or e&ample% a proce ing routine that accepte" a number o$ "ay bet#een operation #oul" be a more general routine than an alternati!e that implemente" a $i&e" et o$ perio" . In broa" term % a general proce or $unction

i one that i able to per$orm a #i"er range o$ $unction than an alternati!e implementation.

4.3.6.

4atc1 Processes

Batch proce e are proce e that per$orm a large amount o$ proce ing% an" are generally "e igne" to be run unatten"e". Thi may inclu"e rea"ing large number o$ "ataba e recor" % or proce ing large amount o$ numeric "ata.

331

8hen "ata problem occur "uring proce ing% thi may be han"le" by #riting an error me age to a log $ile an" continuing proce ing. More eriou error % uch a internal program error or mi ing critical "ata may re ult in terminating the proce .

4.3.6.1. +nput C1ec2in(

Input "ata can be checke" u ing a range o$ check . 3or e&ample% 4ata that i negati!e% Aero or out i"e e&pecte" range .

4ata that i incon i tent% uch a percentage that "o not um to 100. 4ata that i greatly "i$$erent $rom pre!iou !alue .

332

4.3.6.2. /utput C1ec2in(

Interacting proce e may in!ol!e a manual check o$ the re ult % ho#e!er in the ca e o$ a batch proce % large !olume o$ "ata may be up"ate" to a "ataba e. @utput re ult can be checke" u ing imilar check to the input "ata% to "etect po ible error be$ore incorrect "ata i #ritten to a $ile.

4.3.6.3. Per or$ance

+er$ormance may be a igni$icant i ue #ith batch proce e . 4ata that #ill be rea" multiple time can be tore" in internal program array or "ata recor" bu$$er .

333

The or"er in #hich the proce ing i per$orme" can al o ha!e a igni$icant impact on e&ecution pee". 8hen a one/to/many "ataba e link i being proce e"% i$ the chil" recor" are rea" in the or"er o$ the parent key then each parent recor" #oul" only nee" to be rea" once. 3or e&ample% i$ account recor" #here proce e" in account number or"er% then the cu tomer recor" #oul" ha!e to be rea" $or each ne# account. 1o#e!er% i$ the account recor" #ere proce e" in cu tomer number or"er% then the account $or each cu tomer #oul" be proce e" in e'uence an" the cu tomer recor" #oul" only ha!e to be rea" once.

4.3.6.4. Re*ritin(

33,

Batch proce ing co"e i o$ten !ery ol"% a it per$orm ba ic $unction that change little o!er time. Ee#riting co"e may ha!e lea" to a re"uction in e&ecution time% particularly i$ the co"e ha been hea!ily mo"i$ie" or a long time ha elap e" ince it #a $ir t #ritten. 8hen the co"e ha been hea!ily mo"i$ie"% the co"e may calculate re ult that are ne!er u e"% rea" "ataba e recor" that are not acce e" an" re/rea" recor" unnece arily. Thi may occur #hen co"e in a late part o$ the proce i change" to a "i$$erent metho"% ho#e!er the earlier co"e that calculate" the input $igure remain unchange". Ee/rea"ing recor" may occur a the control $lo# #ithin the mo"ule become more comple&.

33*

Al o% re/#riting the co"e may enable tructure in the "ataba e an" the co"e to be u e" that #ere not a!ailable #hen the mo"ule #a originally #ritten.

4.3.6.5. Data Scannin(

A batch proce e may al o be #ritten purely to can the "ataba e% an" apply check uch a range check to i"enti$y error in the "ata.

332

".". Soft.are Component !odels


A o$t#are component i a ma<or ection o$ a program that per$orm a relate" et o$ $unction . 3or e&ample% the u er inter$ace co"e han"ling creen "i play an" application control $lo# may be eparate" into a ma<or ection o$ the program. )alculation co"e may al o be groupe" into a eparate ection o$ co"e. So$t#are component may con i t o$ a ection o$ relate" co"e% or the $unction per$orme" by the component may be groupe" into a clearly "e$ine" $unctional inter$ace.

4.4.1.

)unctional %n(ines

335

An engine i an in"epen"ent o$t#are component that u e a imple inter$ace% an" ha comple& internal proce ing. 4ataba e management y tem are an e&ample o$ a $unctional engine. @ther engine may inclu"e calculation engine % printing engine % graphic engine etc. In ome ca e an engine e&ecute a an in"epen"ent proce % an" communication occur through a program inter$ace.

4.4.2.

'bstract /b3ects an- )unctions

So$t#are component

uch a proce ing

engine are generally more $le&ible an" u e$ul #hen they "eal #ith a number o$ $un"amental ob<ect an" $unction % rather than a et o$ $i&e" proce e .

337

3or e&ample% a calculation engine may calculate the re ult o$ any $ormula that i pre ente" in the peci$ie" $ormat% an" apply $ormula to block o$ "ata. Thi #oul" be a more u e$ul component than an engine that calculate" the re ult o$ a $i&e" et o$ $ormula .

4.4.3.

+$ple$entation

The mo"el o$ "ata an" $unction that appear on one i"e o$ the inter$ace i in"epen"ent o$ the internal tructure o$ the co"e on the other i"e o$ the inter$ace% #hich may u e the ame ob<ect or may be tructure" "i$$erently. 3or e&ample% the co"e on the other i"e o$ the inter$ace coul" implement the ob<ect an" proce e "irectly% or tran late $unction call into "e$inition an" attribute % an" per$orm

33:

actual proce ing #hen "ata or output #a re'ue te". Al o% the inter$ace ob<ect them el!e coul" be implemente" #ithin the o$t#are component u ing a maller et o$ concept . The e ob<ect coul" be u e" to implement the $ull range o$ ob<ect an" $unction that #ere "e$ine" in the inter$ace.

4.4.4.

Sin(le %ntry an- %&it Points

So$t#are component are generally more $le&ible #hen they operate through a ingle entry point. 4e igning a ingle entry point inter$ace may al o lea" to a clearer tructure $or both the inter$ace an" the internal co"e. Thi in!ol!e "e$ining a et o$ $unction an" operation that are upporte" by the

3,0

component% an" pa ing in truction an" "ata through a ingle inter$ace. In ome ca e a ingle e&it point coul" al o be u e". In thi ca e% the ubroutine call that are ma"e #ithin the component #oul" be re/ route" through a ingle $unction that acce e" e&ternal operation . Thi $unction #oul" then call the rele!ant e&ternal $unction $or "ataba e operation % creen inter$acing etc. Thi approach #oul" allo# the internal co"e o$ the component to be "e!elope" completely in"epen"ently. )hanging inter$ace to e&ternal co"e% an" u ing the component in alternati!e ituation % coul" be "one by mo"i$ying the e&ternal er!ice routine.

3,1

4.4.5.

Co-e 0o-els

Separating a y tem into ma<or $unctional ection allo# a "i$$erent co"e mo"el to be u e" in each ection.

4.4.6.

Se7uence Depen-ance

)omponent are more $le&ible #hen in"epen"ent operation can be calle" in any or"er. 3or e&ample% a graphic inter$ace may "e$ine that te&ture % po ition an" lighting mu t be "e$ine" in that or"er% or alternately that the three element coul" be peci$ie" in any or"er.

4.4.!.

/rt1o(onality

@rthogonality #ithin an inter$ace allo# each option an" $unction to be electe"

3,2

in"epen"ently% an" all combination #oul" be a!ailable. Thi increa e the $unctionality o$ the inter$ace% an" may al o make program "e!elopment ea ier through le re triction o$ u e o$ the o$t#are component.

4.4.".

,enerality

A general $unctional inter$ace i one that implement a #i"e range o$ $unction . Thi may in!ol!e pa ing continuou "ata !alue a input% rather than electing $rom a pre/"e$ine" li t o$ option . 3un"amental $unction an" operation may be more general than a o$t#are component inter$ace that inclu"e a range o$ application/ peci$ic $unction an" "ata ob<ect .

3,3

".$. S+stem /nterfaces

4.5.1.

:ser +nter aces

4.5.1.1. C1aracter 4ase- +nter aces

)haracter ba e" u er inter$ace in!ol!e the u e o$ a keyboar" $or y tem input% an" $i&e" character po ition $or !i"eo "i play. Eunning $unction may be "one u ing menu option % or through a comman" line inter$ace.

4.5.1.2. Co$$an- #ine +nter aces

A comman" line inter$ace i ba e" on a "ialog ba e" y tem. Thi generally u e a character ba e" inter$ace #ith keyboar" input an" a $i&e" character "i play.

3,,

)omman" are type" into the y tem. The particular $unction i per$orme"% an" proce ing return to the comman" line to accept $urther input. )omman" line inter$ace are o$ten a!ailable #ith operating y tem % $or per$orming ta k uch a running program an" copying $ile . Some application al o inclu"e a comman" line inter$ace.

4.5.1.3. ,rap1ical :ser +nter aces

=raphical u er inter$ace in!ol!e a graphical layout o$ #in"o# an" "ata% an" the u e o$ a mou e an" keyboar" to elect item an" input "ata. ;n!ironment that upport graphical u er inter$ace are generally multi/ta king% an"

3,*

allo# multiple #in"o# to be open an" program to be running at a particular time.

4.5.1.4. /t1er :ser +nter aces

In other circum tance % "i$$erent "e!ice may be u e" $or both input $rom the u er an" the "i play or output o$ in$ormation. Input "e!ice coul" inclu"e control panel % peech recognition etc. @utput "e!ice coul" inclu"e multiple !i"eo "i play % in"icator panel % printe" li t output etc.

4.5.1.5. 'pplication Control )lo*

)ontrol $lo# #ith application may $ollo# a menu y tem. Thi i u e" in both character/ ba e" an" graphical en!ironment .

3,2

Selecting an option $rom a menu may per$orm the peci$ie" $unction% or "i play a ub/menu. Menu y tem can be hierarchical% #ith ub menu connecte" "irectly to main menu . 3unction may appear in one place or they may appear on multiple ub/menu . In ome ca e ub/menu may be cro /

connecte" an" a ubmenu coul" <ump "irectly to another ubmenu. @ther control $lo# mo"el inclu"e e!ent "ri!en y tem . In thi mo"el% $unction can be per$orme" by electing application ob<ect or comman" button an" per$orming the action re'uire" to run the $unction. Application control $lo# may be proce / "ri!en or $unction/"ri!en. +roce /"ri!en control $lo# #oul" in!ol!e electing menu option to per$orm !ariou

3,5

proce e % an" may be u e" $or "ata proce ing y tem . 3unction/"ri!en y tem $ocu on "ata ob<ect rather than proce e . Thi approach i commonly u e" $or o$t#are tool . In a $unction "ri!en y tem% the ob<ect #oul" $ir t be electe"% an" then the $unction to run #oul" be in!oke". +rogram co"e can be tructure" in the ame #ay a the application control $lo#. Thi approach lea" to a "irect implementation% #ith the tructure o$ the internal co"e $ollo#ing the tructure o$ the application it el$. 1o#e!er% in other ca e an in"irect link may be more uitable. 3or e&ample% a proce / "ri!en y tem #ith a large amount o$ o!erlap bet#een proce e coul" be implemente" internally u ing a $unction/"ri!en co"e tructure% #hile a $unction/"ri!en application

3,7

may be implemente" internally a a et o$ proce e .

4.5.2.

Pro(ra$ +nter aces

+rogram inter$ace are u e" #hen a program connect to another program or o$t#are component. Thi inclu"e inter$ace to ubroutine librarie % "ataba e management y tem % operating y tem $unction % proce ing engine an" other ma<or mo"ule #ithin the y tem.

4.5.2.1. <arro* +nter aces

0arro# inter$ace occur #hen the inter$ace con i t o$ a mall number o$ $un"amental operation an" "ata ob<ect .

3,:

The u e o$ a narro# inter$ace enable the co"e on each i"e o$ the inter$ace to be change" in"epen"ently. Al o% the inter$ace it el$ may be ea ier to u e. Thi i a loo ely/couple" inter$ace% a in theory the application program coul" be couple" to a "i$$erent o$t#are component that per$orme" imilar $unction % po ibly u ing a tran lation layer. Thi may occur% $or e&ample% in porting an application to another operating y tem that u e" "i$$erent creen or printing operation . An alternati!e creen or printing engine coul" be "e!elope" $or the alternati!e operating y tem% an" couple" to the main program. An e&ample o$ a narro# inter$ace i a "ata 'uery language% #ith tatement pa e" to a "ataba e engine. The "ata retrie!al an"

3*0

up"ate operation are peci$ie" by the tatement containe" in the 'uery te&t tring. A ubroutine library that containe" a large number o$ ubroutine % each per$orming a imple $unction% #oul" be a #i"e inter$ace. The $unction in ubroutine library coul" repre ent a clo ely/couple" inter$ace% a the inter$ace #oul" contain a large number o$ link an" interaction . Thi #oul" pre!ent the co"e on either i"e o$ the inter$ace $rom being change" in"epen"ently% a thi #oul" al o re'uire igni$icant change on the other i"e o$ the inter$ace. Al o% the co"e coul" not be replace" #ith an alternati!e library that u e" a "i$$erent internal tructure% a the tructure it el$ #oul" be part o$ the inter$ace. Many program inter$ace are implemente" a ubroutine call % ho#e!er in the ca e o$ a narro# inter$ace thi may con i t o$ a $e# ubroutine pro!i"ing a link that pa e in truction an" "ata through the inter$ace.

3*1

A narro# $unctional inter$ace "oe not nece arily imply a lo# "ata tran $er rate% a #oul" be the ca e in a narro# ban"#i"th net#ork. A narro# $unctional inter$ace may upport the tran $er o$ large block o$ "ata% in contra t to a narro# "ata channel #hich in!ol!e tran $erring "ata erially% #ith mall "ata item tran $erre" in e'uence% rather than a parallel tran $er o$ all the "ata in a ingle large block.

4.5.2.2. Passin( Data

4ata can be pa e" though inter$ace u ing parameter to ubroutine % or pointer to "ata ob<ect tore" in memory.

Another approach in!ol!e the u e o$ a han"le.

3*2

A han"le i a mall "ata item that i"enti$ie a "ata ob<ect. The han"le i returne" to the calling program% ho#e!er the "ata ob<ect it el$ remain #ithin the o$t#are component that #a calle". 3or e&ample% calling a graphic engine to loa" a graphic ob<ect may re ult in the ob<ect being loa"e" into the graphic engine( memory pace% an" a han"le being returne" to the calling program. The han"le coul" then be u e" to i"enti$y the ob<ect #hen $urther call #ere ma"e to the graphic engine.

4.5.2.3. Passin( +nstructions

Eather than containing a large number o$ ubroutine call to per$orm in"i!i"ual

3*3

$unction % a narro# program inter$ace #ork by pa ing in truction through the inter$ace. Thi may take the $orm o$ a imple language% uch a a "ata 'uery language. A calculation engine may recei!e te&t tring containing $ormula or imple tatement $or applying $ormula to "ata ob<ect . In truction can al o be pa e" a a et o$ numeric operation co"e . 3or e&ample% an engine $or "i playing #ire$rame image o$ tructure coul" implement in truction to "e$ine an element% "e$ine connection bet#een element % "e$ine a !ie# po ition an" generate an image. The e $unction coul" be implemente" in an inter$ace by u ing a numeric !alue to repre ent the operation to be per$orme"% an" a han"le to in"icate the "ata ob<ect.

3*,

Thi approach #oul" lea" to a imple inter$ace that #a ea ily e&ten"e"% an" #oul" al o upport "ata tran $er through net#ork connection or inter/proce channel . communication

4.5.2.4. <on5Data #in2in(

In general% a program inter$ace pa e "ata bet#een proce e % an" ubroutine an" "ata !ariable on the other i"e o$ the inter$ace cannot be "irectly acce e". Thi allo# the inter$ace to be clearly "e$ine"% an" pre!ent problem "ue to interaction bet#een ection o$ co"e on either i"e o$ the inter$ace. A""itionally% i$ in truction an" "ata are pa e" through an inter$ace channel% then the t#o co"e ection can e&ecute in"epen"ently% an" may operate in eparate memory pace %

3**

through inter/proce

communication or

through a net#ork communication channel. 1o#e!er% in ome ca e callback $unction are implemente". Thi occur #here the engine call a ubroutine #ithin the main program. In ome ca e callback $unction are una!oi"able. 3or e&ample% a general orting routine that applie" to any type o$ ob<ect #oul" nee" to call a ubroutine in the main program to compare t#o ob<ect % o that the or"er o$ the orting coul" be "etermine".

3*2

".&. S+stem Development

4.6.1.

+n rastructure an- 'pplication

Develop$ent

Sy tem "e!elopment can be broken into t#o eparate pha e . In$ra tructure "e!elopment in!ol!e "e!eloping $acilitie that are u e" internally #ithin the program. Thi coul" inclu"e "e!eloping "ata tructure an" the ubroutine $or operating on them% "e!eloping ubroutine librarie % "e!eloping proce ing engine % "e!eloping common mo"ule in proce /orientate" y tem % an" "e!eloping ob<ect mo"el in ob<ect/ orientate" y tem .

3*5

Application "e!elopment in!ol!e #riting co"e that per$orm the proce ing re'uire" by the y tem% han"le the u er inter$ace% an" per$orm the $unction an" operation that the application upport . In ome pro<ect % the ma<ority o$ "e ign an" co"ing may in!ol!e application co"ing. Thi may be ba e" on traight$or#ar" proce ing% or it may be ba e" on an e&i ting in$ra tructure. The in$ra tructure u e" coul" inclu"e $acilitie "e!elope" $or earlier pro<ect % or a combination o$ operating y tem $unction % tan"ar" language librarie % an" e&ternally/ ource" librarie . In other pro<ect the ma<ority o$ the "e!elopment proce may in!ol!e in$ra tructure "e!elopment% #ith the application compri ing a collection o$ imple co"e that call general proce ing $acilitie .

3*7

Thi may occur in proce ing application #ith a large "egree o$ o!erlap bet#een imilar $unction % an" al o #ith $unction/ "ri!en application uch a o$t#are tool % #here the application it el$ may be largely a u er inter$ace aroun" a et o$ general $acilitie . The "e!elopment o$ ome in$ra tructure can re ult in a y tem that u e le "i$$erent part o$ the y tem. 1o#e!er% "e!eloping in$ra tructure co"e i time con uming. Al o% a comple& in$ra tructure may make y tem "e!elopment more "i$$icult i$ the comple&ity o$ the in$ra tructure i greater than the comple&ity o$ the un"erlying application re'uirement . co"e% i more $le&ible% an" i more con i tent acro

4.6.2.

Pro3ect Syste$s Develop$ent

3*:

4e!eloping a y tem on a pro<ect ba i in!ol!e a et o$ tage . Typically a "e!elopment proce inclu"e the $ollo#ing tep Ee'uirement Analy i Sy tem Analy i Sy tem 4e ign )o"ing Te ting L 4ebugging 4ocumentation coul"

4.6.2.1. Re7uire$ents 'nalysis

Ee'uirement analy i in!ol!e "e$ining the broa" cope o$ a y tem% an" the ba ic $unction that it #ill per$orm. Thi may be ba e" on a "ocument that i upplie" a an input to the y tem "e!elopment proce .

320

Alternati!ely% the re'uirement analy i can be "one at an early tage o$ the pro<ect% prior "e!eloping the y tem. I"eally the re'uirement peci$ication houl"

outline the ba ic $unction an" operation that the y tem houl" pro!i"e% along #ith a et o$ "e irable but non/e ential $unction .

4.6.2.2. Syste$s 'nalysis

Sy tem analy i in!ol!e "e$ining the $unction that the y tem houl" per$orm% inclu"ing "etail o$ the calculation % proce ing% an" the "ata that houl" be tore". Thi proce re ult in the pro"uction o$ a

$unctional peci$ication.

321

The $unction an" "ata re'uire" can be e tabli he" by "etermining the output that the y tem houl" pro"uce% an" #orking back#ar" to the input "ata an" the calculation that are nece ary to pro"uce the output . Some a""itional "ata may be tore" purely $or recor"/keeping purpo e % ho#e!er thi proce #oul" i"enti$y the $un"amental "ata that #a nee"e" $or the proce ing to be complete". The $unction $unction . ;&ception an" pecial ca e are a minor i ue in manual proce ing an" calculation en!ironment % but they are a igni$icant i ue in y tem "e ign. 3or e&ample% i$ one $ormula applie" to 10%000 client an" a "i$$erent $ormula peci$ie" may inclu"e

interacti!e $acilitie an" batch proce ing

322

applie" to 1 client% then "ouble the amount o$ co"e #oul" ha!e to be #ritten to cater $or the 1 client that u e" a "i$$erent $ormula. +roce ing e&ception ari e #hen "i continue" pro"uct or operation remain acti!e% #hen eparate arrangement apply to con!er ion $rom another pro"uct or ituation% an" #hen non/ tan"ar" arrangement are entere" into. Special ca e can be han"le" by con oli"ating a range o$ ituation into a number o$ pro"uct $eature an" option % inclu"ing o!erri"e !alue on in"i!i"ual recor" that o!erri"e "e$ault proce ing !alue % an" inclu"ing u er/"e$ine" $ormula in "ataba e $iel" that can be a""e" to a li t o$ a!ailable $ormula .

4.6.2.3. Syste$s Desi(n

323

Sy tem "e ign in!ol!e "e igning the internal tructure o$ the y tem to pro!i"e the application $acilitie that are peci$ie" in the $unctional peci$ication. In ome ca e % the y tem "e ign an" co"e tructure may $ollo# the tructure o$ the $unctional peci$ication an" the application control $lo#. Thi may lea" to a proce /"ri!en co"e tructure $or a "ata proce ing y tem% or a $unction/"ri!en co"e tructure $or a o$t#are tool. In other ca e % a "i$$erent co"e tructure coul" be u e". 3or e&ample% #here there #a a large amount o$ o!erlap bet#een "i$$erent proce e % implementing a proce /"ri!en application u ing a $unction/"ri!en co"e tructure may re ult in a large re"uction in co"e !olume.

32,

A another e&ample% application mo"ule may be groupe" by proce uch a etc. type% #hile the co"e may be groupe" by internal $unction% creen "i play% calculation routine

4.6.2.3.1. )uture %&pansion

In ome ca e % a umption an" re triction in the $unctional peci$ication coul" be rela&e" to allo# $or $uture e&pan ion. 3or e&ample% a many/to/many link coul" be implemente" #hen the "ata i currently limite" to one/to/many combination % but $uture change may be likely. Al o% a general calculation $acility coul" be implemente"% rather than programming a $i&e" et o$ e&i ting $ormula .

32*

4.6.2.4. Co-e Develop$ent

In ome ca e a "etaile" y tem "e ign "ocument may be pro"uce". In other ca e % co"e "e!elopment may $ollo# "irectly $rom the $unctional peci$ication% or $rom a co"e tructure that ha been electe" $or implementing the y tem. Te ting an" "ebugging $ollo# a cycle o$ te ting% correcting problem % relea ing ne# !er ion o$ the te t y tem an" continuing te ting.

4.6.2.5. )or$al Develop$ent 0et1o-s

3ormal "e!elopment metho"ologie in!ol!e a highly tructure" et o$ tep in the "e!elopment proce . The proce e an" output o$ each tage are clearly "e$ine".

322

Thi approach i u e" i

ome "ata

proce ing "e!elopment en!ironment . 3ormal metho" "e$ine the tage in the "e!elopment proce . Thi inclu"e the proce e that are per$orme" "uring each tage an" the "ocument an" "iagram that are pro"uce". 3ormal metho" ha!e a"!antage in managing an" "e!eloping large "ata proce ing y tem . The tep are clearly "e$ine"% an" the re ult o$ the "e!elopment proce e % both in term o$ the time perio" in!ol!e" an" that hape o$ the $inal y tem can be clearly i"enti$ie" at the beginning o$ the pro<ect. 1o#e!er% there are e!eral "i a"!antage #ith $ormal metho" .

325

3ormal metho" generate large !olume o$ paper "ocumentation% an" may in!ol!e e!eral layer o$ meticulou "e!elopment to pro"uce a $inal ection o$ co"e that may be 'uite traight$or#ar". A more eriou "i a"!antage relate to the $lo#/through tructure o$ the "e!elopment proce . There i a trong linking $lo#/ through $rom the initial re'uirement % through to y tem analy i an" "e ign% an" $inally co"ing. Thi may re ult in the pro"uction o$ a y tem that clo ely matche the e&i ting proce mo"el an" "ata ob<ect . 8hile thi y tem may per$orm the proce ing $unction #ithout "i$$iculty% it may al o be more comple& an" in$le&ible than alternati!e implementation . A y tem "e ign ba e" on a range o$ general ob<ect an" $unction may lea" to a impler "ata% co"e an" u er inter$ace tructure than a

327

y tem that "irectly implement e&i ting proce e .

4.6.3.

#ar(e Syste$ Develop$ent

A large y tem may be traight$or#ar" in "e ign% but in!ol!e a large number o$ proce e % "ataba e table % report an" creen . Al o% a large "e!elopment may in!ol!e a maller amount o$ co"e% but may implement a comple& et o$ operation .

4.6.3.1. Separation o 0o-ules

6arge y tem "e!elopment may be more e$$ecti!e #hen ma<or mo"ule are clearly eparate"% an" communicate through "e$ine" programming inter$ace .

32:

Thi enable each ection to be "e!elope" in"epen"ently. Al o% #here one ection i not complete% another ection can continue "e!elopment by re$erring to the "e$ine" inter$ace #hen inclu"ing proce e that re'uire a link to the other mo"ule.

4.6.3.2. Consistency

)on i tency in "e ign% u e o$ language $eature an" co"ing con!ention i important in large y tem . 8hen co"e i con i tently "e!elope"% "i$$erent ection o$ the co"e can be rea" #ithout the nee" to a"<u t to "i$$erent con!ention . Al o% con i tency re"uce the chance o$ problem occurring #ithin inter$ace bet#een mo"ule .

350

4.6.3.3. +n rastructure

6arge "e!elopment generally in!ol!e the "e!elopment o$ ome common $unction an" general $acilitie . In too little in$ra tructure i "e!elope"% a large amount o$ "uplicate" co"e may be #ritten. Thi may re ult in a y tem that ha large co"e !olume % i rigi" in tructure% an" "oe not inclu"e internal $acilitie to enable $uture mo"ule to be "e!elope" more ea ily. Al o% i$ too much in$ra tructure i "e!elope"% long "elay may be in!ol!e" an" the $inal y tem may in!ol!e unnece arily comple& co"e.

4.6.4.

%volutionary Syste$s

Develop$ent

351

;!olutionary y tem "e!elopment in!ol!e the continual "e!elopment o$ y tem an" relea ing ne# !er ion on a regular ba i . So$t#are tool are $re'uently "e!elope" an" e&ten"e" on an e!olutionary ba i . The e'uence o$ e!olutionary "e!elopment $ollo# a pattern o$ a""ing a range o$ ne# $eature an" $acilitie % an" then con oli"ating a range o$ $eature into a ne# ab tract $acility. Thi lea" to minor an" ma<or change % a $eature are continually a""e"% an" then a ma<or upgra"e occur a the "e ign i re/ tructure" to inclu"e ne# concept an" tructure that ha!e ari en $rom the in"i!i"ual $eature . Sy tem that are not re tructure" on a regular ba i can become e&tremely comple&% #ith e&ecution pee" an" reliability "ecrea ing a

352

time pa e an" more in"i!i"ual $eature are a""e". The e'uence o$ minor an" ma<or change applie to the internal co"e tructure% an" al o the u e o$ the application it el$% an" the ob<ect an" $acilitie that it upport . ;!olutionary y tem generally become more comple& a time pa e . ;&i ting $eature are rarely remo!e" $rom y tem % ho#e!er ne# $eature an" concept may be continually a""e". In ome ca e % thi re ult in the y tem becoming o large an" comple& that it e$$ecti!ely become unu able an" unmaintainable% an" i e!entually aban"one". The li$e pan o$ an e!olutionary y tem can be e&ten"e" by making ma<or tructural change #hen the y tem "e ign ha become more comple& than the $unction that it per$orm % an" by remo!ing pre!iou

353

$unction $rom the y tem a the y tem e!ol!e in "i$$erent "irection .

4.6.5.

'-51oc Syste$ Develop$ent

A"/hoc y tem "e!elopment in!ol!e creating y tem $or un tructure" an" hort/ term purpo e . ;&ample inclu"e te t program % con!er ion program an" pro"ucti!ity tool . In ome ca e a"/hoc "e!elopment may be "one u ing a macro language that i ho te" #ithin an application uch a a prea" heet. Thi allo# a imple proce a complete program. to be per$orme"

#ithout the o!erhea" in!ol!e" in "e!eloping

35,

The application pro!i"e the en!ironment $or loa"ing "ata% "i playing in$ormation% printing etc. An alternati!e to u ing an application program a a ho t #oul" be to "e!elop a mall temporary mo"ule #ithin an e&i ting y tem. Thi #oul" allo# the proce per$orm calculation an" proce ing. ;&ecution pee" may be le y tem. Thi may allo# impler metho" to be u e" to #rite the co"e% uch a the u e o$ tring % imple algorithm an" har"/co"e" !alue . In ca e #here the y tem i e&pan"e" in iAe an" continue in u e on a long/term ba i % the original "e ign an" co"ing practice may be un uitable $or long/term operation. important in an to u e the internal $acilitie o$ the main program to

a"/hoc "e!elopment than in a permanent

35*

Thi coul" be a""re e" through a ma<or con oli"ation an" re/"e ign% an" commencing on an e!olutionary "e!elopment path. In other ca e % particularly #hen the programming language or "e!elopment en!ironment it el$ i un uitable $or long term operation% a complete re"e!elopment o$ the y tem coul" be con"ucte".

4.6.6.

@ust5+n5Ti$e Syste$

Develop$ent

Fu t/in/time techni'ue are ba e" on re pon"ing to problem a they ari e% rather than relying on $or#ar" planning to pre"ict $uture con"ition . Fu t/in/time y tem "e!elopment may in!ol!e "e!eloping an" relea ing ection o$

352

a y tem in re pon e to proce ing re'uirement . Thi approach in!ol!e re pon"ing to change in proce ing re'uirement an" a"apting the y tem to changing con"ition % rather u ing pro<ect "e!elopment o!er long time$rame that rely on an e&pectation o$ $uture con"ition . A Fu t/in/time "e!elopment approach may be uitable $or rapi"ly changing en!ironment . Thi approach a!oi" e!eral problem that

are inherent in pro<ect "e!elopment . The re'uirement $or a y tem o$ten ari e be$ore the y tem i "e!elope"% not at the time that the "e!elopment #ill be complete". A ome large "e!elopment pro<ect may

take e!eral year % thi mean that other metho" mu t be $oun" to per$orm the $unction "uring the "e!elopment perio".

355

Thi may in!ol!e large !olume o$ manual proce ing% "e!elopment o$ temporary y tem % patch#ork change to e&i ting y tem % an" populating "ataba e #ith in$ormation that later pro!e to be in an un uitable $ormat. 6arge "e!elopment pro<ect may be aban"one" or ne!er $ully implemente"% "ue to unmanageable comple&ity% $la# in "e ign% or circum tance ha!ing change" o much by the time the pro<ect i complete" that the y tem i not o$ practical u e. 4i a"!antage #ith <u t/in/time "e!elopment inclu"e the $act that the proce i "eliberately reacti!e% an" o an e$$ecti!e an" $le&ible y tem "e ign may not appear unle the proce i combine" #ith regular internal re"e ign% an" proacti!e change ba e" on a me"ium/term !ie#.

357

Thi approach i

imilar to the e!olutionary

"e!elopment approach. 1o#e!er% the e!olutionary approach in!ol!e continuou "e!elopment o$ a y tem% #hile the <u t/in/ time approach in!ol!e a table y tem that change a re'uire" in re pon e the change in the proce ing en!ironment.

4.6.6.1. '-vanta(es

I ing a <u t/in/time approach% y tem are a!ailable at hort notice. Thi may a!oi" problem #ith u ing temporary y tem % an" toring "ata in #ay that later pro!e un uitable $or hi torical proce ing. A the "e!elopment a"apt to changing con"ition % the y tem may be more clo ely matche" to the proce ing re'uirement that a y tem "e!elope" o!er a long perio"% an" ba e" on a umption about the type o$ proce ing re'uire"

35:

4.6.6.2. Disa-vanta(es

A <u t/in/time approach coul" lea" to a y tem that i tructure" in a imilar #ay to the proce ing it el$. Thi #oul" not generally be an i"eal tructure% a thi #oul" lea" to a rigi" co"e an" "ata "e ign that #a "i$$icult to mo"i$y. An alternati!e #oul" be to retain a eparation bet#een the y tem tructure an" the proce ing re'uirement % an" a"apt the y tem tructure in"epen"ently o$ the proce ing change . Te ting coul" become an i ue #ith <u t/in/ time "e!elopment% a $re'uent relea e o$ ne# !er ion #oul" increa e the amount o$ te ting in!ol!e" in the "e!elopment proce .

370

I$ tructural change #ere not ma"e regularly% a <u t/in/time proce coul" "egenerate into a maintenance proce in!ol!ing patch#ork change to a y tem. Thi coul" occur #hen change #ere implemente" "irectly% rather than a"apting the y tem tructure to a ne# type o$ proce . I$ the "e!elopment proce i tie" in too

clo ely #ith the u e o$ the y tem% then alternati!e y tem "e ign an" tructure may be lo t an" the y tem may be limite" to the current a umption an" metho" u e" in proce ing.

4.6.6.3. +$ple$entation

In general% <u t/in/time "e!elopment may be more e$$ecti!e #hen the y tem tructure i a"apte" to uit a ne# proce % rather than implementing the change "irectly.

371

3or e&ample% a change to a calculation coul" be implemente" by a""ing a ne# $acility $or peci$ying calculation option % rather than inclu"ing the peci$ic change #ithin the y tem. Thi proce #oul" allo# the y tem to

retain a $le&ible an" in"epen"ent tructure% ba e" on a range o$ general $acilitie rather than $i&e" proce e . 8hen a large number o$ change ha" been ma"e% internal tructure coul" be change" to better re$lect the ne# $unction an" proce e that #ere being per$orme".

4.6.!.

Syste$ Re-evelop$ents

Many y tem "e!elopment are ba e" on replacing an e&i ting y tem.

372

A y tem that ha been hea!ily mo"i$ie" an" e&ten"e" o$ten become comple&% un table an" "i$$icult to u e an" maintain. Al o% the $unction an" proce e per$orme" may change an" a y tem may not inclu"e the $unction re'uire" $or the particular ta k being per$orme". Ee"e!elopment may $ollo# the tan"ar" pro<ect "e!elopment tep . In ome ca e % a better re ult may be achie!e" by a!oi"ing a "etaile" re!ie# o$ the e&i ting y tem. Thi may occur becau e the e&i ting y tem #ill be ba e" on a et o$ tructure an" a umption that may not be the i"eal tructure to u e $or a ne# "e!elopment. +er$orming a "etaile" re!ie# o$ the e&i ting y tem may lea" to replacing the y tem #ith a ne# !er ion ba e" on the ame tructure%

373

rather than "e igning a ne# tructure ba e" on the actual un"erlying re'uirement . 1o#e!er% a re!ie# o$ the e&i ting y tem a$ter the "e ign ha been complete" may highlight area that ha!e been mi e"% an" particular problem that nee" to be a""re e". Sy tem re"e!elopment generally in!ol!e a "ata con!er ion o$ the "ata $rom the pre!iou y tem. Thi can be "one by #riting con!er ion program to e&tract the $un"amental "ata% an" in ert the "ata into the ne# "ataba e tructure.

4.6.".

0aintenance an- %n1ance$ents

37,

Sy tem maintenance in!ol!e $i&ing bug an" making minor change to allo# continue" operation. Thi may inclu"e a""ing ne# "ataba e $iel" an" a""itional proce ing option % or mo"i$ying an e&i ting proce change" circum tance . In ome ca e % a y tem may appear to operate normally% ho#e!er in!ali" "ata may occa ionally appear in a "ataba e. In the e ca e % error checking co"e can be a""e" into the y tem to trigger a me age #hen the in!ali" re ult are pro"uce". Thi may enable the problem to be locate" by trapping the error a it occur % enabling the "ata input an" proce ing tep to be i"enti$ie". Alternately% in a batch proce con"ition #a "etecte". the "ata coul" "ue to

be #ritten to a log $ile #hen the in!ali"

37*

Maintenance change can ha!e a high error rate% particularly in $unction/"ri!en rather than proce /"ri!en y tem . Thi i relate" to the $act that the co"e may be un$amiliar. Al o% the y tem "e ign i $roAen% an" change mu t be ma"e #ithin the e&i ting tructure. Thi i in contra t to general "e!elopment% #hen the tructure o$ the co"e i $lui" an" can e!ol!e a ne# co"e i a""e" to the y tem. In general% maintenance change may be a$er #hen they u e the ame co"ing tyle an" tructure a the e&i ting co"e. Al o% implementing the minimum number o$ change re'uire" to correct the problem i le likely to intro"uce ne# bug than i$ e&i ting co"e i al o re/#ritten.

372

Te ting that a maintenance change ha not "i turbe" other proce e can be "one by running a et o$ proce e an" pro"ucing "ata an" output be$ore the change i ma"e. The ame proce e can be re/run a$ter the change to check that other problem ha!e not appeare". ;nhancement are larger change that a"" ne# $eature to the y tem. The e change may be "one on a pro<ect ba i an" inclu"e the $ull analy i an" "e ign tage . At a co"ing le!el% problem are le u e"% an" the co"e i likely to

occur i$ the e&i ting y tem tructure are tructure" in a imilar #ay to the e&i ting co"e #ithin the y tem. An e&ample #oul" be a""ing a mo"ule $or a ne# report to a y tem.

375

In thi ca e% the co"e tructure u e" $or the other report mo"ule coul" al o be u e" $or the ne# mo"ule. In general% minor bug an" problem houl"

be re ol!e" #here po ible. A bug that appear to be a minor problem may be the cau e o$ a more eriou problem in another part o$ the y tem% or may ha!e a greater impact in other circum tance . 8hen a large number o$ maintenance change ha!e been ma"e to a y tem% the control $lo# an" interaction in the co"e can become !ery comple&. Thi can re ult in a change that $i&e one problem% but lea" to a "i$$erent problem appearing. Thi problem can be a""re e" by re/#riting ection o$ co"e that ha!e been ub<ect to a large number o$ maintenance change .

377

4.6.8.

0ultiple So t*are Versions

In ome y tem % multiple !er ion o$ the y tem mu t be "e!elope" an" maintaine" concurrently. Thi may apply #hen cu tomi e" !er ion o$ the program are upplie" to "i$$erent client % or #hen the y tem i pro!i"e" on e!eral operating plat$orm . Multiple !er ion can be implemente" by u ing con"itional compilation% #hich allo# "i$$erent ection o$ co"e to be compile" $or "i$$erent !er ion % keeping multiple !er ion o$ ource co"e $ile % an" u ing con$iguration parameter in $ile or "ataba e to elect proce ing option . ;&ten"ing the general $unctionality o$ a y tem to co!er the range o$ "i$$erent u e may be a better olution in ome ca e .

37:

Maintaining multiple !er ion can lea" to problem #ith tacking ource co"e an" e&ecutable $ile % an" may in!ol!e maintaining larger !olume o$ co"e.

3:0

4.6.19. Develop$ent Processes Su$$ary

'e(elopment Process In$ra tructure 4e!elopment

'escription The "e!elopment o$ general $unction % common routine an" ob<ect tructure .

Application 4e!elopment

4e!elopment o$ co"e to implement application peci$ic $unction an" proce e .

+ro<ect 4e!elopment

4e!elopment o$ a y tem $rom pro<ect ba i .

analy i through to completion on a

;!olutionary 4e!elopment A"/hoc 4e!elopment

)ontinual "e!elopment o$ a y tem 4e!elopment o$ temporary an" un tructure" y tem % uch a te ting program an" pro"ucti!ity tool . 3:1

Fu t/In/Time 4e!elopment

A"apting a y tem to meet changing re'uirement % an" implementing mo"ule a they are "e!elope".

Sy tem Ee"e!elopment

4e!eloping a y tem on a pro<ect ba i to replace an e&i ting y tem.

Maintenance

Minor change to an e&i ting y tem to allo# continue" operation.

;nhancement

A""itional $unction a""e" to an e&i ting y tem.

3:2

".'. S+stem evolution

4.!.1.

)eature & Structural (ro*t1

Sy tem e!olution in!ol!e continually a""ing ne# $eature to a y tem. The e $eature may inclu"e an e&pan ion in the type o$ "ata that can be tore"% an increa e in the range o$ calculation an" $unction that can be per$orme"% an" an increa e in the type o$ report an" "i play that can be generate". The e ne# $eature increa e the comple&ity an" $unctionality o$ the y tem% ho#e!er they "o not a$$ect the tructure o$ the y tem or the concept on #hich it i ba e". A the y tem e!ol!e % change to the tructure an" un"erlying concept o$ the y tem may al o be ma"e.

3:3

Thi inclu"e ab traction% #hich combine peci$ic ob<ect into general concept . Al o% the u age an" purpo e o$ the y tem may al o e!ol!e o!er time. Many y tem are u e" $or ta k that are !ery "i$$erent $rom their original u e . Thi can be a""re e" by changing the ba ic concept on #hich the y tem re t to other tructure . 3or e&ample% a y tem that #a originally a proce ing y tem may e!ol!e into a "e ign tool% or !ice !er a% #hich #oul" in!ol!e "i$$erent co"e tructure an" ba ic $unction . 8hen change are ma"e to y tem $unction an" the y tem tructure no longer matche the $unction that the y tem per$orm % the y tem can become comple& an" un table.

3:,

In thi

ituation% re/aligning the internal

tructure #ith the $unction that are per$orme" may lea" to a igni$icant re"ucing in co"e !olume% an" an increa e in proce ing pee" an" reliability. )hange occur #hen the y tem i applie" to "i$$erent type o$ proce ing or en!ironment % an" al o #hen techni'ue an" approache change. Thi applie at both the co"ing an" "e ign le!el% an" at the le!el o$ the ob<ect an" proce e that the application u e .

4.!.2.

'bstraction

Ab traction i the proce

o$ combining

e!eral peci$ic ob<ect or concept into a ingle% more general concept.

3:*

Thi applie #ithin the co"e% #ithin the ob<ect an" $unction that are u e" in the application% an" in "ataba e "e ign. The y tem e!olution proce typically

in!ol!e continually a""ing $eature % an" perio"ically combining a range o$ $eature into a ne# ab tract concept. 3or e&ample% in the co"e a number o$ tati tical $unction may be a""e" o!er time. A the number an" comple&ity gro# % the e $unction coul" be replace" #ith a generate "ata et ob<ect that implemente" a range o$ $unction on et o$ "ata. In an application% $ormatting $eature coul" be a""e" to a range o$ ob<ect an" proce e . A the $ormatting $eature become increa ingly comple&% the in"i!i"ual $ormatting $eature coul" be replace #ith a ingle -$ormat. ob<ect that coul" be attache" to any other ob<ect.

3:2

Thi change coul" re"uce the comple&ity o$ the co"e% con oli"ate "ata item #ithin the "ataba e an" make the y tem ea ier to u e an" more $le&ible. 1o#e!er% implementing thi change coul" al o in!ol!e change in a large number o$ "i$$erent co"e ection % an" may al o re'uire a "ataba e or $ile $ormat con!er ion. In a "ataba e tructure e&ample% a "ataba e may initially contain a -cu tomer. table. A the y tem change % a - upplier. an" - hipping agent. table coul" be a""e". The e table contain relate" in$ormation% an" coul" be con oli"ate" into a ingle table u ing a general concept o$ -counterparty..

4.!.3.

C1an(in( t1e Co-e 0o-el

3:5

A a y tem e!ol!e there may be ection o$ co"e that are more uite" to a "i$$erent co"e mo"el than the e&i ting mo"el. 3or e&ample% proce /"ri!en co"e coul" be change" to $unction/"ri!en co"e #hen a large amount o$ "uplication ha" appeare" #ithin the co"e. An e&ample #oul" be #riting a general report/proce ing routine to replace a large number o$ imilar report . 3unction/"ri!en co"e coul" be change" to proce /"ri!en co"e #hen the $unction ha" become comple&% an" coul" be implemente" more ea ily u ing a proce approach.

An e&ample #oul" be a "ata con!er ion an" uploa" $acility that ha" become e&tremely comple&% an" coul" be re/#ritten u ing a number o$ eparate proce /orientate" routine .

3:7

Table "ri!en co"e coul" be implemente" #hen a large number o$ imilar operation ha" appeare" #ithin the co"e% uch a menu item "e$inition an" "e$inition o$ "ata ob<ect . @b<ect orientate" co"e coul" be inclu"e" in a $unction/"ri!en ection o$ co"e. In ome ca e the ob<ectJorientate" tructure mo"el may not be e$$ecti!e in proce /"ri!en co"e% an" tan"ar" proce"ural operation may be impler an" clearer. In ome ca e % a change to a "i$$erent co"e mo"el may commence% an" "uring the re/ #riting it may become apparent that the ne# co"e mo"el #oul" not be an impro!ement on the e&i ting tructure. In thi ca e% the ne#ly/ #ritten co"e can be aban"one" lea!ing the e&i ting tructure in place.

3::

In other ca e % a "ra tic re"uction in co"e iAe an" comple&ity can be achie!e" by changing to a "i$$erent co"e tructure.

4.!.4.

Re*ritin( Co-e

8hen co"e i initially implemente"% the tructure may $ollo# the "e ign an" i"ea behin" the "e!elopment. A$ter the co"e ha been #ritten% it may be able to be con oli"ate" by re#riting ection to impli$y the tructure in the light o$ the $ully #ritten ection o$ co"e. Thi proce can al o be applie" to co"e that

ha been mo"i$ie" e!eral time . In thi ca e% the co"e may "e!elop a comple& control $lo# pattern an" a large number o$ interaction bet#een "i$$erent ection o$ the co"e. Thi can make maintaining the co"e

,00

"i$$icult an" lea" to an increa e" $re'uency o$ bug an" general in tability. Thi ituation can be a""re e" by re#riting

ection o$ co"e to impli$y the tructure an" control $lo#. Ee!ie#ing co"e may be bene$icial i$ a igni$icant perio" o$ time ha elap e" ince the co"e #a "e!elope". In an e!olutionary y tem% there may be a range o$ ubroutine an" $acilitie that coul" be u e" to impli$y the co"e that #ere not a!ailable #hen the co"e #a originally "e!elope".

4.!.4.1. Co$binin( )unctions an0o-ules

8ithin an application% an" al o #ithin the co"e% change to $unction may re ult in t#o mo"ule or application $unction per$orming a imilar proce .

,01

In the e ca e % a ingle proce impli$y the "e ign.

coul" be u e"

to replace the pre!iou proce e an"

4.!.5.

,ro*in( Data Volu$es

4ata !olume generally increa e in y tem o!er time% ometime at "ramatic compoun"ing rate . A "ata !olume gro#% proce e that #ere pre!iou ly per$orme" manually may be automate". Thi re'uire "ata to peci$y the proce ing option an" calculation input . In general% mall "ata !olume may allo# $or $ree/$ormat entry o$ cu tomi e" in$ormation% #hile large "ata !olume generally re'uire $i&e" $iel" that can be u e" to per$orm automate" proce ing.

,02

4.!.6.

Database Develop$ent

A the co"e an" y tem $eature change% the "ataba e tructure may al o change. Similar problem can ari e #ith a number o$ "ataba e table toring imilar "ata% an" incon i tencie bet#een $ormat an" tructure in "i$$erent part o$ the "ataba e. Thi can be a""re e" through changing the "ataba e "e$inition to impli$y the tructure. Thi may in!ol!e merging relate" table an" u ing $iel" attribute to i"enti$y eparate type % or creating ne# table to peci$y in"epen"ent concept that ha!e ari en #ithin e&i ting table .

4.!.!.

Release Cycles

,03

Sy tem that are continually mo"i$ie" are generally relea e" a ne# !er ion on a perio"ic ba i . Minor upgra"e #oul" inclu"e bug $i&e an" minor enhancement % #hile ma<or upgra"e may inclu"e igni$icant ne# $unctionality an" po ibly re'uire "ataba e or $ile $ormat con!er ion . Some y tem that are continually "e!elope" are e$$ecti!ely li!e at all time % #ith change being intro"uce" a oon a they are ma"e.

Thi approach can be u e" #ith maintenance change . 1o#e!er% problem can occur #hen larger an" more $re'uent change are intro"uce" in thi #ay. Te ting a $ull y tem i not $ea ible #hen each in"i!i"ual change i up"ate" eparately to the pro"uction !er ion o$ the y tem.

,0,

Thi may lea" to bug occurring% an" problem that lea" to the incorrect up"ating o$ "ata may be "i$$icult to un#in".

,0*

".(. Code Design

4.".1.

Co-e +nteractions

Ee"ucing interaction bet#een "i$$erent part o$ a y tem can ha!e e!eral bene$it . Sy tem "e!elopment an" maintenance may be ea ier% a one ection o$ co"e can be in"epen"ently mo"i$ie" #ithout the nee" to re$er to other ection o$ co"e. Bug may be re"uce"% a a cau e/an"/e$$ect that i #i"ely eparate" through a y tem can pro"uce problem #hen one part o$ the co"e i change" #ithout relate" co"e ection being up"ate". +ortability i enhance" an" in"epen"ent mo"ule can be u e" in other pro<ect or re#ritten $or other en!ironment .

,02

In general% u ing "ata an" operation that pa through inter$ace bet#een mo"ule % rather than inclu"ing interaction bet#een one co"e ection an" a "i tant co"e ection% re ult in a y tem that i more $le&ible% ea ier to "ebug an" ea ier to mo"i$y.

4.".2.

#ocalisation

6ocali ation in!ol!e grouping the proce ing that in!ol!e a particular !ariable or concept #ithin a mall ection o$ co"e. Thi may in!ol!e "etermining con"ition #ithin a region o$ co"e% an" then pa ing $lag to other ubroutine % rather than pa ing the "ata !alue it el$. 3or e&ample% i$ a !ariable i pa e" through e!eral layer o$ ubroutine an" i then u e" in a con"ition% there i a #i"e eparation bet#een the cau e an" e$$ect o$ the original

,05

"e$inition o$ the !ariable% an" it u e in the con"ition. Thi increa e the interaction bet#een "i$$erent ection o$ the co"e% #hich can make rea"ing an" mo"i$ying the co"e more "i$$icult. I$ the con"ition i te te" in the original location% ho#e!er% an" a Boolean !ariable i pa e" through% then the proce ing o$ the original !ariable i containe" #ithin the original ection o$ co"e. The ubroutine u ing the Boolean $lag #oul" not acce the original "ata !ariable% an" the "i$$erent !alue calling $unction coul" pa

o$ the $lag un"er "i$$erent con"ition . Thi approach re"uce the interaction in the co"e an" lea" to a more $le&ible tructure.

,07

4.".3.

Se7uence Depen-ence

Se'uence "epen"ence relate to the i ue o$ calling $unction in a particular or"er. )o"e that i hea!ily "epen"ant on the or"er o$ e&ecution can be more "i$$icult to "e!elop an" maintain than co"e that inclu"e ubroutine an" general $unction that can be calle" in any or"er. 3or e&ample% a graphic engine may inclu"e $unction $or initiali ing the engine% "e$ining light % loa"ing ob<ect % "e$ining ur$ace te&ture % "e$ining backgroun" an" "i playing the image. In a e'uence "epen"ant tructure% each o$ the e $unction #oul" nee" to be per$orme" in a particular or"er. I ing a e'uence/in"epen"ent approach% the ame $unction coul" be calle" in any or"er. 9ali" re ult #oul" be pro"uce" regar"le

,0:

o$ the particular or"er that the ubroutine #ere calle" in. A certain or"er may till be re'uire" $or operation that are logically relate"% rather than relate" imply "ue to the co"e implementation. 3or e&ample% the te&ture o$ an ob<ect coul" not be "e$ine" until the ob<ect it el$ ha" been "e$ine". 1o#e!er% the lighting coul" be "e$ine" be$ore the ob<ect #ere loa"e"% or the ob<ect coul" be loa"e" be$ore the lighting #a "e$ine"% a the e are in"epen"ent element . Se'uence/in"epen"ence increa e the $le&ibility o$ $unction % a a #i"er range o$ re ult may be pro"uce" u ing "i$$erence combination o$ call to the ubroutine .

,10

Al o% le

in$ormation nee" to be taken into

account #hen "e!eloping a ection o$ co"e% #hich may impli$y y tem "e!elopment. Se'uence "epen"ence i re"uce" #hen $unction are "irectly mappe". Thi re ult in the ame re ult or proce regar"le being per$orme"% o$ pre!iou action . Subroutine

that operate in thi #ay can be calle" in any or"er% an" #oul" pro"uce the ame re ult $or the peci$ie" input. Speci$ically% the u e o$ tatic an" global !ariable in ubroutine can intro"uce e'uence "epen"ence. Thi ari e "ue to the $act that the re ult o$ the ubroutine may be relate" to e&ternal con"ition % or to pre!iou call to the ubroutine. Thi may re ult in a "i$$erent or"er o$ e&ecution o$ the ame ubroutine call pro"ucing a "i$$erent re ult.

,11

Se'uence in"epen"ence can be implemente" by eparating the "e$inition o$ ob<ect an" attribute $rom the proce ing tep in!ol!e"% or by checking that any pre/re'ui ite $unction ha!e alrea"y been run.

4.".3.1. @ust5+n5Ti$e Processin(

Se'uence in"epen"ence can be implemente" u ing a -<u t/in/time. approach to proce ing an" calculation. Eather than per$orming each proce ing tep a it i calle"% a et o$ attribute coul" be "e$ine" a$ter each $unction call. 8hen the $inal $unction call i per$orme"% uch a the ubroutine to "i play the image% the entire proce ing i per$orme" in or"er u ing the attribute that #ere peci$ie".

,12

Thi approach eparate the internal proce ing or"er $rom the or"er o$ e&ternal call to the ubroutine . The mo"el u e" in thi approach i an attribute an" "ata ob<ect mo"el% rather than a proce an" tran $ormation mo"el.

In thi mo"el% each call to the ubroutine "e$ine a et o$ attribute % rather than e&ecuting a proce . 3or e&ample% the generation o$ a graphic image coul" in!ol!e loa"ing #ire$rame tructure % mapping te&ture to ob<ect % applying lighting an" generating the image. @ne approach #oul" be to call a ubroutine $or each tage in the proce . 1o#e!er% the e operation may nee" to be per$orme" in or"er. Another approach #oul" be to implement imilar ubroutine call that imply "e$ine"

,13

the ob<ect % te&ture an" lighting% #ith all the proce ing being per$orme" #hen the $inal -generate image. ubroutine #a calle". Thi econ" approach #oul" allo# the call to be per$orme" in any or"er.

4.".3.2. Pre5re7uisite C1ec2in(

Another approach in!ol!e each ubroutine checking that any pre/re'ui ite ubroutine ha" been run. 8hen each proce up"ate". 8hen a ubroutine commence it coul" check the $lag that #ere relate" to any pre/ re'ui ite $unction % an" call the rele!ant ubroutine be$ore per$orming it o#n proce ing. i per$orme"% a $lag coul"

be et to in"icate that the "ata ha" been

,1,

Thi approach a!oi" making a umption about pre!iou e!ent % an" #oul" allo# the ubroutine to be u e" in a #i"er range o$ e&ternal circum tance . 8hen all ubroutine #ere implemente" thi may% the e'uence o$ call in the main routine coul" be replace" #ith a ingle call to the $inal routine% #hich #oul" lea" to a back#ar"/chaining erie o$ ubroutine call % $ollo#e" by a $or#ar" chain o$ e&ecution.

4.".4.

Direct 0appin(

A ubroutine or inter$ace $unction i "irectly mappe" i$ the operation that are per$orme" are completely peci$ie" by the input parameter . Thi occur #hen the re ult o$ the ubroutine are not a$$ecte" by pre!iou call

,1*

to the ubroutine or by "ata in other part o$ the y tem. 4irect mapping can be implemente" by pa ing all the "ata that a ubroutine u e a parameter to the ubroutine. 4irectly mappe" ubroutine are e'uence in"epen"ent% a their re ult are not a$$ecte" by pre!iou operation . Thi enable "irectly mappe" ubroutine to be calle" in any combination an" in any or"er. In"irect mapping i create" by toring internal tatic "ata that retain it !alue bet#een call to the ubroutine% or by acce ing "ata out i"e the ubroutine. 3or e&ample% the ubroutine -li tUne&tUentry(). i not "irectly mappe"% a thi ubroutine return the ne&t item in the li t a$ter the pre!iou call to the ubroutine.

,12

In contra t% the ubroutine -li tUne&tUentry( currentUentry ). i "irectly mappe"% an" #oul" return the ame re ult $or any gi!en !alue o$ -currentUentry.% regar"le o$ pre!iou operation .

4irect mapping can increa e $unctionality by enabling call to the ubroutine $rom "i$$erent co"e ection to o!erlap #ithout con$licting% a #ell a intro"ucing e'uence in"epen"ence. 3or e&ample% the $ir t !er ion o$ the ubroutine allo# only one pa through the li t at a particular time. 1o#e!er% u ing the "irectly mappe" !er ion% multiple in"epen"ent o!erlapping can o$ the li t coul" be per$orme" by "i$$erent ection o$ the co"e% #ithout con$licting. A re"uction in e&ecution pee" coul" occur #hen a earch i re'uire" to locate the

,15

current po ition% uch a the -currentUentry. !ariable in the pre!iou e&ample. Thi problem can be re"uce" by recor"ing an internal tatic cache !alue o$ the pre!iou call to the ubroutine% an" u ing that !alue i$ the parameter peci$ie the pre!iou call a the current po ition. Thi "oe not intro"uce e'uence "epen"ence or in"irect mapping% a the tatic !ariable i only u e" to increa e e&ecution pee" an" "oe not a$$ect the actual re ult. Another e&ample concern a ubroutine -getUcurrentU creenU$iel"().% #hich return the te&t !alue that i hel" in the current creen $iel". In thi ca e the in"irect mapping i not "ue to tatic "ata relating to pre!iou call to the ubroutine% but i "ue to acce ing a !ariable out i"e the ubroutine.

,17

Thi co"e coul" be re/#ritten a -getU creenU$iel"( $iel" ).% in #hich ca e the $unction i "irect/mappe" an" coul" be u e" to retrie!e the !alue o$ any $iel" on the creen. Subroutine #ritten in a "irectly mappe" #ay may be more $le&ible an" ea ier to u e that ubroutine that inclu"e in"irect mapping. Interaction bet#een "i$$erent ection o$ the co"e are al o re"uce" #hen ubroutine are "irectly mappe".

4.".5.

De ensive Pro(ra$$in(

4e$en i!e programming i a co"ing tyle that attempt to increa e the robu tne o$ co"e by checking input "ata% an" by making the minimum number o$ a umption about con"ition out i"e the ubroutine.

,1:

Eobu t co"e i co"e that re pon" to in!ali" "ata by generating appropriate error con"ition % rather than continuing proce ing an" generating in!ali" re ult % or pre$orming an operation that lea" to a y tem cra h% uch a attempting to "i!i"e a number by Aero. 4e$en i!ely co"e" routine may al o check their o#n output be$ore completing. 3or e&ample% a proce that pro"uce $igure may check that the $igure balance to other $igure or are con i tent in ome other #ay. )hecking output re ult "oe not a$$ect the robu tne o$ the in"i!i"ual routine again t throughout the e&ternal problem ho#e!er thi approach may increa e robu tne y tem.

4.".5.1. +nput Data

,20

)hecking input parameter may in!ol!e t#o i ue . 9alue can be checke" to en ure that incorrect operation are not per$orme"% uch a attempting to acce a null pointer or proce ing a loop that #oul" ne!er terminate. Al o% check can be per$orme" to "etect error % uch a negati!e number in a li t that houl" not contain negati!e number % or #eight that "o not um to 1. 8hen li t are canne" an" calculation are per$orme"% check o$ e&i ting $igure can al o be ma"e #hile other proce ing i being per$orme".

4.".5.2. 'ssu$ptions about Previous %vents

)hecking pre!iou operation an" con"ition out i"e the ubroutine can be "one by checking $lag that are et by other proce e .

,21

8hen a pre/re'ui ite proce

ha not been

per$orme"% the ubroutine can run the rele!ant $unction be$ore continuing.

4.".6.

Se($entation o )unctionality

4.".6.1. )unctional 'pplications

In many y tem the co"e can be groupe" into e!eral ma<or area . Thi may inclu"e the u er inter$ace co"e% calculation co"e% graphic an" image generation% "ataba e up"ating etc. In $unctional application uch a o$t#are

tool % eparating the co"e into ma<or area may re"uce the number o$ interaction bet#een "i$$erent ection o$ the co"e.

,22

Thi may lea" to a y tem that i more $le&ible an" ea ier to maintain% a each ection per$orm in"epen"ent $unction an" can be mo"i$ie" #ithout the nee" to re$er to other part o$ the y tem.

4.".6.2. Process5Driven 'pplications

In proce /"ri!en y tem

uch a "ata may re ult in

proce ing application % eparating the co"e by $unction in tea" o$ proce an internal tructure that i completely "i$$erent $rom the tructure o$ the application it el$. 3or e&ample% the application may con i t o$ e!eral $unctional mo"ule % uch a an accounting mo"ule% an a"mini tration mo"ule% a pro"uct reporting mo"ule etc. I ing a proce /"ri!en co"e tructure% each application mo"ule #oul" contain the co"e

,23

relating to that application mo"ule% inclu"ing the u er inter$ace co"e% calculation % "ataba e up"ating etc. 1o#e!er% i$ the e $unction #ere groupe" internally into eparate ection % thi coul" re ult in a igni$icant re"uction in the total co"e iAe an" re"uce incon i tencie . Thi proce #oul" al o re ult in a y tem

that #oul" pro!i"e $acilitie to enable ne# application mo"ule to be "e!elope" #ith a minimum amount o$ co"e. In contra t% the "e!elopment o$ ne# proce /orientate" mo"ule i not a$$ecte" by the "e!elopment o$ pre!iou mo"ule .

4.".6.3. +$ple$entation

Separating $unction can be "one by creating ma<or ection #ithin the co"e that contain relate" $unction . The e coul" be acce e"

,2,

through a "e$ine" et o$ ubroutine call an" operation . The e mo"ule coul" be e&ten"e" to create proce ing engine . 3or e&ample% a calculation engine may per$orm a range o$ general calculation an" numeric proce ing operation . The engine #oul" be acce e" through a clearly "e$ine" inter$ace o$ "ata an" $unction % an" may be calle" "irectly or may e&ecute in"epen"ently o$ the main program. ;ach ection only remain in"epen"ent #hile it "oe not contain proce ing that relate to another ection o$ the y tem. 3or e&ample% a calculation ection #oul" not contain inputNoutput proce ing% uch a creen% $ile or printing operation . Thi approach allo# the co"e ection to be u e" a an in"epen"ent unit.

,2*

+ortability bet#een "i$$erent y tem i al o impro!e" #ith the approach. Maintenance an" "ebugging o$ a co"e ection may al o be impler #hen the ection contain only one type o$ relate" operation. A""itionally% mo"ule uch a calculation

engine an" graphic $acilitie "e!elope" in thi #ay coul" al o be u e" #ith other pro<ect .

4.".!.

Subroutines

4.".!.1. Selection

In general% co"e i

impler an" clearer #hen

a collection o$ mall ubroutine i u e"% rather than a number o$ larger ubroutine .

,22

8here a loop contain

e!eral tatement %

the e may be plit into a eparate ubroutine. Thi re ult in pro"ucing t#o ubroutine . @ne ubroutine contain looping but no proce ing% #hile the other contain proce ing an" no looping. 8hen a large ubroutine contain eparate

block o$ co"e that are not relate"% each ma<or block coul" be plit into a eparate ubroutine. 8hen co"e that per$orm a imilar logical operation e&i t in e!eral part o$ a y tem% thi coul" be groupe" into a ingle ubroutine 3or e&ample% "i$$erent ection o$ co"e may can an" up"ate part o$ the ame "ata tructure% or per$orm a imilar calculation. The !ariation in the proce coul" be

han"le" by pa ing $lag to the ubroutine% or by toring $lag #ith the "ata tructure it el$%

,25

o that the ubroutine coul" automatically "etermine the proce ing that #a re'uire". )o"e that #a imilar by coinci"ence but

per$orme" logically in"epen"ent operation % uch a calculation routine $or t#o in"epen"ent pro"uct % houl" not generally be combine" into a ingle ubroutine.

4.".!.2. )la(s

Subroutine are more general i$ they are pa e" $lag an" in"i!i"ual option % rather than being pa e" "ata an" then te ting con"ition "irectly. 3or e&ample% a ubroutine may be pa e" a Boolean $lag to peci$y an option% uch a orting a li t in a cen"ing or "e cen"ing or"er.

,27

@ther option coul" al o be pa e". 3or e&ample% the key o$ a "ata et coul" be pa e"% rather than an entire tructure type that containe" the key a one "ata item. I ing $lag an" option allo# the ubroutine to be calle" in "i$$erent #ay $rom "i$$erent part o$ the co"e. Al o% u ing $lag allo# the ubroutine to per$orm "i$$erent combination o$ proce ing% in contra t to checking the "ata "irectly% #hich may re ult in a $i&e" re ult "epen"ant on the "ata. Interaction #ith "i$$erent part o$ the co"e may al o be re"uce".

4.".".

'uto$atic Re5,eneration

,2:

In ome ca e a et o$ input "ata an" calculate" re ult may be tore" in a "ata tructure. I$ the input "ata i change"% the calculate" re ult may nee" to be re/generate". Innece ary re/calculation can be a!oi"e" by inclu"ing a tatu $lag #ithin the "ata tructure. 8hen the input $igure are change"% the tatu $lag i et to in"icate that the calculate" re ult are no# in!ali". 8hen a re'ue t i ma"e $or a calculate" $igure% the tatu $lag i checke". I$ the $lag i et% then a recalculation i per$orme" an" the $lag i cleare". Thi approach enable multiple change to the input "ata to be ma"e #ithout generating repeate" re/calculation % an" allo# multiple

,30

re'ue t $or calculate" re ult to be ma"e #ithout re'uiring multiple re/calculation . Thi approach can only be u e" #hen the calculate" re ult are acce e" !ia ubroutine % rather than being acce e" "irectly a "ata !ariable .

,31

4.".8.

Co-e Desi(n +ssues Su$$ary

'esign )ssue Interaction

'escription Interaction bet#een "i tant part o$ a program% through global !ariable % tatic !ariable or chain o$ ubroutine call % can make program more "i$$icult to "ebug an" mo"i$y.

6ocali ation

=rouping proce ing relating to a ingle "ata item or tructure into a mall ection o$ co"e may make co"e ea ier to rea" an" mo"i$y.

Se'uence 4epen"ence

Subroutine that can be calle" in any or"er% an" #hich pro"uce the ame re ult regar"le o$ pre!iou e!ent % may be more $le&ible than alternati!e approache .

+re/re'ui ite checking

)hecking #ithin a ubroutine that pre!iou $unction ha!e been per$orme"% an" e&ecuting them i$ ,32

nece ary% may increa e the $le&ibility an" generality o$ a ubroutine. 4irect Mapping Subroutine that pro"uce a re ult parameter can make program bug cau e" by une&pecte" interaction . 4e$en i!e +rogramming Subroutine may be more robu t that i pa e"% check e&ternal "ata that i u e"% an" make a minimum number o$ a umption about pre!iou e!ent an" current con"ition . Segmentation o$ $unctionality Separating ma<or component o$ a y tem into eparate ection may an" more reliable y tem % a each component can be "e!elope"

that i completely peci$ie" by their

"e!elopment ea ier an" may re"uce

#hen they check the parameter "ata

lea" to ea ier program "e!elopment

in"epen"ently. )lear inter$ace may

,33

be u e$ul in "e igning general $unctional component . Subroutine Selection Sy tem compo e" o$ a large number o$ mall ubroutine may be ea ier to interpret% "ebug an" mo"i$y that y tem compo e" o$ e!eral large an" comple& ubroutine . Se!eral mall ubroutine may be clearer than a ingle comple& ubroutine. Subroutine +arameter Subroutine may be more general% an" interaction may be re"uce"% #hen ubroutine are pa e" $lag an" option % rather than "ata u e" $or internal con"ition . 4ata u e" in internal con"ition cau e interaction #ith "i tant co"e an" re ult in a $i&e" outcome $or an in"i!i"ual "ata con"ition.

,3,

".*. Coding
)o"ing i the proce co"e. o$ #riting the program

4.8.1.

Develop$ent o Co-e

Although a general "e ign may be planne"% the "irection that !ariou ection o$ the co"e take may not become apparent until the co"ing i actually in progre . Some $unction turn out to be more comple& an" "i$$icult to implement than #a originally e&pecte"% #hile other may turn out to be con i"erably impler. An initial "e!elopment o$ the co"e coul" re ult in creating a et o$ me"ium/ iAe" ubroutine to per$orm the !ariou $unction .

,3*

A$ter the e are #ritten% the co"e coul" be con oli"ate" by e&tracting common ection into maller ubroutine . Thi proce lea" to a larger number o$

maller ubroutine % an" generally clearer an" impler co"e. Attempting to pre"ict the u e$ul ubroutine in a"!ance can lea" to #riting co"e that i not u e". Al o% the tructure o$ the co"e become arti$icially con traine"% rather than changing in a $lui" #ay a "i$$erent ection are re/#ritten to impli$y the proce ing. Thi approach applie particularly to $unction/"ri!en co"e% #hich u e a range o$ general/purpo e $unction an" "ata tructure . Thi approach i le proce /"ri!en co"e applicable to

,32

4.8.2.

Robust Co-e

The reliability o$ co"e i "etermine" #hen it i #ritten% not "uring the te ting pha e. A co"e i #ritten% the i"ea an" tructure that are being implemente" are u e" to $orm complete ection o$ co"e. Thi i the time at #hich the interrelation bet#een !ariable % concept an" operation are mentally combine" into a ingle #orking mo"el. 9ariou i ue are re ol!e" "uring thi proce % uch a the han"ling o$ all input "ata combination an" con"ition % implementing the $unction that the co"e ection upport % an" re ol!ing problem #ith inter$ace to other ection o$ co"e. I$ co"ing commence on a "i$$erent ection o$ the y tem #hile i ue remain

,35

unre ol!e"% thi may lea" to problem occurring at $uture time . Eobu t co"e #oul" generally re pon" to in!ali" "ata by generating appropriate error con"ition % rather than continuing program operation an" pro"ucing in!ali" output or attempting an operation that re ult in a y tem cra h% uch a attempting to "i!i"e a number by Aero.

4.8.3.

Data 'ttributes Vs. Data

Structures

4ata in relate" but "i$$erent tructure can be tore" in eparate "ataba e table an" tructure % or combine" into a ingle tructure an" i"enti$ie" eparately u ing a "ata !ariable. 4ata tructure % co"e an" $unction are generally impler an" more $le&ible #hen a

,37

"ata !ariable i u e" to i"enti$y eparate type o$ "ata% rather than creating eparate tructure . 3or e&ample% corporate client an" in"i!i"ual client coul" be tore" a eparate "ataba e table an" program tructure . 1o#e!er% a the e t#o ob<ect recor" imilar $un"amental "ata% they coul" be combine" into a ingle table. I$ a large number o$ $iel" apply to only one type% thi can be plit into a eparate table #ith a one/to/one "ataba e link. 1o#e!er% #hen the number o$ $iel" i not e&ce i!e% a ingle table may be the impler olution. A another e&ample% creating a e!eral eparate table $or "i$$erent pro"uct #oul" lea" to a more comple& y tem than u ing a ingle table% #ith "ata $iel" to i"enti$y pro"uct option an" calculation .

,3:

4.8.4.

#ayout

The !i ual layout o$ co"e i important. 8riting% "ebugging an" maintain co"e i igni$icantly ea ier #hen the co"e i lai" out in a clear #ay. )lear layout can be achie!e" #ith the ample u e o$ #hite pace% uch a tab % blank line an" pace . )o"e #ritten in language that u e control/ $lo# tructure % uch a -i$. tatement % can be in"ente" $rom the tart o$ the line by an a""itional le!el $or each ne te" co"e block. 3or e&ample% tatement #ithin an -i$. tatement may be #ritten #ith an a""itional 2% , or 7 pace at the tart o$ the line% to i"enti$y the ne ting o$ the co"e #ithin the -i$. tatement.

,,0

)on i tency in a layout tyle throughout a large ection o$ co"e lea" to co"e that i ea ier to rea". 3or e&ample% the $ollo#ing co"e u e $e# pace an" "oe not in"ent the co"e to re$lect the change in control $lo#.

for(i=3Hi"ma%_treesHi++) I if(Jtree_tableKiL6 active)I tree_tableKiL6usage_count=#H tree_tableKiL6head_node=ne! nodeH tree_tableKiL6active=TRM8HN queue=queue_headH !hile(queueJ=@MGG)Iif(queue $tree==i) queue $active=TRM8H queue=queue $ne%tH N N

The $ollo#ing co"e i i"entical to the pre!iou e&ample% ho#e!er it inclu"e a""itional pace % u e a con i tent layout ,,1

tyle throughout the co"e% an" i in"ente" to re$lect the ne ting tructure o$ the co"e block .
for (i=3H i " ma%_treesH i++) I if (J tree_tableKiL6active) I tree_tableKiL6usage_count= #H tree_tableKiL6head_node = ne! nodeH tree_tableKiL6active = TRM8H N queue = queue_headH !hile (queue J= @MGG) I if (queue $tree == i) queue $active = TRM8H queue = queue $ne%tH N N

,,2

4.8.5.

Co$$ents

A comment i te&t that i inclu"e" in the program co"e $or the bene$it o$ a human rea"er% an" i ignore" by the compiler. )omment are u e$ul $or a""ing a""itional in$ormation into the co"e. Thi may inclu"e $act that are rele!ant to the ection o$ co"e% an" general "e cription o$ the proce e being per$orme". 8hen a ubroutine contain a large number o$ in"i!i"ual tatement % comment can be u e" to eparate the tatement into relate" ection . The $ollo#ing e&ample contain t#o comment that a"" in$ormation that may not be rea"ily "etermine" $rom rea"ing the co"e

7 ) 'ear is a leap 'ear if it is divisible b' four, is not 7 divisible b' #33, or is divisible b' 233

,,3

if ('ear mod 2 = 3 and 'ear mod #33 "$ 3) or 'ear mod 233 = 3) then is_leap_'ear = true else is_leap_'ear = false end

7 reduce value b' # da'9s interest for (ebruar' +1th if is_leap_'ear then value = value * (# + rate*-.4) end

,,,

The $ollo#ing co"e illu trate the u e o$ comment to eparate group o$ relate" tatement

subroutine process_model() 7 intialse graphics engine and load model graphics6initialise graphics6allocate_data read_model graphics, model

7 update graphics image graphics6define_lights light_table grphics6define_vie!point config_date grphics6displa'

7 generate report process_report_data print_report end

,,*

4.8.6.

Variable <a$es

The choice o$ !ariable name can ha!e a igni$icant impact on the rea"ability o$ program co"e. 9ariable name that "e cribe the "ata item% uch a -currU"ay. an" -totalU#eight . a"" more in$ormation into the co"e than !ariable name that are general term or -amount.. Single letter !ariable name are ometime u e" a loop !ariable % a thi impli$ie the appearance o$ the co"e an" allo# the rea"ing to $ocu on the operation that are being per$orme". uch a -count.

,,2

3or e&ample% the letter -i. an" -<. are ometime u e" a loop !ariable . Thi u age $ollo# the con!ention u e" in mathematic an" early !er ion o$ 3ortran% #here the letter -i.% -<. an" -k. are u e" $or array in"e&e . Thi particularly applie to canning array that are u e" to tore li t o$ "ata. In other ca e % the u e o$ a $ull name $or a loop !ariable% uch a -currU"ay. or -me h. may lea" to clearer co"e. Thi may apply #hen the item in an array are acce e" "irectly an" the in"e& !alue it el$ repre ent a particular "ata item. Some co"ing con!ention a"" e&tra letter into the !ariable name% or change the ca e% to "e cribe the "ata type o$ a !ariable or it cope. 3or e&ample% -i4ay. may be an integer !ariable% an" the upperca e letter in

,,5

-+rintU"e!ice. may in"icate that the !ariable i a global !ariable. )on tant may be i"enti$ie" #ith a co"e or #ith a ca e change% uch a the u e o$ upperca e letter $or a con tant name. I ing "i$$erent !ariable name that "i$$er only by ca e or punctation% uch a -6i t1ea".% -li thea". an" -li tUhea". can make rea"ing an" interpreting co"e more "i$$icult. Ambiguou name can al o re ult in co"e that can be "i$$icult to interpret. 3or e&ample% the #or" -output. can be both a noun an" a !erb. The name -reportUoutput. coul" mean -output (print) the report.% or -thi i the report output.. In ome ca e % !ariable at "i$$erent le!el o$ cope may ha!e the ame name. 3or

,,7

e&ample% a local !ariable may be "e$ine" #ith the ame name a a global !ariable. In the e ca e % the name i taken to re$er to the "ata item #ith the tighte t le!el o$ cope. Eea"ing the co"e may be more "i$$icult in the e ca e a an in"i!i"ual name may ha!e "i$$erent meaning in "i$$erent ection o$ the co"e.

4.8.!.

4oolean Variable <a$es

The name o$ Boolean !ariable may be ea ier to rea" i$ the #or" -not. i not inclu"e" #ithin the !ariable name% an" i$ the !alue i tate" in the po iti!e $orm rather than the negati!e $orm. Thi a!oi" the u e o$ "ouble/negati!e in e&pre ion % #hich in!ol!e re!er ing the

,,:

"e cription o$ the !ariable to "etermine the actual con"ition being te te". 3or e&ample% the $lag -!ali". coul" al o be name" -notU!ali".% -in!ali". or -notUin!ali".. 4epen"ing on the con"ition% the other $orm may be le imple po iti!e $orm. clear that the

4.8.".

Variable :sa(e

)o"e may be ea ier to rea" #hen there i a one/to/one corre pon"ence bet#een a "ata concept an" a "ata !ariable. In general% a ingle "ata !ariable houl" not be u e" $or t#o "i$$erent purpo e at "i$$erent point #ithin the co"e. Al o% t#o "i$$erent "ata !ariable houl" not

be u e" to repre ent the ame $un"amental "ata item at "i$$erent point in the co"e.

,*0

Thi i ue relate to u age #ithin a common le!el o$ cope% uch a local !ariable #ithin a ubroutine% or mo"ule/le!el !ariable #ithin a mo"ule. 3or e&ample% the item in a li t may be counte" u ing one !ariable% an" thi !alue may then be a igne" to a "i$$erent !ariable $or $urther calculation . In another ca e% a !ariable may be u e" to tore a !alue $or a calculation in an early part o$ the ubroutine. The ame !ariable may then be u e" to tore an unrelate" !alue in a later part o$ the co"e. In the e ca e % the co"e may be mi interprete" #hen $uture change are ma"e% lea"ing to an increa e" chance o$ $uture bug .

,*1

4.8.8.

Constants

In mo t language % a $i&e" number or tring #ithin the co"e can be "e$ine" a a -con tant.. A con tant i a name that i imilar to a

!ariable name% but ha a $i&e" !alue. The u e o$ con tant allo# all the $i&e" !alue to be groupe" together in a ingle place #ithin the co"e. Al o% #hen a con tant i u e" in e!eral place % thi en ure that the ame !alue i u e" in each place% an" a!oi" po ible bug #here one !alue i up"ate" but another i not. Storing con tant #ithin the program co"e i kno#n a har"/co"ing. Thi re"uce the $le&ibility o$ the co"e% a a program change i re'uire" #hene!er a con tant !alue i change".

,*2

The $le&ibility o$ a y tem may be increa e" i$ con tant are tore" in "ataba e recor" or con$iguration $ile . Alternati!ely% in ome ca e the u e o$ a con tant !alue can be replace" by !ariable !alue or $lag . 3or e&ample% a con tant !alue that peci$ie" a particular recor" key coul" be replace" by a $lag on the recor" that in"icate" that a particular proce houl" occur.

A another e&ample% a con tant number% uch a a proce ing !alue% coul" be replace" by a tan"ar" "ataba e $iel" containing a !ariable !alue. )on tant are u e$ul $or !alue that are $i&e" or change rarely% uch a the "ay o$ the #eek% cienti$ic con tant % or a pro"uct name. )on tant are al o by u e" $or $i&e" !alue that are u e" in programming con truction %

,*3

uch a en"/o$/li t marker % co"e u e" in "ata tran mi ion% interme"iate co"e etc. The name o$ the con tant re$er to the meaning o$ the "ata% not it !alue. T#o !alue that #ere the ame by coinci"ence% uch a the iAe o$ t#o "i$$erent array type % houl" be "e$ine" a t#o eparate con tant !alue . =enerally a har"/co"e" !alue houl" not be inclu"e" in a program to repre ent "ata that coul" be in"epen"ently change"% uch a the key o$ a "ataba e recor". Inclu"ing con tant uch a thi #oul" "ecrea e the $le&ibility o$ the program% an" #oul" lea" to incorrect proce ing i$ the "ata !alue #a change". 8hen proce ing applie" to a certain recor"% thi coul" be peci$ie" by inclu"ing an option $lag on the recor" it el$.

,*,

4.8.19. Subroutine <a$es

Subroutine name may con i t o$ e!eral #or" . 8hen the ubroutine name contain a noun an" a !erb% thi can be li te" in either or"er. 3or e&ample% the $ollo#ing co"e "e$ine !ariable in the !erb/noun or"er.
define_report format_report print_report

Thi u age $ollo# the u ual e'uence o$ a entence. The oppo ite $orm% in the noun/ !erb or"er% can al o be u e"
report_define report_format report_print

,**

Thi approach group relate" $unction together% an" highlight the "ata ob<ect rather than the $unction. )o"e #ritten in thi #ay ha a clearer eparation bet#een the in"i!i"ual ob<ect an" $unction . Thi approach i u e" in ob<ect orientate" programming.

4.8.11. %rror .an-lin(

;rror occur #hen an in!ali" con"ition i "etecte" #ithin a ection o$ program co"e. Thi may be "ue to a program bug% or it may be the re ult o$ the "ata that ha been u e" in the calculation or proce . ;rror at the co"ing le!el inclu"e problem that lea" to y tem cra he or hanging% an" problem #ith "ata an" "ata tructure .

,*2

Sy tem problem inclu"e attempt to "i!i"e a number by Aero% loop that ne!er terminate% an" attempting to acce an in!ali" pointer or an ob<ect that ha not been initiali e". 4ata problem inclu"e li t that are empty #hen they houl" contain "ata% "ata #ithin a tructure that contain too many or too $e# entrie % or an incorrect et o$ !alue $or the proce being per$orme". le!el% error may inclu"e input

At the proce

"ata that i in!ali"% mi ing "ata% an" input "ata that i !ali" but pro"uce re ult that are out i"e e&pecte" range .

4.8.11.1.%rror Detection

;rror can be "etecte" by u ing error checking co"e.

,*5

The e tatement "o not alter the re ult o$ the proce % but are inclu"e" to "etect error at an early tage. Thi i u e" to a i t in the "ebugging proce % an" to pre!ent incorrect "ata being tore" an" incorrect re ult $rom being pro"uce". ;rror "etection can in!ol!e checking "ata !alue at point in the proce e&pecte" range . At the proce le!el% check coul" inclu"e $or !alue that are negati!e% Aero% an empty tring% or out i"e

per$orming re!er e calculation % canning output "ata tructure $or in!ali" !alue an" combination % an" checking the relation hip bet#een !ariou !ariable to en ure that the output !alue are con i tent #ith each other an" #ith the input !alue . ;rror "etection co"e may a"" comple&ity an" !olume to the co"e an" lo# e&ecution.

,*7

1o#e!er% thi co"e may al o impli$y "ebugging an" "etect error that #oul" other#i e lea" to incorrect output. A""ing permanent error check that are imple an" e&ecute 'uickly can be u e" to increa e the robu tne o$ the co"e.

4.8.11.2.Response to %rrors

8hen an error con"ition i "etecte"% !ariou action can be taken. ;rror #ithin general ubroutine an" $unction may be han"le" by returning an error tatu con"ition to the calling routine. Alternati!ely% in ome language an" ituation an e&ception i generate"% an" thi e&ception re ult in program termination unle it i trappe" by an error/han"ling

,*:

routine. The error han"ling routine i automatically calle" #hen the e&ception con"ition ari e . 8hen the error occur #ithin a main proce ing $unction% an error me age may be "i playe" $or an interacti!e proce % or logge" to an error log $ile $or a batch proce . 3ollo#ing the error% the proce re ult% or the current proce may

continue operation an" pro"uce a partial may terminate.

4.8.11.3.%rror 0essa(es

;rror me age may inclu"e in$ormation that i u e" in the "ebugging proce .

,20

In$ormation that can be inclu"e" in an error me age inclu"e the $ollo#ing point B An error number. A "e cription o$ the error. The place in the program #here the error occurre".

The "ata that cau e" the error. Eelate" ma<or "ata key that can be u e" to locate the item. A "e cription o$ the action that #ill be taken $ollo#ing the error. +o ible cau e o$ the error. Eecommen"e" action . Action to a!oi" the error i$ the "ata i actually correct. A li t or "e cription o$ alternati!e "ata that #oul" be !ali".

,21

3or e&ample -;EE@E +23,*B A negati!e policy contribution o$ [/12.3, i recor"e" $or policy number 00525000,, on 12N03N7*. Mo"ule +rintStatement% Subroutine )alcBalance.

-;EE@E :3,B Mo"el -Shell+ro$ile. ha no me h type. Thi error may occur i$ the con!er ion $rom !er ion 3.52 ha not been complete". I$ thi mo"el i a continuou / ur$ace mo"el% the option -continuou mo"el parameter ur$ace. in the creen can be

electe" to enable correct calculation. Mo"ule Een"erMe h% Subroutine Me h)ount.

,22

In ome ca e % help in$ormation i inclu"e" #ith an application that pro!i"e a""ition in$ormation regar"ing the error con"ition. 3or the programming per pecti!e% the key element o$ an error me age are a #ay to i"enti$y the place in the co"e #here the error occurre"% an" in$ormation that #oul" enable the "ata that #a being proce e" to be i"enti$ie". Thi particularly applie to general y tem error uch a "i!i"e/by/Aero error .

4.8.11.4.%rror Recovery

In ome proce e a igni$icant number o$ error may be e&pecte". Thi occur % $or e&ample% in compiler #hile compiling program co"e% an" in "ata

,23

proce ing #hile proce ing large batche o$ "ata. In the e ca e % en"ing the proce re/running o$ the proce correcte". ;rror reco!ery in!ol!e taking action to continue operation $ollo#ing an error con"ition% to generate other re ult or generate partial output% an" to "etect the $ull li t o$ error . 4uring program compilation% a compiler #ill generally attempt to proce error #ithin the co"e. 8hen an error i "etecte"% an error me age may be logge" to a $ile. 4epen"ing on the ituation% error reco!ery may in!ol!e ignoring the error an" continuing operation% terminating part o$ a proce an" continuing the entire program an" pro"uce a li t o$ all compilation #hen the

$ir t error i "etecte" coul" re ult in repeate" a each error i

,2,

other part % u ing a "e$ault !alue in place o$ an in!ali" one% or arti$icially creating "ata to ub titute $or mi ing in$ormation.

4.8.11.5.Sel 5Co$pensatin( Syste$s

A el$/compen ating y tem i a y tem that automatically a"<u t the y tem to correct e&i ting error . Thi can be "one by calculating the e&pecte" current po ition% the actual current po ition% an" creating recor" to a"<u t $or the "i$$erence. Thi i in contra t to a proce per$orm a $i&e" proce "ata. 3or e&ample% a monthly $ee proce may that imply

an" ignore other

create monthly $ee tran action . I$ a pre!iou

,2*

tran action i incorrect% thi #ill be ignore" by the current month proce . 1o#e!er% i$ the monthly proce calculate"

the year/to/"ate amount "ue% an" the year/to/ "ate amount pai"% an" then create" a tran action the repre ent the "i$$erence% thi approach #oul" a"<u t $or the e&i ting incorrect tran action. Separate !alue coul" al o be create" $or the e&pecte" amount an" the une&pecte" a"<u tment.

4.8.12. Portability

+ortable co"e i #ritten to a!oi" u ing $eature that are peci$ic to a particular compiler% language implementation% or operating en!ironment.

,22

)o"e that i #ritten in a portable #ay i ea ier to con!ert to "i$$erent "e!elopment en!ironment . Al o% ome portability i ue a$$ect the clarity an" implicity o$ the co"e% an" a ection o$ co"e #ritten in a portable #ay may be ea ier to rea" an" maintain than an alternati!e ection that u e implementation/ peci$ic $eature .

4.8.12.1.#an(ua(e /perations an%&tensions

Many compiler

upport e&ten ion to the

tan"ar" language% through the implementation o$ a""itional key#or" an" operation . Some language operation an" parameter are not peci$ie" a part o$ the language "e$inition. Thi may inclu"e the iAe o$

,25

"i$$erent numeric "ata type % the re ult o$ certain operation % an" the re ult o$ ome inputNoutput operation . )o"e that i "epen"ant on un peci$ie" $eature o$ the language% or that u e compiler/ peci$ic e&ten ion to the language% may be le portable than co"e that a!oi" the e $eature . Some language "o not ha!e a ingle "e$inition% an" igni$icant "i$$erence in the language tructure may occur bet#een implementation . In the e ca e a ub et o$ common $eature acro portability problem . ma<or implementation coul" be u e" to re"uce

4.8.12.2.%&ternal +nter aces

I er inter$ace tructure % $ile an" "ataba e tructure an" printing operation may all

,27

!ary $rom operating y tem to operating y tem. In general% con!er ion to alternati!e en!ironment may be impler #hen relate" proce e are groupe" together. 3or e&ample% all the u er inter$ace co"e% inclu"ing call to operating y tem $unction % coul" be groupe" into a u er inter$ace mo"ule.

4.8.12.3.Se($entation o )unctionality

In many y tem the co"e can be groupe" into e!eral ma<or ection . @ne ection may be the u er inter$ace co"e% #hich "i play creen % menu % an" han"le input $rom the u er. @ther ma<or ection may inclu"e a et o$ calculation an" proce ing $unction % an" $ormatting an" printing co"e.

,2:

Thi #oul" increa e portability by enabling one ection to be mo"i$ie" $or an alternati!e en!ironment% #hile the other ection remain unchange". 1o#e!er% thi approach #oul" not apply to an e!ent/"ri!en y tem that u e" a comple& u er inter$ace "e ign% #ith mall proce ing tep attache" to !ariou $unction .

4.8.13. #an(ua(e Subsets

I ing a ub et o$ a language in!ol!e u ing a et o$ imple $un"amental operation . Thi #oul" in!ol!e a!oi"ing alternati!e operation % an" comple& or little/u e" language $eature . )o"e #ritten u ing a ub et o$ the $ull language may be impler an" ea ier to rea" than co"e that u e $unction $rom pre!iou

,50

!er ion o$ the language an" little/u e" language $eature . 3or e&ample% a language may upport e!eral looping tatement that pro!i"e imilar $unctionality. 8riting co"e in a language ub et may in!ol!e u ing one o$ the loop con truct throughout the co"e.

4.8.14. De ault Values

A "e$ault !alue i a !alue that i u e" #hen a "ata item i unkno#n or i not peci$ie". 4e$ault !alue can be u e" to a!oi" peci$ying multiple option $or a particular proce . 3or e&ample% the "e$ault !alue $or each option may be peci$ie" in a "ataba e recor" or con$iguration $ile. The e "e$ault !alue #oul" be u e" unle a peci$ic option #a o!erri""en by another !alue.

,51

4e$ault o!erri"e may occur at multiple le!el . 3or e&ample% a "e$ault !alue coul" be peci$ie" $or an option acro an entire y tem% #hich coul" be o!erri""en by a eparate "e$ault !alue $or a particular group o$ recor" % #hich in turn coul" be o!erri""en by a peci$ic !alue in an in"i!i"ual recor". The "e$ault at each le!el coul" be in"epen"ently change". 8hen a "e$ault o!erri"e i remo!e"% the actual !alue u e" return to the "e$ault !alue o$ the pre!iou le!el. The term "e$ault !alue i al o u e" in the conte&t o$ an initial !alue. Thi i an initial !alue place" in a "ata recor"% "ata tructure or creen entry $iel". 1o#e!er% #hen initial !alue are change" the pre!iou !alue i lo t% unlike "e$ault !alue #hich can be re tore" by remo!ing the o!erri"e !alue.

,52

4.8.15. Co$ple& %&pressions

In ome ca e the clarity o$ a comple& e&pre ion can be impro!e" by breaking the e&pre ion into ub/part an" toring each part in a eparate !ariable. Thi allo# the !ariable name to a"" more in$ormation into the co"e% an" i"enti$ie the tructure o$ the e&pre ion. 3or e&ample%

total = (# + ')O(e*d)*(c*(#0(#+')O n)*' + fv*((# + ')On))

Thi co"e coul" be plit into e!eral component to clari$y the tructure o$ the e&pre ion.

,53

part_period_discount = (# + ') O (e*d) annuit' = (# 0 (# + ')O( n))*' face_value_pv = fv * (# + ')On) total = part_period * (c * annuit' + face_value_pv)

A""ing a""itional bracket into a comple& e&pre ion may al o clari$y the inten"e" operation.

4.8.16. Duplicate- %&pressions

8hen a particular e&pre ion occur more than once #ithin a program% it can be place" in a eparate ubroutine. Thi may a!oi" problem #hen one !er ion o$ the e&pre ion i change" but the other !er ion i not.

,5,

The e type o$ bug can remain un"etecte" $or long perio" o$ time% becau e the y tem may continue to operate an" appear to be #orking correctly. 3or e&ample
if sample_t'pe = ;>< and result_value " 36-4 then print_data end P P P if sample_t'pe = ;>< and result_value " 36-- then include_in_averages end

In thi e&ample% the econ" e&pre ion i $urther through the co"e. The $ir t e&pre ion print recor" #ith a !alue o$ le than 0.3*% #hile the econ" e&pre ion calculate the a!erage o$ all recor" #ith a !alue o$ le than 0.33.

,5*

The intention may ha!e been $or thi to repre ent the ame e&pre ion% an" the printe" a!erage to be the a!erage o$ the printe" recor" . Thi bug #oul" not a$$ect y tem operation% an" #oul" not be "etecte" unle the -a!erage. $igure. 8riting a ubroutine to replace the e e&pre ion an" implement the e&pre ion in a ingle place #oul" a!oi" thi problem. Al o% the $i&e" number coul" be replace" #ith a con tant uch a E;SI6TUT@6;EA0);% #hich a"" in$ormation into the co"e an" #oul" allo# thi con tant to be u e" in other place #ithin the co"e. 8here t#o e&pre ion #ere the ame by coinci"ence% but they ha" a "i$$erent the printe" $igure #ere re/calculate" manually to check

,52

meaning% they houl" not be combine" into a common ubroutine.

4.8.1!. <este- A+)B state$ents

0e te" -i$. tatement can be "i$$icult to interpret. In general% a erie o$ eparate -i$. tatement may be ea ier to rea" an" interpret than a et o$ ne te" -i$. tatement . 3or e&ample% the $ollo#ing co"e "etermine #hether a year i a leap year% u ing ne te" -i$. tatement .

if 'ear mod 2 = 3 then if 'ear mod #33 = 3 then if 'ear mod 233 = 3 then is_leap_'ear = true else is_leap_'ear = false

,55

end else is_leap_'ear = true end else is_leap_'ear = false end

Thi co"e can be re/#ritten a a erie o$ eparate -i$. tatement . In thi ca e the control $lo# may be clearer than the co"e that u e a ne te" tructure.

is_leap_'ear = false if 'ear mod 2 = 3 then is_leap_'ear = true end if 'ear mod #33 = 3 then is_leap_'ear = false end if 'ear mod 233 = 3 then is_leap_'ear = true end

,57

Thi particular e&ample coul" al o be re/ #ritten a a ingle con"ition% a $ollo#ing co"e
if ('ear mod 2 = 3 and 'ear mod #33 "$ 3) or 'ear mod 233 = 3 then is_leap_'ear = true else is_leap_'ear = false end

ho#n in the

4.8.1". A%lseB con-itions

In mo t ca e % the -el e. part o$ an -i$. tatement i inten"e" to apply to -i$ the con"ition i not true.. 1o#e!er% in other ca e the intention i $or the co"e to apply -$or the other !alue..

,5:

3or e&ample% a particular numeric !ariable may generally ha!e a !alue o$ 1 or 2. The $ollo#ing co"e i an e&ample.
if process_t'pe = # then run_process# else run_process+ end

In thi e&ample% i$ the !alue o$ -proce Utype. i not 1% then it ha been a ume" to be 2. 1o#e!er% "ue to a bug in the y tem or a mi un"er tan"ing o$ meaning an" !alue o$ !ariable -proce Utype.% it may ha!e a "i$$erent !alue. Thi can be checke"% a in the $ollo#ing e&ample.

if process_t'pe = # then run_process# else if process_t'pe = + then run_process+ else displa'_message ;Bnvalid value ; Q

,70

process_t'pe Q ;for variable process_t'pe in run_process< end

Thi co"e may "etect e&i ting problem % or "etect problem that ari e $ollo#ing $uture change .

4.8.18. 4oolean %&pressions 4.8.18.1.Con-itions

I$ the !ariable - ortUa cen"ing. i a Boolean !ariable% i.e. it can only ha!e the !alue True or 3al e% then the $ollo#ing t#o line o$ co"e are e'ui!alent

if sort_ascending = true then

,71

if sort_ascending then

The econ" $orm i clear #hen a Boolean !ariable i u e"% an" the -? True. i not nece ary. 1o#e!er% in ome language the econ" $orm o$ the e&pre ion can al o be u e" #ith numeric !ariable . In thi ca e the co"e may be clearer i$ the actual con"ition i inclu"e". 3or e&ample%

if record_count then

if record_count "$ 3 then

In thi ca e the !ariable -recor"Ucount. recor" a number% not a Boolean !alue. In ,72

language #here -true. #a "e$ine" a non/ Aero% the t#o e&pre ion may be e'ui!alent. 1o#e!er% thi imply relie on the metho"

that ha been u e" to implement Boolean e&pre ion % an" the econ" $orm may be clearer a it peci$ie the con"ition that i actually being te te". In language that u e trict type checking% the $ir t $orm may generate an error% a the e&pre ion ha a numeric type but the -i$. tatement u e Boolean e&pre ion .

4.8.18.2.+nte(er +$ple$entations

In ome language % Boolean !ariable are implemente" a integer #ithin the co"e% rather than a a eparate type. The True an" 3al e !alue #oul" be numeric con tant .

,73

Tero i generally u e" $or 3al e% #hile True can be 1% /1% or any non/Aero number "epen"ing on the language. In language #here Boolean !alue are implemente" a number % problem can ari e i$ numeric !alue other than True an" 3al e are u e" #ith !ariable that are inten"e" to be Boolean. 3or e&ample% i$ 3al e i Aero an" True i 1% but any non/Aero !alue i accepte" a true% the $ollo#ing anomalie can occur.

*alue 1 e'ual to 0 1 to 1 1 Aero 2 e'ual to 0

Condition i $al e ? True i true

+utcome no ye ye

,eason 1 i not 1 i e'ual 1 i non/

i $al e

no

2 i not

,7,

2 e'ual to 1 2 Aero

? True i true

no ye

2 i not 2 i non/

In thi ca e% -2. #oul" match the con"ition -i true.% a i it non/Aero% but #oul" not match the con"ition -? True.% a it i not e'ual to 1. The e problem can be re"uce" i$ numeric an" Boolean !ariable an" e&pre ion are clearly eparate".

4.8.29. Consistency

)on i tency in the u e o$ language $eature may re"uce the chance o$ bug #ithin the co"e. 3or e&ample% array are commonly in"e&e" #ith the $ir t element ha!ing an in"e& o$ Aero

,7*

or one. In ome language thi con!ention i $i&e"% #hile in other it can be "e$ine" on a y tem/#i"e ba i or #hen an in"i!i"ual array i "e$ine". I$ ome array are in"e&e" $rom Aero an" ome are in"e&e" $rom one% thi may increa e the change o$ bug in the e&i ting y tem% or bug being intro"uce" through $uture change . 3or e&ample% thi co"e u e the con!ention o$ toring the !alue Aero.
for i = 3 to num_active end #

tarting #ith element

total = total + current_valueKiL

The $ollo#ing co"e u e the con!ention o$ toring !alue tarting #ith element one.

for i = # to num_active total = total + current_valueKiL

,72

end

I$ the #rong loop type #a u e" $or the array% one !ali" element #oul" be mi e"% an" #oul" be replace" #ith another !alue that coul" be a ran"om% initial or pre!iou !alue. Thi may lea" to ubtle problem in proce ing% or create general in tability an" occa ional ran"om problem . 8hen maintenance change are ma"e to an e&i ting y tem% the chance o$ error occurring may be re"uce" i$ the language $eature are u e" in a #ay that i con i tent #ith the e&i ting co"e.

,75

4.8.21. :n-e ine- #an(ua(e /perations

In many language % there are combination o$ tatement that $orm !ali" ection o$ co"e% but #here the re ult o$ the operation i not clearly "e$ine". 3or e&ample% in many language the !alue that a loop !ariable ha a$ter the loop ha terminate" i not "e$ine". The $ollo#ing co"e earche an array $or a #or" an" a"" the #or" into the array at the $ir t empty pace i$ it i not $oun".
subroutine add_!ord( !ord as string, substring_found as boolean ) define i as integer define found as boolean found = false for i = 3 to num_!ords 0 # if !ord_tableKiL = !ord then found = true end

,77

if string_search( !ord_tableKiL, !ord ) then substring_found = true end end if not found then !ord_tableKiL = !ord num_!ords = num_!ords + # end end

8hile the !alue o$ the !ariable -i. increa e $rom 0 to -numU#or" J 1. on each iteration through the loop% in many language the !alue o$ -i. i not clearly "e$ine" a$ter the loop ha terminate". It may be e'ual to the la t !alue through the loop% the la t !alue plu one% or ome other !alue. Mo t compiler #oul" not "etect thi problem% a technically thi co"e i a !ali" et o$ tatement #ithin the language.

,7:

Thi problem coul" be a!oi"e" by u ing the !ariable -numU#or" . a$ter the loop in tea" o$ the loop !ariable it el$. )alling ubroutine $rom #ithin e&pre ion can al o re ult in un"e$ine" operation . 3or e&ample% in ome ca e the or"er in #hich an e&pre ion i e!aluate" i not "e$ine"% an" #hen an e&pre ion contain t#o ubroutine call % the e call coul" occur in either or"er. In the ca e o$ Boolean e&pre ion % i$ the $ir t part o$ an A04 e&pre ion i $al e% then the econ" part "oe not nee" to be e!aluate"% a the re ult o$ the A04 e&pre ion #ill be $al e% regar"le re ult o$ the econ" e&pre ion. In the e ca e % language may "e$ine that the econ" part #ill ne!er be e&ecute"% that the econ" part #ill al#ay be e&ecute"% or the re ult may be un"e$ine". o$ the

,:0

,:1

".1,. Testing

Te ting in!ol!e creating "ata an" te t cenario % calling ubroutine or u ing the y tem% an" checking the re ult . Te ting i "one at the le!el o$ in"i!i"ual ubroutine % complete mo"ule % an" an entire y tem. Te ting cannot repair a y tem that i poorly "e igne" or co"e". The reliability o$ a y tem i "etermine" "uring the "e ign an" co"ing tage % not "uring the te ting tage.

4.19.1. %&ecution Pat1 Co$ple&ity

The number o$ po ible path that program e&ecution can $ollo# i e&tremely large.

,:2

3or e&ample% the $ollo#ing co"e can an array o$ 1000 item % an" print all the item that ha!e a !alue o$ le
for i = 3 to 111 if tableKiL " # then print tableKiL end end

than one.

The number o$ po ible combination o$ output i 21000% #hich i appro&imately 105 $ollo#e" by 2:: Aero . In large y tem % only a mall $raction o$ the po ible program $lo# path #ill e!er be e&ecute" in the entire li$e o$ the y tem operation.

,:3

4.19.2. Testin( 0et1o-s

4.19.2.1.)unction Testin(

Te ting in"i!i"ual $unction in!ol!e te ting in"i!i"ual ubroutine an" mo"ule a each $unction i "e!elope". 4ebugging i ea ier an" more reliable i$ te ting i "one a each mall tage i "e!elope"% rather than #riting a large !olume o$ co"e an" then con"ucting te ting. 3unction te ting i con"ucte" by #riting a te t program or te t harne . Thi may be a eparate program% or a ection o$ co"e #ithin an e&i ting y tem. The te ting routine generate "ata% call the $unction being te te"% an" either log the re ult to a $ile or check the $igure u ing an alternati!e metho".

,:,

4.19.2.2.Syste$ Testin(

Sy tem te ting in!ol!e te ting an entire y tem. Thi i "one by creating te t "ata% running proce e an" $unction #ithin the y tem% an" checking the re ult . Sy tem te ting generally re ult in the pro"uction o$ a li t o$ kno#n problem . The actual error or outcome in each ituation i "e cribe"% along #ith the "ata an" tep re'uire" to re/pro"uce the problem. 8hen a range o$ problem ha!e been $i&e"% a ne# te t !er ion o$ the y tem can be relea e" $or $urther te ting.

4.19.2.3.'uto$ate- testin(

,:*

Automate" te ting in!ol!e the u e o$ te ting tool to con"uct te ting. Te ting tool are program that imulate key troke entere" by the u er% check the appearance o$ creen "i play to "etect error me age % an" log re ult . Thi proce i particularly u e$ul #hen

change are ma"e to an e&i ting y tem. A et o$ re ult can be generate" be$ore the change i ma"e% an" then automatically re/ generate" a$ter the change. Thi metho" can be u e" to check that other proce e ha!e not been altere" by the y tem change . Automate" te ting can al o be con"ucte" by altering the y tem to log each key toke to a $ile% an" then re/rea"ing the $ile an" replaying the key toke automatically.

,:2

4.19.2.4.Stress Testin(

Stre

te ting in!ol!e te ting a y tem #ith

large !olume o$ "ata an" high input tran action rate . Thi i "one to en ure that the y tem #ill continue to operate normally #ith large "ata !olume % an" to en ure that the re pon e time #oul" be #ithin acceptable limit . Stre te ting can be "one by generating a

large !olume o$ ran"om or e'uential "ata% populating the "ataba e table % an" running the y tem proce e . Stre te ting can al o be "one #ith internal

"ata tructure . 3or e&ample% a te ting routine $or te ting a general et o$ binary tree $unction % or a orting mo"ule% coul" create a large !olume o$ "ata% in ert the "ata into the tructure% an" call the $unction that operate on the "ata tructure.

,:5

4.19.2.5.4lac2 4o& Testin(

Black bo& te ting in!ol!e te ting a y tem or mo"ule again t a "e$inition o$ the $unction% #hile ignoring the internal tructure o$ the proce . Thi can be a u e$ul initial te t% a the te ting i "one #ithout preconcei!e" i"ea about the proce ing. 1o#e!er% "ue to the large number o$ po ible path in e!en mall ection o$ co"e% it i not po ible to check that the output re ult #oul" be correct in all circum tance . Te t ca e that take into account the tructure an" e"ge ca e in the internal co"e are likely to "etect more problem that purely black bo& te ting.

,:7

4.19.2.6.Parallel Testin(

In ome ca e % an alternati!e y tem i a!ailable that can per$orm imilar $unction to the y tem being te te". Thi may be an e&i ting y tem in the ca e o$ a y tem re"e!elopment% a temporary y tem% or an alternati!e y tem uch a a commercial y tem that pro!i"e relate" $unction . +arallel te ting can be "one by loa"ing the ame et o$ "ata into both y tem an" comparing the re ult . The re ult houl" al o be checke" y tem into a ne# y tem.

in"epen"ently% to a!oi" carrying o!er bug $rom a pre!iou

4.19.3. Test Cases

,::

4.19.3.1.'ctual Data

Actual "ata i "eri!e" $rom pre!iou y tem % manual keying% uploa"ing $rom e&ternal y tem % an" the e&i ting y tem it el$ #hen change are being ma"e. Te t con"ucte" on actual "ata can be u e" to generate a et o$ kno#n re ult . The e re ult can then be re/generate" an" compare" to the pre!iou "ata a$ter change ha!e been ma"e. Thi proce can be u e" to check #hether e&i ting $unction ha!e been altere" by change ma"e to the y tem.

4.19.3.2.Typical an- 'typical Data

Typical "ata i a et o$ create" "ata that $ollo# u ual pattern .

*00

Al o% a range o$ unu ual "ata combination can al o be create" to te t the $ull $unctionality o$ the y tem. Typical "ata i u e$ul in te ting proce ing% a a $ull et o$ tan"ar" re ult #ill generally be generate". Thi may not occur #ith unu ual ca e that are !ali" y tem input % but "o not re ult in a $ull et o$ proce ing being per$orme". Te ting generally co!er the $ull range o$ po ible "ata an" $unction % an" $ocu e on unu ual an" atypical ca e . +roblem #ith common ca e may appear relati!ely 'uickly% #hile re"ucing long/term problem in!ol!e checking cenario that may not appear until ome time into the $uture.

*01

4.19.3.3.%-(e Cases

;"ge ca e in!ol!e checking the igni$icant point #ithin co"e or "ata. Thi may inclu"e !alue that re ult in a change in calculation output% or ca e that are "i$$erent $rom the ne&t an" pre!iou !alue% uch a the la t recor" in a $ile. 3or e&ample% in a calculation the altere" a$ter one year% te ting coul" be "one u ing perio" o$ 32,% 32*% 322 an" 325 "ay . A another e&ample% in a y tem $or recor"ing "etail o$ learner "ri!er #ith a minimum age o$ 15% te ting coul" be "one #ith te t ca e u ing age o$ 12% 15 an" 17.

4.19.3.4.Ran-o$ Data

*02

Ean"om "ata generation may pro"uce te t ca e that are unu ual an" une&pecte"% e!en though they are !ali" y tem input . Te ting #ith ran"om "ata can be u e$ul in checking the $ull range o$ $unctionality o$ a y tem or mo"ule. Ean"omly generate" "ata an" $unction e'uence may te t cenario that #ere not contemplate" #hen the y tem #a "e igne" an" #ritten.

4.19.4. C1ec2in( Results 4.19.4.1.Syste$ /peration

In ome ca e "irect problem occur #hen proce e or $unction are run. Thi may inclu"e problem uch a a program error me age being "i playe"% a y tem cra h #ith an internal error me age% printe" output not appearing or being incorrectly arrange"%

*03

or the program entering an in$inite loop an" ne!er terminating.

4.19.4.2.'lternative 'l(orit1$s

In ome ca e an alternati!e metho" can be u e" to check the re ult that ha!e been generate". Thi may in!ol!e #riting a te ting routine to calculate the ame re ult% u ing a metho" that may be imple% but may e&ecute lo#ly an" may only apply to that particular ituation. 8hen thi i the ca e% the te t program can generate a large number o$ te t ca e % call the mo"ule being te te"% an" check the re ult that are pro"uce".

4.19.4.3.;no*n Solutions

*0,

8hen te ting i con"ucte" on an e&i ting y tem% a et o$ tan"ar" re ult can be pro"uce". Thi may inclu"e a et o$ "ata that i up"ate" #ithin a "ataba e% or a et o$ calculate" $igure that are tore" in a $ile $or $uture compari on. Thi proce allo# a te t program to re/

generate the "ata or $igure % an" check the re ult again t the kno#n correct output.

4.19.4.4.0anual Calculations

The input to calculation an" the calculation re ult can be logge" to a $ile $or manual checking. Thi may inclu"e #riting a imple program to can the $ile an" check the $igure % or it may in!ol!e u ing a program uch a a prea" heet to check the "ata an" re/calculate the $igure .

*0*

)heck can be run again t the input "ata that #a upplie" to the y tem% an" al o again t calculation #ithin the et o$ output "ata% uch a !eri$ying total .

4.19.4.5.Consistency o Results

In ome ca e % the output $rom a proce houl" ha!e a certain $orm% an" in"i!i"ual output houl" be relate" in certain #ay .

In the e ituation % a te t program can be u e" to check that the in"i!i"ual re ult are con i tent #ith each other. The e te t coul" al o be built into the routine it el$% an" u e" to check output a it i pro"uce". 8hen the e te t are $a t an" imple they can remain in the co"e permanently% other#i e they can be acti!ate" $or te ting an" "ebugging.

*02

3or e&ample% a et o$ output #eight

houl" that

um to 1% a orte" output li t houl" be in a orte" or"er% an" the output o$ a proce "ecompo e a !alue into part the original !alue. A another e&ample% checking that a ort routine ha ucce $ully orte" a li t i a canning the li t imple proce % an" in!ol!e houl" e'ual

once an" checking that each item i not maller than the pre!iou item.

4.19.4.6.Reverse Calculations

Some calculation an" proce e can be per$orme" in t#o "irection % #ith one "irection being "i$$icult an" the other traight$or#ar". 3or e&ample% the !alue o$ -y. in the e'uation -y ? &2 C &. i "etermine" by calculating the re ult $rom the !alue o$ -&..

*05

1o#e!er% i$ the !alue o$ -y. i alrea"y kno#n but the !alue o$ -&. i re'uire"% then the e'uation cannot be "irectly ol!e"% an" an iterati!e metho" $or "etermining an appro&imate olution mu t be u e". In thi ca e% "etermining the !alue o$ -y. may be a relati!ely comple& proce . 1o#e!er% once the re ult i kno#n% it can be ea y checke" by pre$orming the re!er e calculation an" en uring that the re ult matche the original $igure.

4.19.5. Declarative Co-e

Te ting "eclarati!e pattern in!ol!e checking that the pattern matche the e&pecte" et o$ tring u ing the e&pecte" et o$ ub/pattern .

*07

4.19.5.1.Testin( o t1e pro(ra$

In the ca e o$ $act/ba e" y tem that in!ol!e problem ol!ing an" goal eeking% te ting can be con"ucte" to en ure that $act are not con$licting% an" that there are no uninten"e" gap in the in$ormation that #oul" lea" to un"e$ine" re ult . A te t program can be #ritten to rea" the pattern or $act "e cription into an internal "ata tructure $or canning. A can o$ the tructure can be per$orme" to check $or loop % multiple path % an" con"ition that ha!e un"e$ine" re ult . 8here a loop occur % in ome ca e thi may be the re ult o$ a "eliberate recur i!e "e$inition% #hile in other ca e thi may igni$y an error.

*0:

In ome ca e % t#o point #ithin a pattern may be connecte" by multiple path . In the e ca e % an input tring may be matche" by a pattern in t#o "i$$erent #ay . In ome application thi may not be igni$icant% #hile in other ca e thi may in"icate that the pattern coul" not be u e" in proce ing. In ome application % algorithm e&i t to check particular attribute o$ a pattern tructure. 3or e&ample% an algorithm coul" be u e" to check #hether a language grammar #a or #a not uitable $or top/"o#n par ing.

4.19.5.2.Testin( Pro(ra$ /peration

Te ting can be per$orme" #ith input "ata to en ure that the correct re ult i pro"uce".

*10

Thi may in!ol!e u ing the program #ith te t ca e an" checking output. Trace coul" be pro"uce" o$ the logic path that #a $ollo#e" to arri!e at the re ult% or the ub/pattern that #ere matche".

4.19.6. Testin( Su$$ary

Testing &ethods 3unction te ting Te ting in"i!i"ual ubroutine % mo"ule an" $unction u ing te t program . Sy tem Te ting Te ting entire y tem by running te t ca e an" checking re ult . Automate" Te ting I ing automate" te ting tool to imulate keying% run *11

proce e % an" "etect creen an" "ata output. Stre Te ting Te ting application #ith large "ata !olume an" high tran action rate to check operation an" re pon e time . Black bo& te ting Te ting a $unction again t a peci$ication% ignoring the $unction( internal tructure. +arallel Te ting Te ting a y tem by running an alternati!e y tem u ing the ame "ata. Test 'ata Actual 4ata 4ata ource" $rom pre!iou y tem % "ata uploa" % the e&i ting y tem it el$ or manual keying. Typical an" Atypical 4ata )reate" "ata u ing common "ata combination an" al o unu ual an" une&pecte"

*12

combination that are !ali" y tem input . ;"ge )a e Te t "ata that i lightly le %

lightly more% an" e'ual to !alue that re ult in change in calculation % or internal program limit . Ean"om 4ata 4ata create" #ith ran"om !alue an" combination % u e" to generate large "ata !olume an" to te t the $ull range an" combination o$ y tem input . 'etecting -rrors Sy tem @peration +roblem "ue to program cra he % error me age% an" incorrect output. Alternati!e Algorithm =enerating the ame re ult #ithin a te t program u ing an alternati!e algorithm% an" comparing re ult . *13

Hno#n Solution

)omparing re ult #ith re ult generate" pre!iou ly% an" "e$ining a et o$ input "ata #ith kno#n re ult generate" by a eparate te t program.

Manual )alculation

)hecking re ult u ing te t program an" o$t#are tool to re/calculate output re ult an" check $igure #ithin output uch a total .

)on i tent Ee ult

)hecking output $or con i tency% uch a in"i!i"ual output that houl" balance to Aero or e'ual another output% checking that orte" "ata i actually orte" etc.

Ee!er e )alculation

+er$orming a calculation in re!er e to "etermine the original $igure% an" comparing thi re ult #ith the *1,

actual input !alue to !eri$y that the generate" re ult i correct. 'eclarati(e Code Te ting @utput 4eclarati!e co"e can be run again t actual te t "ata% an" the output re ult checke". )hecking program trace Trace o$ logic an" pattern matche" "uring the operation #ith the input "ata may highlight problem #ith the "eclarati!e tructure. Structure )heck 4eclarati!e tructure can be rea" by te t program % an" a can o$ the tructure can be per$orme" to check $or loop % multiple path % an" combination o$ e!ent that #oul" lea" to un"e$ine" re ult .

*1*

*12

".11. De0ugging

4ebugging i the proce

o$ locating bug

#ithin a program an" correcting the co"e. A bug i an error in the co"e% or a "e ign $la#% that lea" to an incorrect re ult being pro"uce".

4.11.1. Proce-ural Co-e

Be$ore "ebugging can be per$orme"% a et o$ tep that lea" to the ame problem occurring each time the program i run mu t be "etermine". Thi tep i the $oun"ation o$ the "ebugging proce . 4ebugging can be "one u ing ome o$ the $ollo#ing metho"

*15

Eea"ing the co"e an" attempting to $ollo# the e&ecution path o$ the particular et o$ tep . Eunning the program #ith trace co"e a""e" to log the !alue o$ !ariable to a "ata $ile% an" to i"enti$y #hich con"ition #ere triggere". Stepping through the e&ecution u ing a "ebugger% an" pau ing at !ariou point in the e&ecution to e&amine the !alue o$ "ata !ariable . A""ing error checking co"e into the y tem to "etect error at an earlier tage% or to trigger a me age #hen in!ali" "ata or re ult are pro"uce".

Some e&ample o$ bug inclu"eB An error in entering an e&pre ion% uch a placing bracket in the #rong place.

*17

A logic error% #here a certain combination o$ con"ition i not han"le" correctly. A mi take in the un"er tan"ing o$ a !ariable\ ho# it i calculate"% an" #hen it i up"ate". A e'uence problem% #hen calling a et o$ $unction in a particular or"er lea" to an incorrect re ult. A corruption o$ memory% "ue to an up"ate to an incorrect memory location uch a an incorrect array re$erence. A loop that terminate un"er incorrect con"ition . An incorrect a umption about the concept an" proce e that the y tem u e .

4.11.1.1.Vie*in( Data Structures

*1:

The content o$ entire "ata tructure % uch a array an" table % can be #ritten to a te&t $ile an" then !ie#e" in a program uch a a prea" heet application. Thi can be "one by #riting ubroutine to #rite the content o$ the "ata tructure to a te&t $ile. Thi metho" may highlight ob!iou problem % uch a a column $ull o$ Aero or a large li t #hen there houl" be a mall li t. 4ata column $rom "i$$erent "ata tructure can be compare"% an" manual calculation can be "one to check that the $igure are correct.

4.11.1.2.Data Traces

A log $ile can be #ritten o$ the !alue o$ !ariable a the program run .

*20

Thi can be u e" to !ie# the e'uence o$ change to !ariou "ata !ariable . Trace may al o be u e" to recor" #hich ection o$ the co"e #ere e&ecute"% an" #hich con"ition #ere triggere". A Time tamp% containing an up"ate "ate an" time% can be inclu"e" on "ata recor" . Thi can be u e" to i"enti$y the recor" that #ere up"ate" "uring the proce .

4.11.1.3.Cleanin( & Re*ritin( Co-e

In ca e #here a "i$$icult bug cannot be $oun"% the co"e can be re!ie#e" an" change uch a a""ing comment % minor re/#riting o$ co"e% changing !ariable name etc. can be ma"e. In ituation #here the co"e i in !ery poor con"ition% $ollo#ing a large number o$

*21

change % an entire ection o$ co"e may be re/ #ritten. Thi may occur #hen the control $lo# #ithin a ection o$ co"e i e&tremely comple&% an" it i likely that other problem are al o pre ent in the co"e% a #ell a the particular problem being checke". In thi ca e% the original bug houl" be locate" be$ore the re/#riting i$ po ible% a it may repre ent a "e ign $la# that i al o pre ent in other part o$ the y tem.

4.11.1.4.+nternal C1ec2s

Internal check are co"e that i a""e" into the y tem to "etermine a point in the proce #hen the re ult become incorrect. Thi can be u e" to "etermine the appro&imate location o$ the problem. Thi

*22

metho" i particularly u e$ul $or bug that ran"omly occur% #here a e'uence o$ tep to repro"uce the problem cannot be "etermine". In ome ca e % in!ali" "ata may occa ionally appear in a "ataba e% ho#e!er re/running the proce generate the correct re ult .

Inclu"ing internal check may trap the error a it occur % enabling the problem to be trace".

4.11.1.5. Reverse Calculations

Some calculation can be per$orme" in re!er e% to check that the re ult i correct. 3or e&ample% an iterati!e metho" coul" be u e" to "etermine the !alue o$ the !ariable -&. in the e'uation -y ? &2 C &.% #hen the !alue o$ -y. i kno#n.

*23

In thi e&ample% #hen the !alue o$ -&. ha been calculate"% the e'uation can be u e" to calculate the !alue o$ -y. an" en ure that it matche" the original !alue.

4.11.1.6. 'lternative 'l(orit1$s

In ome ca e an alternati!e metho" can be u e" to calculate a re ult an" check that it i correct. 3or e&ample% thi may be a imple metho" that i circum tance . lo#er that the metho" being checke"% an" only applie in certain

4.11.1.!.C1ec2in( Results

Some proce e pro"uce e!eral re ult that can be checke" again t each other. 3or e&ample% in proce that "ecompo e a !alue

*2,

into component part % the um o$ the part houl" match the original !alue. A another e&ample% orting i a lo# proce % ho#e!er checking that a li t i actually orte" can be "one #ith a ingle pa o$ the li t. 4uring te ting a ort routine coul" check the output being pro"uce" to en ure that the "ata ha" been correctly orte".

4.11.1.". Data C1ec2in(

4ata !alue can be checke" at !ariou point in the program to "etect problem . Thi may inclu"e checking in"i!i"ual !ariable % an" canning "ata tructure uch a array .

)heck can inclu"e checking $or Aero% negati!e number % number out i"e e&pecte" range % empty tring etc. 6i t can be

*2*

canne" to check that total match in"i!i"ual entrie % an" that !alue are con i tent% uch a percentage #eight umming to 100O.

4.11.1.8. 0e$ory Corruptions

Memory corruption can occur in ome en!ironment #here a ection o$ memory containing "ata item can be o!er#ritten by other "ata "ue to a program bug. In ome en!ironment % $or e&ample% memory may be o!er#ritten by u ing an array in"e& that i larger than the iAe o$ the array. Some memory corruption can be "etecte" by u ing a $i&e" number co"e #ithin a "ata !ariable in a tructure or array. 8hen the tructure i acce e"% the number i checke" again t the e&pecte" !alue% an" i$ the !alue i "i$$erent then thi in"icate that the memory ha been o!er#ritten.

*22

A check um can al o be u e"% #hich i a um o$ the in"i!i"ual !alue in the tructure. Thi $igure i up"ate" each time that a "ata item i mo"i$ie". 8hen the check um i recalculate"% a "i$$erence $rom the pre!iou $igure #oul" in"icate a memory corruption.

4.11.2. Declarative Co-e

4ebugging "eclarati!e co"e may be "i$$icult% a in many ca e the "e$inition are recur i!e% an" allo# an in$inite number o$ po ible pattern . 3or e&ample% the $ollo#ing "e$inition "e$ine a language o$ imple calculation e&pre ion .
e%pressionD number number * e%pression number + e%pression number e%pression number * e%pression ( e%pression )

*25

Thi i a recur i!e "e$inition% a an e&pre ion can be a number% a number multiplie" by another e&pre ion% or a et o$ bracket containing another e&pre ion. Te ting an" "ebugging "eclarati!e co"e may in!ol!e rea"ing the pattern or $act into an internal "ata tructure% an" canning $or loop % multiple path an" combination that #oul" lea" to un"e$ine" output . In ome ca e % a proce coul" be u e" to

e&pan" a pattern into a tree/like tructure #hich may be ea ier to interpret !i ually. In the ca e o$ recur i!e "e$inition that coul" be in$inite% a tree "iagram coul" e&ten" to e!eral le!el to in"icate the general pattern o$ e&pan ion. The pattern can al o be u e" to generate ran"om "ata that ha a matching pattern ba e" on the "e$inition.

*27

Thi may highlight ome o$ the ca e that are inclu"e" #ithin the pattern unintentionally% an" pattern that #ere inten"e" to be inclu"e" but are not being generate". 4ebugging can al o be per$orme" by e&ecuting a proce that u e the pattern or li t o$ $act % an" generating a trace o$ the logic path that #a u e" "uring proce ing. Thi may inclu"e a li t o$ the in"i!i"ual ub/ pattern that #ere matche" at each tage% or the $act that #ere checke" an" u e" to "etermine the re ult.

*2:

4.11.3. Su$$ary o -ebu((in( approac1es

!pproach Eea"ing co"e

'escription Eea"ing co"e an" $ollo#ing the e&ecution path that re ult in the incorrect output.

+rogram trace

6ogging the !alue o$ "ata !ariable % an" "etail o$ #hich ection o$ co"e #ere e&ecute" an" #hich con"ition #ere triggere"% to a "ata $ile a the program run .

4ebugger

I ing a "ebugger to halt the program "uring e&ecution% !ie# the !alue o$ "ata !ariable % an" tep through ection o$ co"e.

9ie#ing "ata tructure

8riting entire "ata tructure to a $ile an" !ie#ing the content o$ the tructure% to i"enti$y ob!iou problem an" to re/calculate $igure an" *30

compare "ata #ith other tructure . )leaning co"e Minor re/#riting o$ co"e to a"" comment % correct incon i tent !ariable name an" tatement % an"

clari$y the logic $lo# #ithin the co"e.

'etecting errors Ee!er e calculation +er$orming a calculation in re!er e

an" recalculating the input !alue $rom input !alue match. Alternati!e algorithm I ing an alternati!e algorithm to generate the ame output% an" check that the output "ata matche . )on i tent output )hecking output re ult $or con i tency% uch a checking that output #eight um to 1% that orte" "ata i actually orte" etc. 4ata checking )hecking "ata item at !ariou tage

the generate" output% to check that the

in a proce % inclu"ing canning "ata

*31

tructure % to check $or negati!e item % Aero !alue % empty li t % #eight that "o not um to 1 etc. Memory corruption I ing check um an" magic number to "etect pointer to incorrect type an" memory tructure that ha!e been o!er#ritten #ith other "ata.

'eclarati(e code Trace o$ logic $lo# 8riting a trace o$ the logic path u e" an" the pattern that #ere matche" to a $ile% o that problem #ith the "eclarati!e tructure can be i"enti$ie". Scanning tructure Scanning tructure u ing a te t routine to "etect loop % multiple path % an" combination o$ input con"ition that #oul" re ult in an un"e$ine" output.

*32

".12. Documentation

4.12.1. Syste$ Docu$entation

4uring the "e!elopment o$ a y tem% e!eral "ocument may be pro"uce". Thi typically inclu"e a -3unctional Speci$ication.% #hich "e$ine in "etail the $unction an" calculation that the y tem houl" per$orm. @ther "ocument % uch a "e ign "ocument may al o be pro"uce". Sy tem "ocumentation can be u e" "uring maintenance% an" al o "uring enhancement to a y tem.

4.12.2. :ser ,ui-e

*33

I er "ocumentation may inclu"e a u er gui"e. Thi "ocument i a gui"e to u ing the y tem. It may inclu"e a "e cription o$ the proce an" $unction that the y tem per$orm % a #ell a a re$erence gui"e to calculation an" con"ition . In ome u er gui"e a et/by/ tep tutorial o$ !ariou $unction i inclu"e".

4.12.3. Proce-ure 0anual

A proce"ure manual i u ually pro"uce" by the en" u er o$ the y tem% rather than the "e!eloper o$ the y tem. The proce"ure manual "e$ine ho# a y tem i u e" in a particular in tallation. Thi may inclu"e a "e cription o$ the ource o$ !ariou "ata item that are maintaine" an" a li t o$ the timing an" or"er o$ regular proce e .

*3,

*3*

$. 1lossar+

Ab olute 9alue Ab traction

The iAe o$ a number #ithout it ign. C2 an" /2 both ha!e an ab olute !alue& o$ t#o. The proce o$ replacing a et o$ peci$ic ob<ect #ith a more general concept% uch a replacing client% upplier an" bank #ith -counterparty.. A number i"enti$ying a memory location. A -re$erence. i the a""re o$ a "ata item% an" a -pointer. i a !ariable that can

A""re

Ageing

contain an a""re . Altering proce ing ba e" on a time perio" or count (u ually a time count% not actual time). 3or e&ample% cache "ata may be age"% an" remain in the cache only #hile it ha been recently acce e". A "ata type that i compo e" o$ *32

Aggregate

4ata Type

in"i!i"ual "ata item . 3or e&ample% a - tructure. type may contain e!eral in"i!i"ual !ariable % #hile an -array. contain multiple entrie o$ the ame "ata type. A tep/by/ tep proce"ure $or pro"ucing a certain re ult. 3or e&ample% a li t can be orte" by canning the li t an" electing the malle t item% then repeating the can $or the ne&t malle t item an" o on. Thi i the -bubble ort. algorithm. The *2 character -a. through to -A. an" -A. through to -T.% a "i tinct $rom "igit % punctuation an" pecial ymbol . A character that i either a letter or a "igit% that i the character -a. to -A.% -A. to -T. an" -0. to -:.. Thi i u e" in ome "e$inition % uch a the !ali" $ormat $or !ariable name . 1a!ing more than one po ible meaning. An ambiguou language *35

Algorithm

Alphabetic )haracter

Alphanumeric )haracter

Ambiguou

grammar may match an input tring #ith more than one language pattern% an ambiguou tatement "oe not ha!e a Analy i guarantee" re ult. )ollection o$ in$ormation an" "etermining un"erlying concept an" proce e % prior to "e igning a y tem. -Ee'uirement Analy i . in!ol!e "e$ining the broa" purpo e an" $unction o$ a y tem% #hile -Sy tem Analy i . in!ol!e "etermining the $unction that a y tem #ill per$orm% an" pro"ucing a -3unctional A04 Speci$ication. A Boolean operator. A -logical. A04 e&pre ion i TEI; i$ both part o$ the e&pre ion are TEI;% other#i e it i 3A6S;. A -bit#i e. A04 e&pre ion ha the !alue 1 i$ both bit are 1% A+I other#i e it ha a !alue o$ 0. Application +rogram Inter$ace. A "e$ine" et o$ "ata tructure an"

*37

ubroutine call or operation % u e" to communicate bet#een t#o in"epen"ent mo"ule or proce e . A+I Speci$ication Al o calle" a - er!ice inter$ace. A peci$ication o$ an Application +rogram Inter$ace. Thi peci$ication "e$ine the ubroutine call or operation in truction % an" the "ata ob<ect that pa i ue through the A+I. @ther uch a "epen"ence on the

or"er o$ certain operation % limitation on certain $unction an" o $orth may al o be a""re e". Thi i primarily a logical "e$inition% although "etail in!ol!e" in connecting to the inter$ace in practice may al o be A+6 inclu"e". Actuarial +rogramming 6anguage. A mathematically/orientate" programming language "e!elope" $or actuarial calculation % #hich in!ol!e $inance an" tati tic in the in urance $iel". A+6 co"e i *3:

hea!ily la"en #ith operator ymbol an" make e&ten i!e u e Application =enerator o$ matrice . A "e!elopment en!ironment that allo# application to be create" by "e$ining the creen an" report layout % #ith a minimum o$ proce ing co"e. The e y tem are u e" in "ata proce ing en!ironment . Al o calle" $ourth/ Arabic 0umber Sy tem generation language . A number y tem ba e" on a et o$ character % #here each place in the number contain one o$ the character % an" the !alue o$ each place increa e by a multiple o$ the -ba e. a place mo!e $rom right to le$t. The "ecimal an" binary number y tem are Arabic number y tem % #hile roman Arbitrary +reci ion Arithmetic numeral are not. A type o$ numerical !ariable #here any number o$ "igit o$ preci ion can be peci$ie". The calculation $unction are generally

*,0

implemente" a Arithmetic @perator

ubroutine % an"

may be !ery lo#. The common mathematical operation o$ a""ition% ubtraction etc. Mo t programming language "irectly upport a""ition% ubtraction% multiplication% "i!i ion an" e&ponentiation (&y). A "ata tructure that contain multiple item o$ the ame type. In"i!i"ual item are generally re$erre" to by number% kno#n a the -in"e&.. In ome ca e a tring can be u e" a the in"e&% in #hich ca e the array i kno#n a an -a ociati!e array.. A programming language that ha a "irect one/to/one corre pon"ence #ith the internal machine co"e o$ the computer. A embler ha no ynta& or tructure% an" i imply a li t o$ in truction . A embly co"e i e&tremely $a t% ho#e!er large !olume o$ co"e mu t be #ritten

Array

A embly 6anguage

*,1

A ignment @perator A ociati!e Array

to per$orm ba ic ta k . The operator $or etting the !alue o$ a !ariable% o$ten -?.. 3or e&ample% -total ? total C count.. An array that u e a tring a the in"e& !alue% rather than the u ual ca e o$ u ing a number. 3or e&ample% -runUtypeP -Mon"ay. Q ? 3. A "ata !alue that peci$ie a property o$ another ob<ect. 3or e&ample% the colour o$ a "i playe" ob<ect i a "ata item that i an attribute o$ the ob<ect. A li t o$ "ata entrie that recor" a erie o$ change % generally to "ata #ithin a "ataba e. Au"it trail are u e" $or "ebugging% "ata reconciliation etc. A proce that operate #ithout input $rom a u er. 3or e&ample% a "aily "ata up"ate proce may connect to an e&ternal y tem an"

Attribute

Au"it Trail

Automate" +roce

Backbone

tran $er "ata automatically. The main link in a large net#ork% #hich carrie high/!olume tra$$ic

*,2

acro Backtracking

a net#ork an" "i tribute

"ata to maller ub/net#ork . Eeturning to pre!iou point in a "ata can% uch a returning to an earlier point in a tree an" taking a "i$$erent branch% or re/ canning pre!iou te&t. Algorithm that in!ol!e backtracking are generally lo#er than algorithm that in!ol!e a ingle pa through the input "ata or tructure. The -ba e. i the number #hich $orm the $oun"ation o$ an operation. The ba e o$ the "ecimal number y tem i 10% #hile the ba e o$ the binary number y tem i 2. A natural logarithm i a logarithm #ith a ba e o$ the mathematical con tant -e.% #hile a common logarithm i a logarithm to the ba e 10. A thir"/generation programming language #ith a imilar broa" tructure to language uch a )% 3ortran an" +a cal A proce "e igne" to be run *,3

Ba e

BASI)

Batch +roce

unatten"e" an" generally in!ol!ing rea"ing a large number o$ "ata recor" an" taking a B)4 igni$icant perio" o$ time to run. Binary )o"e" 4ecimal. A number torage $ormat that i ba e" on toring each "ecimal "igit eparately a a binary number% rather than con!erting the entire number !alue into a true binary number. B)4 number #here u e" in earlier computing% an" are al o u e" in ome har"#are application Binary uch a control "e!ice an" calculator . An Arabic number y tem ba e" on the number t#o. ;ach place in a binary number ha the "igit 0 or 1% in contra t to the "ecimal y tem #hich u e the "igit 0 to :. The "ecimal number ,23 i ,&1000 C 2&100 C 3&1% #hile the binary number 1011 i 1&7 C 0&, C 1&2 C 1&1. )omputer generally tore all "ata internally a binary *,,

number . An e$$ect that inclu"e t#o element % uch a an operator that take t#o argument or a con"ition that ha t#o po ible Binary @perator outcome . An operator that operate on t#o !alue % uch a the multiplication operator -D.% an" the Boolean operator -@E.. In thi conte&t% -binary. "oe not re$er to binary number % but re$er to the $act that t#o !alue are u e". See al o Binary Search -unary operator.. A $a t metho" $or locating an item in a orte" lo t. The number in the centre o$ the li t i checke" $ir t% then the top hal$ or bottom hal$ o$ the li t i cho en. Thi hal$ i then "i!i"e" in t#o an" o on% until the !alue i locate". The a!erage number o$ compari on $or a li t o$ -n. item i appro&imately log2(n)/1. Al o kno#n a a -binary chop.. *,*

Binary Tree

A "ata tructure that con i t o$ no"e % #here each no"e contain a "ata !alue% a pointer to a le$t ub/ tree% an" a pointer to a right ub/ tree. A binary tree i imilar to an up i"e/"o#n tree% commencing at a ingle root no"e an" branching out $urther "o#n the tree. Binary tree are u e" in a number o$ algorithm . See -+rece"ence. A ingle binary "igit% ha!ing a !alue o$ 0 or 1. Bit are commonly groupe" into eight bit to $orm a -byte.. A""re e commonly re$er to the location o$ a ingle byte. A collection o$ in"epen"ent bit u e" $or recor"ing in"i!i"ual option or eparate !alue . In contra t% mo t collection o$ bit are relate" an" repre ent a binary number. A compari on that compare bit pattern "irectly% rather than comparing #hether t#o number *,2

Bin"ing Strength Bit

Bitmap

Bit#i e )ompari on

Bit#i e @perator Block

ha!e the ame !alue. An operator that operate on an in"i!i"ual bit. See al o -A04.% -@E.% -0@T.% -V@E.. A ection o$ co"e% #hich may be an arbitrary ection o$ co"e% or may be relate" uch a the block o$ co"e #ithin a loop or -i$. tatement. In!ol!ing the t#o !alue TEI; an" 3A6S;. A Boolean !ariable ha one o$ the e !alue % an" a Boolean e&pre ion uch a -3 > *. i either true or $al e. The operator A04% @E% 0@T an" V@E. I e" $or -logical. Boolean e&pre ion in!ol!ing TEI; an" 3A6S;% an" -bit#i e. Boolean e&pre ion in!ol!ing 0 an" 1. See al o -A04.% -@E.% -0@T.% -V@E.. The character -]- an" -^. @$ten u e" to re$er to the character -(- an" -).% but technically a bracket i the 'uare bracket -P- an" -Q.% #hile the

Boolean

Boolean @perator

Brace Bracket

*,5

ymbol -(- an" -). are parenthe i % an" -]- an" -^. are Branching brace . Fumping to another point in the program to continue e&ecution. Machine co"e u e brache ba e" on con"ition % an" uncon"itional <ump . Statement that alter control $lo# in a programming language% uch a -i$. tatement an" loop % are tran late" into branche an" <ump by the B/tree compiler. A tree tructure that ha multiple branche at each le!el. B/tree are el$/balancing #hen item are in erte" an" "elete"% an" are o$ten u e" #ithin "ataba e to Bubble Sort implement in"e&e . A orting algorithm. The bubble ort metho" in!ol!e canning a li t to locate the malle t item% then re/ canning $or the ne&t malle t item an" o on% until e!ery item ha been proce e".

*,7

Thi metho" i

imple to

implement an" i u e$ul $or a"/hoc program % 1o#e!er% the bubble ort algorithm i highly ine$$icient% an" i impractical $or li t o$ more than a $e# hun"re" item . In the e ca e an alternati!e algorithm uch a -'uick ort. #oul" be Bu$$er u e". An area o$ memory u e" $or general torage rather than peci$ic !ariable % uch a a tran lation $rom one binary "ata tructure to another. Al o u e" a a memory area to pa "ata bet#een in"epen"ent proce e % or bet#een program co"e an" Bug har"#are "e!ice . An error in program co"e% or a $ault in "e ign that re ult in an incorrect re ult being pro"uce" #hen a particular combination o$ Byte e!ent occur . A collection o$ eight Bit . )omputer memory i o$ten

*,:

organi e" into byte % #ith a ingle a""re re$erring to the location o$ an in"i!i"ual byte o$ torage. A byte can repre ent a number $rom 0 to 2**% an" may contain in$ormation uch a part o$ a larger number% or a co"e ) repre enting a ingle letter. A thir"/generation programming language% #ith a broa"ly imilar tructure to language uch a 3ortran an" +a cal. ) i o$ten u e" )ache in y tem /le!el programming. An area o$ memory or a "ata tructure "e igne" $or the temporary torage o$ "ata item to allo# $a ter acce . A cache may be u e" to tore "ata that #a retrie!e" $rom a lo#er torage metho"% uch a a "ataba e or "i k $ile. )ache are al o u e" to tore the re ult o$ pre!iou calculation that #ill be re/u e" in $urther proce ing. )ache are u e" in har"#are an" **0

)all

o$t#are at multiple le!el . A re$erence to a ubroutine name% #hich cau e the program e&ecution to <ump to the ubroutine an" begin e&ecuting the co"e #ithin the ubroutine. )ontrol $lo# return to the tatement $ollo#ing the ubroutine call #hen the ubroutine terminate . A pointer or re$erence to a ubroutine that i pa e" to another routine% an" u e" to call the ubroutine that i re$erence". Thi i u e" #hen general/purpo e $unction nee" to call a ubroutine that i relate" to the operation being per$orme". 3or e&ample% a callback $unction may be calle" by a general orting routine to compare t#o ob<ect that #ere being orte". A metho" $or pa ing parameter to ubroutine % #here a pointer to a !ariable i pa e"% rather than

)allback 3unction

)all/By/ Ee$erence

**1

the !ariable( !alue. Thi allo# the calle" ubroutine to change the !ariable( !alue an" return multiple re ult % ho#e!er thi can intro"uce problem #hen the calling program !ariable are change" in une&pecte" circum tance . See al o -call by )all/By/ 9alue !alue. A metho" $or pa ing parameter to ubroutine % #here the !alue o$ the !ariable i pa e". Thi metho" increa e the in"epen"ence o$ co"e an" guarantee to the calling program that it !ariable #ill not be change" in une&pecte" circum tance . 1o#e!er% thi metho" can be lo#er that call/by/ re$erence% a more "ata may nee" to be copie"% an" returning multiple !alue $rom a ubroutine can be "i$$icult. See al o -call by )aller re$erence. The ection o$ co"e that **2

)a ca"ing Ip"ate N 4elete

per$orme" a call to a ubroutine. In a relational "ataba e% a -ca ca"ing up"ate. up"ate the "ata $iel" o$ all recor" that re$er to the key o$ another recor"% #hen the key i change". 3or e&ample% i$ a client number #a change"% then all recor" inclu"ing the client number a a "ata item #oul" be automatically up"ate" #ith the ne# client number. -)a ca"ing "elete. re ult in a "eletion o$ all recor" that re$er to a primary recor"% #hen the primary recor" i "elete". A tatement a!ailable #ithin ome language that act a a combination o$ e!eral -i$. tatement % uch a a tatement that e&ecute three "i$$erent ection o$ co"e "epen"ing on #hether a !ariable( !alue i 1% 2 or 3. The ca e o$ a character% uch a -a. $or lo#er ca e an" -A. $or **3

)a e

upper ca e. In internal torage% the e character are tore" #ith eparate co"e an" are no more relate" then -A. an" -L.. 1o#e!er% ome $unction an" operation are ca e/in en iti!e% an" #oul" treat -a. an" -A. a the )a e/ in en iti!e ame character. A ca e/in en iti!e proce that treat upperca e an" lo#erca e letter a the ame !alue. In a programming language that u e" ca e/in en iti!e !ariable name % the name -0e&tItem. an" -ne&titem. #oul" re$er to the )a e/ en iti!e ame !ariable. A ca e/ en iti!e operation i one that treat upper/ca e an" lo#er/ ca e letter a "i$$erent character . 3or e&ample% in a programming language that u e ca e/ en iti!e !ariable name % the name -3ir tItem. an" -$ir titem. #oul" )a t repre ent "i$$erent !ariable . An operation a!ailable in ome i one

**,

programming language to con!ert one "ata type to another% uch a an integer !alue to a $loating/point )entral +roce ing Init ()+I) !alue. In mo t computer the e&ecution o$ machine co"e in truction i per$orme" by a ingle chip% or a har"#are tructure kno#n a a )+I J )entral +roce ing Init. Many computer ha!e only one )+I% #hile in ome ca e a large computer may ha!e e!eral% although thi i general a mall number. Al o kno#n a a )haracter -proce or.. An in"i!i"ual letter% "igit or ymbol% uch a -e.% -;.% .Q. an" )haracter Set -*.. A et o$ numeric co"e $or character % uch a -a.% -,.% -A. an" -]-. @riginally mo t proce ing #a "one u ing the AS)II character et% #ith ome main $rame computer u ing an alternati!e character et kno#n a

***

;B)I4I). Thi change" igni$icantly #ith the gro#th in computer u age in non/engli h language . Te&t proce ing may u e a range o$ alternati!e character et % although programming ource co"e o$ten u e a tra"itional character et. In ome ituation alternati!e character et are u e"% uch a the A+6 programming language #hich )heck um inclu"e a""itional ymbol . A number that i calculate" $rom a block o$ "ata. Thi can be u e" to check that the block o$ "ata ha not change"% uch a #hen "ata i ent through a communication link. )heck um cannot "etect all error % an" a more ophi ticate" calculation kno#n a a )E) can be per$orme" that #ill "etect a )hil" #i"er range o$ error . I e" in the conte&t o$ "ataba e recor" an" "ata tructure % a -chil". recor" or ob<ect i attache" **2

to a -parent. recor" or ob<ect. Thi i u e" to "e cribe a one/to/many connection% #here each parent recor" may ha!e e!eral chil" recor" % but a chil" recor" connect to only one parent )hip recor". Shortene" term $or -Silicon )hip.. Mo t computer har"#are i implemente" #ith ilicon chip that inclu"e million o$ tran i tor etche" onto a mall block o$ ilicon% u ing a photographic or other proce . ;ach tran i tor can #itch on an" o$$ electricity% #hich i u e" to tore the 0 an" 1 !alue in a binary number% an" to per$orm the e'uence o$ tep )la nee"e" to e&ecute an in truction. A term u e" in ob<ect/orientate" programming to "e cribe a type o$ "ata ob<ect. A cla contain a "e$inition o$ "ata !ariable an" ubroutine % kno#n a -metho" .. 8ithin the program co"e% cla **5

ob<ect are create"% an" the metho" are applie" to e&ecute )lear $unction . To et the !alue o$ a Boolean !ariable to 3A6S;% or to et the )oale ce !alue o$ a bit to 0. To combine t#o ob<ect into a ingle large ob<ect. 3or e&ample% i$ t#o $ree memory block are a"<acent in memory% then they can be re/"e$ine" a a ingle larger )obol block o$ $ree memory A programming language that operate at a imilar le!el o$ ab traction to thir"/generation language uch a 3ortran% +a cal an" ). 1o#e!er% cobol i tructure" 'uite "i$$erently to other language an" u e ;ngli h/ like entence a program co"e. )obol i u e" e&ten i!ely in large )o"e )o"e" $iel" "ata proce ing en!ironment . See -Source )o"e. A "ataba e $iel" that contain one item $rom a et o$ $i&e" co"e % uch a a tran action type $iel". **7

The e may be numeric co"e or )ollating Se'uence tring !alue . The or"er in #hich the character are orte". Although -b. #oul" generally be orte" a$ter -a.% "i$$erence ari e #ith the treatment o$ upper/ca e an" lo#er/ca e letter % punctuation% )olumn an" "igit . )olumn may be a "ata column in a report% a ingle $iel" #ithin a "ataba e recor" or tructure type that appear a a column o$ !alue #hen a li t o$ recor" i "i playe"% or one "imen ion o$ a t#o/ "imen ional matri&. T#o/ "imen ional matrice are ometime proce e" a ro# an" )omment column o$ "ata item . Te&t entere" #ithin program co"e $or the bene$it o$ a human rea"er% uch a note concerning a calculation. )omment "o not a$$ect the operation o$ a program )ommon an" are ignore" by the compiler. )o"e ubroutine that are calle" **:

)o"e

$rom more than one program. )ommon mo"ule are ometime "e!elope" an" maintaine" eparately $rom application program % #here e!eral y tem "e!elopment may u e the ame $unction . A "ata tructure that ha been mo"i$ie" to remo!e blank entrie an" replace "uplicate" entrie #ith a ingle entry% to re"uce memory u age. +roce ing a "ata tructure or "ataba e to re"uce it iAe% by eliminating unu e" pace #ithin the tructure. 8hen recor" or "ata ob<ect are a""e" an" "elete"% the "eletion can lea!e empty pace #ithin the tructure. Ee/ creating the tructure #ith the acti!e "ata create a ne# tructure #ithout the unu e" pace . Thi i ometime "one on a perio"ic ba i #ith "ataba e . See -Eelational @perator.

)ompacte" Structure

)ompacting

)ompari on

*20

@perator )ompilation

The proce

o$ generating a

machine co"e !er ion o$ a program $rom the program ource co"e. The machine co"e !er ion o$ the program can be "irectly e&ecute" by the computer. Thi proce )ompiler i "one by a program kno#n a a compiler. A program that generate an e&ecutable machine/co"e $ile $rom a program ource co"e $ile. In ome y tem % -ob<ect co"e. i pro"uce" in tea"% #hich i a machine/co"e $ormat but mu t be linke" #ith other mo"ule u ing a program kno#n a a -linker. to )omple& 0umber pro"uce an e&ecutable $ile. A mathematical tructure that i u e" in ome engineering calculation . A comple& number i ba e" on the "e$inition o$ the letter -i. a repre enting the 'uare root o$ negati!e one. A the 'uare root o$ a negati!e number

*21

cannot be repre ente" by a real number% the -i. i kno#n a an -imaginary number.. 4ue to the "e$inition% i2 ? /1. A -comple& number. ha t#o component % a -real. an" an -imaginary. part. 3or e&ample% the comple& number -3 C *i. repre ent 3% plu * )ompo ite Hey multiplie" by -i.. A recor" key in a relational "ataba e that i compo e" o$ t#o or more "ata $iel" . 3or e&ample% the primary key o$ a change/o$/ a""re recor" may be the combination o$ the client number an" the e$$ecti!e "ate o$ the change. 4ate are commonly inclu"e" in compo ite key . Thi i u e" $or orting purpo e % o that ran"om acce e can check #hether a recor" e&i t $or a particular "ate% an" to create a )ompre e" uni'ue key to i"enti$y the recor". In application uch a "ata tran mi ion o!er lo# link % "ata *22

may be tran late" into a compre e" $ormat to re"uce it iAe an" increa e the tran $er rate. A number o$ imple an" comple& algorithm are u e" $or thi )oncatenation proce . )ombining t#o tring to $orm a ingle tring. 3or e&ample% appen"ing -.c !. to the tring -temp. create the tring )oncurrently -temp.c !.. @perating at the ame time. )oncurrent proce e e&ecute in"epen"ently an" communicate through program inter$ace . )oncurrent e&ecution o$ ubroutine i po ible in ome pecial/purpo e language although the e are rarely u e"% a "ebugging i e&tremely "i$$icult an" little bene$it i a""e" )on"ition compare" to a tan"ar" proce . A Boolean e&pre ion u e" in an -i$. tatement or a loop. In an -i$. tatement% the co"e $ollo#ing the

*23

tatement i e&ecute" i$ the con"ition i true% other#i e it i )on$iguration 4ata kippe". )on$iguration "ata i u e" to peci$y option $or y tem operation. 3or e&ample% a !alue may peci$y that a certain calculation metho" houl" be u e" #hen e!eral calculation metho" )on tant are a!ailable. A $i&e" !alue% uch a 12.,3 or -comma.. 0ame are ometime u e" $or con tant % $or clarity an" o that the !alue can be "e$ine" in one place% uch a )ontrol 3lo# )orrupt 4ata -8;;HSU+;EUM;AE.. See -logic. A ection o$ memory% a "ata tructure% or a "ataba e item that contain "ata in an in!ali" $ormat. Thi can be cau e" by the "ata being o!er#ritten "ue to a program bug% uch a #riting the "ata $rom one tructure type into the memory location o$ a "i$$erent tructure type. Thi i "i tinct *2,

$rom incorrect "ata% #hich i in a !ali" $ormat but i ba e" on an incorrect calculation or other )E) problem. )yclic Ee"un"ancy )heck. Thi i a comple& calculation that i per$orme" on a block o$ "ata to pro"uce a mall number. The number can then be compare" again t the ame re ult at another time to check #hether the "ata ha been change"% uch a "uring a "ata tran mi ion or "ue to an error on a "i k. A )E) cannot "etect all po ible change % ho#e!er i can "etect a #i"er range o$ problem than a imple -check um.% uch a t#o number )u tomi e" So$t#are 4ata being interchange". So$t#are that ha been altere" $or a particular u er% or $or a particular purpo e. 0umber % te&t an" other in$ormation uch a graphic image . In mo t computer % "ata i

*2*

tore" internally a binary number % #ith number co"e being u e" to repre ent letter in te&t% an" et o$ in"i!i"ual bit 4ata proce ing u e" $or point in graphic image . A type o$ program that in!ol!e proce ing large !olume o$ "ata% per$orming calculation % generating "ata recor" an" pro"ucing report . I e" hea!ily in banking% in urance% general a"mini tration an" in"u trie 4ata type uch a manu$acturing. In mo t language % "i$$erent type o$ !ariable may be tore". Thi may inclu"e tring ( mall te&t item )% numeric !ariable o$ !ariou type % an" other type uch a "ate . Aggregate "ata type % uch a array an" tructure % can al o be "e$ine". See al o -array.% - tring.% - tructure.% -integer.% -$loating 4ataba e point.. A large "ata torage $ile that

*22

contain recor" in a $i&e" et o$ $ormat . In mo t "ata ba e % a -recor". i a $ormat that contain e!eral in"i!i"ual "ata item a number an" te&t tring . Multiple recor" o$ the ame type but #ith "i$$erent "ata may be tore"% an" multiple recor" $ormat can be "e$ine". See al o 4ataba e con!er ion -relational "ataba e. Ma<or up"ate to y tem ometime re'uire a "ataba e con!er ion% #hich re/create a "ataba e in a ne# $ormat u ing the original "ata. Thi i "one by #riting con!er ion program % an" ometime manual a"<u tment to 4ataba e Management Sy tem ome "ata A program that manage the retrie!al% a""ing% mo"i$ying an" "eletion o$ recor" in a "ataba e. +rogram communicate #ith the 4BMS through ubroutine call or a "ata 'uery language. Thi i u e" to retrie!e "ata an" up"ate *25 uch

recor" . A 4BMS may al o inclu"e a "irect u er inter$ace to pro!i"e $or a"/hoc report an" 4ea"lock up"ate to the "ata. A con"ition that can occur #ith concurrent proce e % #here e&ecution cannot continue a each proce i #aiting $or the other to complete a ta k be$ore it can continue. 3or e&ample% one proce $or acce coul" lock a $ile an" #ait to a printer be$ore

continuing% #hile another proce ha locke" the printer an" i #aiting $or acce to the $ile. Thi particular ituation #oul" not occur a printer are not locke"% an" $ile rarely are% ho#e!er "ea"lock i an i ue in ome proce e uch a locking multiple "ataba e recor" $or a ingle 4e/allocate Memory up"ate proce . The operation o$ en"ing the allocation o$ memory that i u e" a a "ynamic memory tructure. *27

Al o kno#n a -$reeing memory.% -"eleting ob<ect .% -relea ing 4ebugger memory. an" -"e troying ob<ect . A program that i u e" to a i t in "ebugging. A "ebugger may be u e" to tep through a program in tage % an" e&amine the !alue o$ "ata !ariable at "i$$erent point in 4ebugging the program e&ecution. The proce o$ locating bug #ithin the program co"e. Thi can be "one by rea"ing the co"e to check a e'uence o$ operation % tepping through tage u ing a "ebugger% an" a""ing check an" 4ecimal te t #ithin the program co"e. An Arabic number y tem ba e" on the !alue 10. The "ecimal number y tem i the number y tem u e" $or e!ery"ay u e. A point u e" to eparate the #hole/number part o$ a number $rom the $ractional part% or alternati!ely u e" to eparate 4eclarati!e thou an" in ome region . A language that con i t o$ a et o$ *2:

6anguage

"e$inition % rather than a et o$ tatement that are e&ecute" in e'uence. A program in a "eclarati!e language contain a et o$ $act or pattern "e$inition % #hich the language engine u e in an attempt to ol!e a problem that i pre ente"% or to match input pattern . An e&ample i a che / playing program% #here the program con i t o$ tatement "e$ining the mo!e on a che boar". 4eclarati!e language are not #i"ely u e". A tatement that pro!i"e in$ormation about the program% but i not e&ecute" a an operation. The "e$inition o$ !ariable are "eclarati!e tatement . The proce o$ tran lating encrypte" "ata into the original "ata $ormat. See -;ncrypte" 4ata. A !alue that i u e" in the ab ence o$ an o!erri"ing !alue. 3or

4eclarati!e Statement

4ecryption

4e$ault

*50

e&ample% the "e$ault !alue $or printer output may be the y tem "e$ault printer% unle printer i another electe". 4e$ault !alue

may be initial !alue that can be change"% or true "e$ault !alue #here the !alue #ill return to the "e$ault !alue i$ the o!erri"e i 4e$ault @!erri"e remo!e" A !alue u e" to o!erri"e a "e$ault !alue. 3or e&ample% tatement may be able to be printe" in "etaile" $ormat or ummary $ormat% #ith the output "epen"ing on the "e$ault !alue electe"% unle there i a -"etaile" only. or - ummary only. o!erri"e entere" 4e$en i!e +rogramming on a cu tomer recor". A programming tyle that attempt to impro!e the reliability an" robu tne o$ co"e by a!oi"ing a umption about pre!iou operation an" con"ition out i"e the ubroutine% an" by checking "ata that i pa e" into a *51

4elete

ubroutine. Eemo!e a recor" $rom a "ataba e or an item $rom a "ata tructure. 4e/allocate memory $or a "ynamic memory tructure. See 4e/Allocate. 4ata tore" in a "ataba e that ha been generate" by the y tem. In ome ca e % "eri!e" "ata coul" be "elete" an" re/generate" $rom the primary "ata. See al o -+rimary 4ata. A 3inite State Automaton that ha a ingle po ible tran ition $or each e!ent in each tate. Thi can be e&ecute" "irectly% in contra t to a 0on/"etermini tic 3inite State Automaton. The "e!elopment re$er to the e"itor% compiler% "ebugger an" other tool u e" in the "e!elopment o$ program . Thi may al o inclu"e other o$t#are tool uch a !er ion control y tem % ubroutine librarie an" er!ice a!ailable $or program *52

4eri!e" 4ata

4etermini tic 3inite State Automaton

4e!elopment ;n!ironment

4igit

"e!elopment. @ne o$ the character -0. through to -:.. Al o u e" a -"ecimal "igit. or -binary "igit.% #here the binary "igit can be either 0 or 1. An in"epen"ent election o$ an element in an array or matri&. 3or e&ample% in a t#o/"imen ional array% each element i electe" by t#o in"epen"ent number % ometime re$erre" to a ro# an" column% & an" y% etc. +rogramming language that upport array generally upport array up to a large number o$ "imen ion . A $eature or operation that i inclu"e" in the "e$ine" operation o$ a ubroutine% programming language or programming inter$ace. In contra t% an -un"ocumente". re ult i "etermine" e&perimentally an" may change #ith ne# !er ion o$ o$t#are or change"

4imen ion

4ocumente" 3eature

*53

4ouble

circum tance . Shortene" term $or -"ouble preci ion $loating point number.. Some programming language u e the term -"ouble. to "e$ine "ata !ariable o$ thi type. A li t "ata tructure in #hich each no"e contain a link to the ne&t no"e in the li t an" al o a link to the pre!iou no"e. Thi allo# canning in both "irection % an" in ert an" "elete operation may a lightly impler than #ith a ingle linke" li t. See -e&port. I e" to link to ubroutine librarie #hile a program i running. Thi may be u e" to acce operating y tem $unction % an" to link to

4oubly 6inke" 6i t

4o#nloa" 4ynamic 6inking

4ynamic Memory Allocation

o$t#are engine . )reating an" "e troying "ata ob<ect a a program run . Thi "oe not inclu"e !ariable that are create" a ubroutine tart an" $ini h% but re$er to memory block that continue to e&i t *5,

through the program operation ;"itor until they are $ree". A program that i u e" $or !ie#ing an" mo"i$ying program co"e. An e"itor i $eature imilar to a #or" proce or but inclu"e uch a "i playing language key#or" in "i$$erent color % in"enting co"e block an" ;l e recor"able key toke macro I e" #ith an -i$. tatement to e&ecute co"e #hen the con"ition i $al e. 8hen an -i$. tatement contain an -el e. ection% i$ the con"ition i true then the $ir t block o$ co"e i e&ecute" an" the -el e. co"e i the $ir t block i ;mbe""e" kippe"% other#i e kippe" an" the

-el e. co"e i e&ecute". )ontaine" #ithin another ection o$ co"e or a "ata tructure. 3or e&ample% embe""e" SK6 re$er to SK6 tatement entere" "irectly in program co"e. A "e cription o$ a ituation #here relate" co"e an" "ata item are *5*

;ncap ulation

groupe" into a ingle unit. Thi al o implie that the co"e an" "ata cannot be acce e" e&ternally% but mu t be acce e" through an inter$ace. Thi term i $re'uently u e" in ob<ect orientate" co"e. ;ncap ulation can impro!e co"e reliability by re"ucing the number o$ link an" interaction bet#een ;ncrypte" 4ata program ection . 4ata that ha been cramble" into an unrecogni able $ormat $or ecurity purpo e . ;ncryption i u e" in communication y tem % uch a large net#ork an" "igital mobile telephone communication . A #i"e range o$ encryption algorithm are a!ailable% ranging $rom tri!ial techni'ue to ophi ticate" ;ncryption ;ngine algorithm . The proce o$ encrypting "ata. See -;ncrypte" 4ata.. A ma<or o$t#are component that pro!i"e a range o$ $unction in a

*52

relate" area% uch a graphic "i play or calculation. ;ngine are acce e" through a programming inter$ace% an" may be linke" into a program or e&ecute a a eparate ;nhancement proce . )hange ma"e to a y tem to a"" a""itional $eature an" proce e . Similar to -maintenance.% although maintenance generally re$er to $i&ing bug an" minor change to enable continue" operation% #hile enhancement are larger a""ition o$ ne# ;ntity $unctionality. I e" in y tem analy i to re$er to a $un"amental "ata ob<ect% #hich may be implemente" a a "ataba e table. Al o a general term $or an in"epen"ent ;rror Eeco!ery $un"amental ob<ect. Taking action to enable proce ing to continue a$ter an error ha occurre". 3or e&ample% i$ "ata i mi ing% then a "e$ault !alue may

*55

be u e" to generate a partial re ult% rather that terminating the entire ;!ent proce . An e!ent i omething that occur

that re ult in a ection o$ program co"e being e&ecute" in an e!ent/ "ri!en y tem% or that re ult in a "ata me age being "eli!ere" to a ection o$ co"e in a me age/ ;&ception pa ing y tem. A "ata e&ception i a "ata problem that pre!ent normal proce ing. Thi may re ult in an error me age or ome other action. An e&ecution e&ception i an internal y tem error% uch a an attempt to "i!i"e a number by Aero. Thi may be trappe" by an error/han"ling ;&ecutable 3ile ubroutine. A $ile containing machine co"e that can be e&ecute" "irectly. The ource co"e o$ a program i compile" to pro"uce an e&ecutable ;&ecution $ile. The running o$ a program% or the per$orming o$ an action that i *57

peci$ie" #ithin a line o$ program co"e. 3or e&ample% #hen an e&pre ion #ithin a program i e&ecute"% the !alue #ill be calculate" an" the !alue o$ a !ariable may be et to e'ual the re ult. A -print. tatement may cau e te&t to be ent to a printer ;&ecution ;n!ironment #hen it i e&ecute". The har"#are an" operating y tem that the program run on. Al o kno#n a the -e&ecution plat$orm.. In the ca e o$ implementation that re'uire run/ time upport% uch a interprete" co"e an" co"e that run on !irtual machine % thi inclu"e the o$t#are component re'uire" to ;&ecution +lat$orm ;&ecution +ro$iler e&ecute the program. See -;&ecution ;n!ironment. A program that pro"uce a report o$ the e&ecution time pent in each ection o$ the co"e a$ter a program i run. Thi i u e" to i"enti$y

*5:

per$ormance bottleneck an" i"enti$y ection o$ co"e that can be mo"i$ie" to increa e e&ecution ;&port pee". =enerate "ata #ithin a y tem an" #rite it to a tran $er $ile% #hich i then u e" to import "ata by another y tem. Al o kno#n a -"o#nloa"ing.. 4e$ine ubroutine an" "ata name that #ill be a!ailable to co"e ;&pre ion out i"e a mo"ule. A combination o$ !ariable % con tant !alue an" operator that pro"uce a calculate" re ult. 3or e&ample% -2 D 3 C *.. Another e&ample i -!arP3Q > *3 A04 y _ 3al e &. A Boolean !alue% the other Boolean !alue being True. See al o -Boolean.. I ually implemente" internally a the 3iel" !alue Aero. Ee$er to an in"i!i"ual "ata !ariable #ithin a tructure type% or an in"i!i"ual "ata item #ithin a *70

"ataba e recor". Thi may be a number% te&t tring% or a -co"e" 3I3@ $iel".. See al o -co"e" $iel".. 3ir t/In/3ir t/@ut. I e" in e!eral conte&t . A -'ueue. i a 3I3@ "ata tructure% #here the $ir t "ata item place" in the 'ueue i the $ir t one retrie!e". In caching% a 3I3@ cache "i car" the "ata that ha been in the cache $or the longe t perio" o$ time #hen ne# 3ile recor" are rea" into the cache. Many operating y tem manage "ata in block kno#n a a -$ile.. A $ile i name"% copie" an" "elete" a a ingle unit. A $ile may contain "ata uch a a ingle "ocument or program% or it may 3inite State Automaton contain an entire large "ataba e. A y tem that in!ol!e "e$ining a et o$ tate % an" a et o$ tran ition $rom one tate to another ba e" on e!ent . 3inite State Automaton are u e" in par ing an" te&t proce ing. An

*71

3SA i !ery $a t a it inclu"e a imple tran ition at each point an" "oe not in!ol!e backtracking. 1o#e!er% creating an 3SA "irectly can be "i$$icult% an" ome algorithm create an 3SA automatically $rom another tructure uch a a language grammar or a te&t matching pattern. Al o kno#n a a 3inite 3i&e" +oint State Machine. A type o$ number torage $ormat that inclu"e a $i&e" number o$ "igit o$ preci ion be$ore the "ecimal point% an" a $i&e" number o$ "igit a$ter the "ecimal point. Thi i not upporte" by har"#are a commonly a integer an" 3lag $loating point $ormat are. A Boolean !ariable% #ith a !alue TEI; o$ 3A6S;. Thi i u e" to in"icate option an" to tore re ult "uring proce ing. 3or e&ample% - ort a cen"ing trueN$al e. *72

3lat 3ile

A $ile that i un tructure" an" imply contain a li t o$ "ata in te&t $ormat% uch a "ata recor" tore" a ro# an" column . Thi i u e" to tran $er "ata bet#een y tem . Shortene" term $or -$loating point number.. Some programming language u e the term -$loat. to "e$ine !ariable o$ thi type. A type o$ number torage that inclu"e a number o$ "igit o$ preci ion% an" a eparate number peci$ying the iAe o$ the number. 3or e&ample% 12300000 coul" be tore" a 1.23 & 105% #hile 0.000000123 coul" be tore" a 1.23 & 10/5. Mo t computer har"#are upport integer an" $loating point $ormat . A key#or" commonly u e" in thir"/generation programming language to repeat a loop o$ co"e a certain number o$ time % uch a -$or i ? 1 to 100. In a relational "ataba e% a $oreign *73

3loat

3loating +oint

3or

3oreign Hey

key i the primary key o$ another recor"% tore" a a "ata item to pro!i"e a metho" o$ acce ing the relate" recor". 3or e&ample% an account recor" may contain a client number $iel" to recor" the client number o$ the client relate" to the account. See al o -ca ca"ing up"ateN"elete.% 3ormal "e!elopment metho"ology -primary key.% -compo ite key.. A tructure" an" planne" techni'ue $or "e!eloping y tem % u e" mainly $or "ata proce ing y tem . Thi inclu"e a number o$ clearly "e$ine" tage % an" a et o$ tool an" tructure #hich ho# the ma<or $un"amental "ata item an" their connection . 3unction may al o be "e$ine" u ing a tructure" 3ormal language "e$inition metho". A "etaile" peci$ication that attempt to peci$y all operation o$ the language% inclu"ing *7, uch a -entity relation hip "iagram .%

peci$ying #hich operation are not inclu"e" #ithin the language $acilitie % or ha!e un"e$ine" re ult . In ome ca e tructure" in$ormation uch a a -language grammar. may be inclu"e". Thi peci$ication may be u e" a a re$erence gui"e to check peci$ic i ue % an" al o $or the pro"uction 3ortran o$ o$t#are uch a compiler . A thir"/generation programming language that i particularly u e" in engineering an" cienti$ic application . 3ortran an" )obol #here the $ir t #i"ely/u e" 3ourth/ =eneration 6anguage 3ragmente" A "ata tructure ha contain a large number o$ mall eparate block % rather than a $e# large block . Thi ari e $ollo#ing $re'uent a""ition an" "eletion . 3ragmentation occur #ith "i k programming language . See -Application =enerator..

*7*

$ile % an" al o #ith "ata tructure uch a a -heap.. 3ragmentation re"uce per$ormance by increa ing earch time % an" i correcte" by coale cing mall $ree block into larger $ree block % or by rebuil"ing 3ree memory the "ata tructure. (noun) 3ree memory i memory that i not allocate" to a peci$ic purpo e% an" i a!ailable $or allocation $or ne# "ynamic "ata ob<ect . (!erb) 3reeing memory in!ol!e "i car"ing "ynamic memory ob<ect an" relea ing the memory allocation. See al o -"e/ 3unction allocation.. A term u e" in ome programming language $or a ubroutine that 3unctional Speci$ication return a ingle "ata !alue. A "ocument pro"uce" "uring Sy tem Analy i that peci$ie the "etaile" $unction an" calculation that a y tem houl" per$orm. A $unctional

*72

peci$ication may al o "e$ine the "ata item to be tore" an" 3unctionality =arbage collection proce e". The $eature an" $acilitie that a o$t#are component pro!i"e . A proce o$ canning a "ynamic memory allocation tructure to per$orm proce ing uch a coale cing $ragmente" memory block into larger block . =arbage collection i u ually per$orme" automatically in language that re'uire it $or "ynamic memory management% although in ome ca e a $unction can be e&plicitly calle" to per$orm garbage collection #hen re ource le!el or =enerality e&ecution pee" "rop. I ue relating to co"e per$orming a range o$ $unction % rather than a $i&e" et o$ proce e . 3or e&ample% a report $unction that print a report $or any gi!en "ata et% column combination an" ort or"er ha a higher "egree o$

*75

generality than a group o$ $unction that generate peci$ic report . Thi ha a"!antage #ith $le&ibility an" $uture "e!elopment% but "i a"!antage #ith greater =enerate internal co"e comple&ity. )reate a et o$ "ata% $ollo#ing a "e$inition o$ the proce . 3or e&ample% a 3 "imen ional graphic "i play coul" be generate" a$ter =eorgian )alen"ar =lobal 9ariable =oto the ob<ect ha" been "e$ine". The tan"ar" 8e tern calen"ar inclu"ing the t#el!e month o$ the year% leap year etc. A !ariable that can be acce e" $rom co"e in any part o$ the y tem A tatement a!ailable in many thir"/generation language $or <umping to a peci$ic place in the co"e an" continuing e&ecution at =rammar that point. A $ormal "e cription o$ the ynta& o$ a programming language% i.e. the combination o$ ymbol that #ill generate !ali" program . *77

=rammar in certain peci$ic $orm can be proce e" automatically to pro"uce a par er% #hich i the ection o$ a compiler that break a program into it =ue component part . Some numeric algorithm re'uire an initial !alue in or"er to commence the proce . Thi i a gue or e timate o$ the appro&imate olution to the 1an"le e'uation or proce . A !alue that i returne" to a calling proce to i"enti$y a "ata ob<ect that ha been create". Thi han"le i then pa e" back in $uture ubroutine call to i"enti$y #hich "ata ob<ect a $unction 1ar" houl" be applie" to. I e" in e!eral conte&t to mean a !alue that i $i&e"% in contra t to a - o$t. !alue that can be change". 1ar"/#ire" chip u e" tran i tor to per$orm calculation % #hile microco"e" chip u e a imple

*7:

internal program to e&ecute in truction . -1ar"/co"ing. i the practice o$ inclu"ing $i&e" !alue #ithin a program% uch a name an" "e$ault !alue % in contra t to rea"ing !alue $rom a "ata $ile that 1ar"#are can be mo"i$ie". ;lectrical component #ith a computer% inclu"ing memory chip an" the computer( central proce ing unit #hich e&ecute the program . Some numeric calculation are e&ecute" in har"#are by the central proce ing unit% #hile other calculation are per$orme" in o$t#are by program 1a h 3unction ubroutine . A calculation $or generating a eemingly/ran"om in"e& $rom an input tring. The in"e& peci$ie the location in memory o$ the "ata% an" the ame $unction i per$orme" #hen the "ata i being 1a h Table retrie!e". A -ha h table. i a "ata tructure

*:0

that tore "ata in ran"om location . The "ata i i"enti$ie" by a -key.% #hich i an in"e& generate" by applying a calculation to the input key. 1a h table allo# almo t "irect acce to "ata item u ing tring a key % but only in"i!i"ual item can be retrie!e"% item cannot be 1ea" 1eap retrie!e" in e'uence. A pointer to the $ir t item in a li t. A -heap. i a "ata tructure that i u e" $or allocating memory block o$ !ariou iAe . 4ynamic memory allocation $or creating ne# "ata 1e&a"ecimal ob<ect may be "one u ing a heap. The he&a"ecimal number y tem i an Arabic number y tem #ith a ba e o$ 12. Thi i u e" mainly a a hort/han" #ay o$ recor"ing binary number . A 12 i an integer po#er o$ 2% each he&a"ecimal "igit "irectly relate to $our binary "igit . The he&a"ecimal character are -0. to

*:1

-:. an" -A. to -3.% $or i&teen po ible "igit in each po ition. 3or e&ample% 3A2; ? 3&,0:2 C 1o t 10&2*2 C 2&12 C 1,&1 A computer% operating y tem% application or programming language that pro!i"e an en!ironment in #hich a program can operate. 3or e&ample% an application may be mo"i$ie" to run on e!eral "i$$erent operating y tem . ;mbe""e" SK6 tatement appear #ithin a -ho t language.% #hile macro routine Icon are #ritten in a ho t application. A mall graphic image% o$ten u e" to elect an in"i!i"ual I4 $unction. -I"enti$ier.% uch a a recor"/I4 #hich #oul" be a numeric $iel" on the recor" that containe" a !alue I$ i"enti$ying the recor". A tatement a!ailable in many language $or per$orming the $un"amental con"itional e&ecution element o$ proce"ural *:2

programming. I$ an e&pre ion i true% then a block o$ co"e i e&ecute"% other#i e it i kippe". 3or e&ample% -i$ "ay UinUmonth ? Illegal 31 then X. A !alue or operation that i not recogni e" by a language an" generally gi!e ri e to an error con"ition. 3or e&ample% i$ memory ha" been altere" an" containe" incorrect "ata% the central proce ing unit may attempt to e&ecute a !alue that "i" not corre pon" to a recogni e" in truction. Thi #oul" gi!e ri e to an -illegal in truction error.. Implementatio An actual program that per$orm a n "e$ine" ta k% a "i tinct $rom the "e ign it el$. 3or e&ample% a compiler implement a programming language by generating an e&ecutable $ile $rom Importe" a ource co"e $ile. Subroutine an" !ariable name "e$inition that re$er to ob<ect

*:3

that are e&ternal to the main Importing y tem Eea"ing a tran $er "ata $ile into a y tem% an" toring the "ata in a "ataba e or et o$ $ile . Al o In"enting kno#n a -uploa"ing.. Inclu"ing pace at the beginning o$ a line o$ co"e to !i ually eparate ection o$ co"e. )o"e i generally in"ente" $or an a""itional le!el #ithin each control $lo# block uch a a loop or -i$. tatement. )o"e #ithin the centre o$ an -i$. tatement an" t#o loop #oul" be in"ente" by three le!el . An in"enting le!el may corre pon" to a tab character% or 2% , or 7 pace "epen"ing on In"e& the layout tyle. A number u e" to re$erence an element in an array. Array element are generally re$erence" in integer or"er uch a 1% 2% 3% an" may begin at 0% 1 or ome other number.

*:,

A "ata tructure u e" #ithin a "ataba e to increa e the pee" o$ ran"omly acce ing a recor". Thi i may be a balance" tree tructure In"irect uch a a B/tree. In"irect acce occur #hen e!eral tep are in!ol!e" in acce ing a "ata item. 3or e&ample% acce ing a !ariable u ing a pointer i a ingle le!el o$ -in"irection.. I$ that !ariable #a a pointer it el$% t#o le!el o$ in"irection #oul" be re'uire" to acce the "ata item. Thi i al o kno#n a -"e/re$erencing. a pointer. I ing array % in ome "ata tructure an array may contain a !alue #hich i u e" a the in"e& to a eparate array. Thi i an in"irect In$inite loop array acce . A loop that continue $ore!er an" ne!er terminate % "ue to a program bug. 3or e&ample% i$ tructure A containe" a link to tructure B% #hich #a linke" to tructure )% *:*

#hich #a linke" back to tructure A% then $ollo#ing the link #oul" lea" to an in$inite chain that ne!er In$i& ;&pre ion terminate". An in$i& e&pre ion i an e&pre ion #here the binary operator (the operator u ing t#o !alue ) occur bet#een the t#o !alue . Thi i the u ual metho" o$ #riting e&pre ion % uch a -2 / (3 C *) D ,.. ;&pre ion are generally not tore" internally in thi $ormat% a they cannot be e&ecute" "irectly until the or"er o$ the operation ha been "etermine". Thi proce the e&pre ion i i u ually "one at an early tage an" tore" in a eparate $ormat% uch a a -po t$i& In$ra tructure ("e!elopment en!ironment) e&pre ion.. The "e!elopment tool uch a

compiler an" e"itor % an" the ubroutine librarie that are u e" in the proce "e!elopment. *:2 o$ y tem

In$ra tructure (internal)

The practice o$ buil"ing general common mo"ule % an" program component that per$orm general $unction on "ata ob<ect % a an ai" to "e!eloping the main program it el$. A term u e" in ob<ect orientate" co"e #hen an ob<ect i "e$ine" that i an e&ten ion o$ another ob<ect. The ne# ob<ect inclu"e the "ata an" metho" o$ the main ob<ect a #ell a a""itional $eature a""e" in the ne# ob<ect. Initiali ation i the proce o$ "e$ining the !alue that a !ariable ha #hen the !ariable $ir t become acti!e. In ome language % a !ariable "eclaration can inclu"e an initial !alue. In ome language % !ariable are automatically initiali e" to !alue uch a Aero an" empty tring -.% #hile in other language !ariable commence #ith ran"om !alue % #ith "ata in memory *:5

Inheritance

Initiali ation (!ariable )

remaining $rom pre!iou Initiali ation co"e proce e . )o"e that i per$orme" at the beginning o$ a proce to et up the $acilitie u e" "uring the proce % uch a creating "ata tructure % rea"ing con$iguration Input $ile etc. 4ata that $lo# into a program $rom keyboar" input an" in$ormation rea" $rom "ataba e In ertion an" "i k $ile . A""ing a ne# recor" into a "ataba e or a ne# "ata item into a In tallation "ata tructure. The proce o$ copying $ile % regi tering ob<ect an" creating con$iguration in$ormation that i u e" to in tall a program on a In truction computer in a #orking or"er. A co"e that repre ent a peci$ic action. The computer( central proce ing unit continually e&ecute machine co"e in truction % #hich are numeric co"e repre enting action uch a

*:7

copying "ata $rom one memory location to another% per$orming calculation an" <umping to other point in the program to continue In truction et e&ecution. The li t o$ in truction that a central proce ing unit e&ecute . The e generally inclu"e operation $or mo!ing "ata bet#een memory location % comparing number an" <umping to other point in the program to continue e&ecution% an" per$orming ba ic calculation uch a a""ition an" Integer multiplication. A #hole number% uch a 0% 3, or /*. Integer !ariable are hea!ily u e" in program a they u e a mall amount o$ memory pace an" calculation on integer Integrate" !ariable are generally !ery $a t. Integrate" $unction are $unction that are combine" into a ingle unit. 3or e&ample% an integrate" "e!elopment en!ironment

*::

contain an e"itor% complier an" "ebugger #ithin a ingle u er inter$ace. -integrating co"e. in!ol!e taking a range to imilar proce e an" re/#riting a ingle general proce to replace the in"i!i"ual proce e per$orme" by Integrity the pre!iou co"e. 4ata tructure integrity occur #hen the link #ithin the "ata tructure ha!e not been corrupte". All pointer point to !ali" memory location % an" !alue uch a hea"er/count o$ the number o$ ob<ect #ithin the tructure are correct. The "ata tore" in the tructure may be incorrect% but the tructure hol" the "ata item together correctly. See al o Inter$ace -corrupt.. A connection bet#een t#o eparate thing . The u er inter$ace inclu"e the creen "i play an" keyboar" input u e" to run the program an" interpret the output. 200

An application program inter$ace% or er!ice inter$ace% i an inter$ace bet#een t#o ma<or co"e mo"ule ( ee Application +rogram Inter$ace). A - erial inter$ace. i a har"#are connection to a "e!ice that tran $er "ata in a tream o$ character % a ingle character at a Interme"iate )o"e time. In ome ituation % a compiler "oe not pro"uce machine co"e "irectly but initially pro"uce -interme"iate co"e.. Thi i a imple language that inclu"e !ariable re$erence an" tan"ar" operation % but generally ha no tructure% an" like a embly language i imply a li t o$ in"i!i"ual in truction . )ontrol $lo# #ithin interme"iate co"e i implemente" by <ump % either uncon"itional or con"itional on the !alue o$ an e&pre ion. Interme"iate co"e may be u e" a an interme"iate tep to a $ull 201

compilation% or it may be interprete" "irectly $or ta k uch a macro language an" u er/ Interprete" "e$ine" $ormula . An interprete" implementation o$ a programming language e&ecute the program ource co"e "irectly% rather than pro"ucing a machine co"e e&ecutable $ile. Internally a partial compilation to interme"iate co"e may be per$orme". Thi proce i lo#er than $ully/ compile" co"e but i u e$ul $or "ebugging% an" $or pecial/ Interpreter purpo e language . A program that e&ecute a ource co"e program "irectly% in contra t to a compiler that pro"uce an Interrupt e&ecutable $ile. A har"#are ignal that cau e a ection o$ co"e to commence e&ecution. Thi i u e" internally $or communication bet#een har"#are "e!ice . Interrupt are al o hea!ily u e" in har"#are

202

control application in"u trial proce Iterate

uch a

control. See al o

-polling.. To per$orm an action that i part o$ a repeate" action. 3or e&ample% one iteration o$ a loop in!ol!e e&ecuting the co"e block #ithin the loop a ingle time. Eepetition. Iteration in!ol!e repeating an action many time . 3or e&ample% the !alue o$ & in the e'uation -y ? &2 C &. cannot be "etermine" "irectly. An initial gue mu t be ma"e% an" continually re$ine" on each tep to "etermine the appro&imate olution. Thi i an iterati!e proce $or ol!ing the e'uation. A language "e igne" $or creating program #ithin internet #eb page . Fa!a i an ob<ect/orientate" language that u e "ynamic memory allocation an" run on a !irtual machine. Fa!a ha a )/like ynta&% although it i not "irectly

Iteration

Fa!a

203

"eri!e" $rom any pre!iou Fulian language. The <ulian calen"ar i an alternati!e calen"ar to the tan"ar" =eorgian calen"ar. A <ulian "ate i recor"e" a the number o$ "ay ince the 1 t o$ Fanuary% ,513 B.). A <ulian "ate can be tore" in a ,/byte integer !ariable. Fulian "ate are u e$ul becau e they u e a imple an" $a t "ata type% an" becau e they co!er a #i"e range o$ "ate % in contra t to many built/in language "ate $acilitie that co!er a re tricte" Hey "ate range. A te&t tring that i u e" to i"enti$y a "ataba e recor"% uch a a client co"e% or i u e" to i"enti$y a "ata item #ithin a "ata tructure uch a an a ociati!e array or Hey#or" ha h table. A key#or" i a #or" that $orm part o$ a programming language% uch a -an".% -i$.% -integer. etc.

20,

6anguage ;&ten ion

Al o kno#n a a -re er!e" #or".. Some compiler upport $eature that are not part o$ the tan"ar" language% an" are kno#n a language e&ten ion . A no"e #ithin a "ata tructure uch a a tree% #hich occur at an en"/point in the tructure an" "oe not ha!e any ub/tree connecte" to it. A tatement or e&pre ion in a programming language that #ill compile #ithout error. A legal tatement or e&pre ion "oe not guarantee that the re ult o$ the operation i "e$ine". In ome ca e a legal language tatement can pro"uce an un"e$ine" re ult #hich may !ary $rom compiler to compiler or ituation to ituation. The le&ical tructure o$ a language "e$ine the $ormat o$ the in"i!i"ual component part #ithin a language% uch a a number con tant% !ariable name an" operator uch a ->?.. 3or 20*

6ea$ 0o"e

6egal

6e&ical ;lement

e&ample% the $ormat o$ a !ariable name may be "e$ine" by the pattern -Pa/AA/TUQPa/AA/T0/ :UQD.% #hich i interprete" a a letter or un"er core% $ollo#e" by a letter% un"er core or "igit repeate" Aero or more time . See al o 6ibrarie - ynta&. A library i generally a collection o$ ubroutine that per$orm relate" $unction . Al o calle" a -$unction 6I3@ library.. 6a t/In/3ir t/@ut. A 6I3@ tructure or proce u e a la t/in/ $ir t/out approach. A - tack. i a 6I3@ tructure% #here the la t "ata item place" on the tack i the $ir t 6ink item remo!e". The proce o$ combining ob<ect co"e mo"ule an" linking the "ata re$erence together to pro"uce an 6inker 6i p e&ecutable $ile. A program that per$orm the linking operation. See al o -link. 6i p i a highly unu ual programming language. All "ata 202

an" co"e #ithin 6i p i proce e" a li t % an" 6i p co"e ba ically con i t o$ hun"re" o$ bracket % #ith occa ional !ariable name 6i t an" operator ymbol . A collection o$ item that can be acce e" in or"er. 6i t may be tore" in array % #here each item i acce e" ran"omly or in e'uence. Alternati!ely a -linke" li t. can be u e" #hich compri e no"e connecte" by pointer % #here an in"i!i"ual item can be a""e" or "elete"% but the entire li t mu t be earche" to locate a ingle 6ocal item. See al o -linke" li t. A local !ariable i a !ariable that can only be u e" #ithin a 6ock ubroutine. A lock i place" on an item to pre!ent another ob<ect $rom acce ing it. 3or e&ample% thi i ometime u e" in "ataba e up"ate % #here t#o recor" mu t be up"ate" a a et. In thi

205

e&ample% either both recor" or neither recor" houl" be up"ate"% an" a lock #oul" be place" on both recor" to pre!ent another application up"ating one recor" #hile the $ir t application #a mi"/#ay through up"ating the 6ocke" other recor". A $ile% "ataba e recor" or har"#are "e!ice that i una!ailable $or u e through being locke" by another application. Thi i generally "one to pre!ent con$lict "uring up"ate proce"ure % an" #ith har"#are "e!ice uch a a mo"em #here a tream o$ "ata i ingle continuou 6og

proce e". A $ile containing a li t o$ e!ent or "ata !alue relating to change o!er time. 3or e&ample% "uring "ebugging a log $ile may be #ritten o$ the !alue o$ a "ata !ariable% #hich #oul" recor" a erie o$ !alue changing a the 207

6ogic

program e&ecution procee"e". The -logic $lo#. or -control $lo#. o$ a program i the path that the program e&ecution take % an" i "etermine" by the -i$. tatement % loop % an" the !alue o$ "ata !ariable at !ariou point in time. Al o calle" -program logic.. The logical operator are A04% @E an" 0@T an" are u e" in logical Boolean e&pre ion . See al o -Boolean @perator. A co"e u e" to i"enti$y a u er to a y tem% uch a the u er( initial . A hortene" !er ion o$ -6ong Integer.. In many programming language the term -6ong. i u e" to "eclare !ariable o$ thi type. A long integer #oul" u ually contain at lea t , byte o$ "ata% repre enting number up to appro&imately t#o billion i although the iAe may !ary bet#een programming language % an" in ome ca e bet#een "i$$erent implementation . 20: iAe%

6ogical @perator

6ogon 6ong

6ookup Table

A table or array that contain con tant "ata or "ata that i u e" a a re$erence #hile a program i running. 3or e&ample% a tran lation table that i u e" to con!ert common character to horter binary co"e "uring a "ata compre ion proce . See -table.. A ection o$ co"e that i repeate" e!eral time . Thir"/generation language make e&ten i!e u e o$ loop . The binary number in truction that are e&ecute" "irectly by the computer( central proce ing unit. Machine co"e can be create" $rom a embly language% #hich i one/to/one te&t !er ion o$ machine co"e% or $rom a high le!el programming language by a compiler. A metho" a!ailable in ome language to change the program co"e prior to compilation by "e$ining a -macro e&pre ion. that 210

6ookup Table 6oop

Machine )o"e

Macro

operate in a imilar #ay to a one/ line ubroutine. A -macro language. i a programming language that i u ually ho te" #ithin an application% an" may be a peci$ically create" language or a !er ion o$ a tan"ar" Magic 0umber programming language. A number that i "e igne" to i"enti$y a type o$ $ile or "ata tructure% an" i u e" to check $or incorrect ob<ect an" "ata Maintenance corruption. Bug $i&e an" minor repair to y tem % u ually implemente" to allo# normal operation to continue. A "i tinct $rom upgra"e an" enhancement #hich Mapping a"" ne# $unctionality. Tran lating one et o$ !alue to another% uch a con!erting a $ile tore" u ing one character et to a Matri& $ile u ing another character et. A mathematical ob<ect that i imilar to a program array. A 211

matri& i a 'uare tructure% i.e. a matri& #ith * ro# an" 12 column #a 12 column on e!ery ro#% an" * ro# in e!ery column. A matri& can ha!e one "imen ion% #here each element i i"enti$ie" by a ingle number% t#o "imen ion % #here each number i i"enti$ie" by t#o in"epen"ent number uch a a ro# an" column% or higher "imen ion . Some mathematically/orientate" language inclu"e operator $or per$orming matri& calculation % but mo t general programming Memory language "o not. 8hile program are running% the program in truction an" "ata !alue are tore" in memory. Memory i implemente" in computer chip #hich tore binary number . ;ach memory location i i"enti$ie" by a number kno#n a an -a""re .. In many computer a ingle location hol" one -byte.% 212

#hich can repre ent a number $rom 0 to 2**. Thi number may be a mall !alue% part o$ a larger number% a co"e repre enting a letter or program in truction% or ome other "ata uch a part o$ a Menu graphic image. A li t o$ option that can be electe" $or operation to be per$orme"% commonly u e" in both character/ba e" an" graphical Me h u er inter$ace . A pattern o$ connection #here a et o$ point are each connecte" to e!eral nearby point . 3or e&ample% the ur$ace o$ ob<ect u e" in 3/"imen ional graphic "i play i o$ten "e$ine" a a large number o$ mall triangle % #ith each triangle <oine" to a"<acent triangle along each o$ the three Metho"ology i"e . A tructure" an" $ormal approach to y tem "e!elopment% "e$ining peci$ic tep in the proce an"

213

in$ormation pro"uce" at each tage% uch a -$unctional peci$ication . an" -entity Metho" relation hip "iagram .. A metho" i an operation that can be per$orme" on a "ata ob<ect in an ob<ect/orientate" y tem. Metho" are implemente" a Microco"e ubroutine . )entral proce ing unit are generally either har"/#ire"% #here operation are per$orme" "irectly by tran i tor Microco"e i #itching on an" imple programming o$$% or they u e -microco"e.. in truction that operate internally to the computer chip. The e in truction are e&ecute" by an internal controller an" e&ecute the Mo" in truction et o$ the chip. Shortene" term $or -mo"ulu .. The mo"ulu i the "i$$erence bet#een the integer multiple an" the actual multiple in a "i!i ion. 3or e&ample% 13 N * i e'ual to 2.2%

21,

o the integer (#hole number) part e'ual to 2. Thi i the ame re ult a 10 N *% o the mo"ulu o$ 13 N * i e'ual to 3% the "i$$erence bet#een 13 an" 10. The Mo" operator i upporte" in mo t programming language that inclu"e integer arithmetic. The re ult o$ -A ? & Mo" y. coul" be calculate" a -A ? & J int(&Ny) D y.% #here -int(). return the integer part o$ the "i!i ion. Mo" can be u e" to generate a repeating cycle o$ number $rom a ri ing number% an" to map a #i"e range o$ eparate number on to multiple maller number % uch a mapping a large ha h table key to Mo"el a maller number o$ entrie . A tructure "e!elope" through the u e o$ a o$t#are tool% uch a an engineering "e ign. An approach to co"e tructure or y tem "e!elopment. A et o$ concept u e" a the 21*

$oun"ation o$ a y tem% uch a account an" tran action in accounting% $orce an" motion in imulating air$lo# in a phy ical y tem% or program % $ile an" e&ecution in a program e&ecution Mo"em cript language. Mo"ulator/4emo"ulator% a mo"em i a har"#are "e!ice u e" to inter$ace a computer to an e&ternal connection that "oe not u e binary "ata% uch a a telephone line or broa"ban" cable. 0et#ork connection u e net#ork inter$ace har"#are that "irectly Mo"ule tran port binary in$ormation. A unit o$ co"e that inclu"e e!eral ubroutine % an" generally per$orm a ingle ta k or $unction. In ome ca e a mo"ule i 0arro# Inter$ace tore" a a ingle operating y tem $ile. A narro# inter$ace i an inter$ace bet#een t#o proce e that pro!i"e the $unctionality #ith a mall number o$ operation an"

212

"ata ob<ect . Thi i not relate" to narro# ban"#i"th% #hich implie a lo# "ata tran $er rate. The SK6 "ata 'uery language i an e&ample o$ a narro# inter$ace% #here all "ataba e operation are pa e" a a ingle te&t tring. Thi approach ha bene$it in ea e o$ u e% an" allo# co"e on each i"e o$ the inter$ace to be change" in"epen"ently. In contra t a #i"e inter$ace ha many connection % uch a an inter$ace to a ubroutine library in!ol!ing a large number o$ eparate 0e te" ubroutine call . @ne tructure occurring #ithin another. A ne te" -i$. tatement i an -i$. tatement #ithin another -i$. tatement% a ne te" loop i a loop #ithin another loop% an" a ne te" "ata tructure i a tructure #ithin another tructure. In ome language % ubroutine can be "e$ine" #ithin other ubroutine % 215

an" can only be acce e" $rom 0et#ork #ithin the outer ubroutine. 1ar"#are connection bet#een computer allo#ing "ata tran $er. A mo"el that in!ol!e no"e that can be connecte" to multiple other no"e in a many/to/many pattern% in contra t to a tree tructure #here connection occur in one "irection an" a no"e may ha!e e!eral -chil". no"e % but only 0et#ork Tra$$ic 0e# one -parent. no"e. The !olume o$ "ata $lo#ing through a net#ork. A key#or" u e" in ome programming language to create a ne# "ata ob<ect "ynamically a a 0o"e program run . A "ata ob<ect that can be connecte" to other "ata ob<ect by link or -pointer .. Thi i u e" to create "ata tructure 0on/ "etermini tic 3inite State uch a tree an" linke" li t . A 3inite State Automaton that may ha!e e!eral po ible path $or a ingle input e!ent. It i 217

Automaton

generally not practical to e&ecute thi "irectly. 1o#e!er% ome algorithm pro"uce a 03SA $rom an input uch a a te&t matching pattern% #hich i then tran late" into a larger "etermini tic 3SA that can be e&ecute" "irectly. The Boolean operator that re!er e the !alue. -0ot TEI;. i e'ual to -3A6S;.% an" -0ot 3A6S;. i e'ual to -TEI;.. 3or e&ample% -i$ not recor"U$oun" then.. 8ith bit#i e operation % -0ot 0. i e'ual to -1. an" -0ot 1. i e'ual to -0.. A key#or" u e" in ome language to in"icate that a !alue i un"e$ine" or unkno#n% particularly u e" #ith pointer . 3or e&ample% #hen a pointer !ariable i $ir t create" i may ha!e the !alue 0I66% in"icating that it "oe not currently re$er to a !ali" "ata ob<ect. A tructure u e" #ithin ob<ect/

0ot

0I66

@b<ect

21:

orientate" programming that contain "ata item an" .metho" .% #hich are implemente" a ubroutine . @b<ect can be create" an" their metho" calle"% to per$orm @b<ect co"e $unction on the "ata. A complie"% machine/co"e !er ion o$ a program that "oe not ha!e the internal re$erence linke" together. Thi tep i "one by a -linker. to pro"uce an e&ecutable @b<ect/ @rientate" $ile. A mo"el o$ co"e tructure that in!ol!e "e$ining a et o$ ob<ect % #ith each ob<ect containing "ata item an" relate" ubroutine . Thi i a -"ata/centere". approach% #here $unction are -attache". to "ata ob<ect % in contra t to other techni'ue #hich may be -co"e/ centere". approache % #here "ata i pa e" to proce e . Thi mo"el i u e$ul $or y tem /le!el an" $unction/"ri!en co"e% but i le 220

applicable to proce /"ri!en @p )o"e y tem . @peration co"e. A numeric !alue repre enting an in truction% uch a a machine co"e in truction% interme"iate co"e in truction% or !alue pa e" to a o$t#are component to i"enti$y the @perator operation to be per$orme". A ymbol or key#or" that peci$ie a relation hip in an e&pre ion. 3or e&ample% that a""ition operator -C.% an" the Boolean operator A04. Thi peci$ie both a relation hip an" an action. 3or e&ample% in the e&pre ion -2 D 3.% the operator -D. igni$ie that the !alue o$ thi e&pre ion i e'ual to t#o multiplie" by three (a tatement o$ a $act)% an" that thi !alue coul" be "etermine" by taking the t#o !alue an" per$orming a multiplication (an action). In contra t% $unction call uch a 221

-print( -hea"ing. ). are imply an operation to be per$orme"% not a tatement o$ a $act. See al o -Boolean operator.% -compari on operator.% -arithmetic operation.% @perator @!erloa"ing -mo"ulu .. A term u e" in ob<ect orientate" programming. @perator o!erloa"ing re$er to a programming language $acility that allo# operation to be "e$ine" on ne# "ata ob<ect u ing the e&i ting language operator . 3or e&ample% the tatement -li t ? li t C ne#Uno"e. coul" be u e" to a"" a ne# no"e to a li t% i$ the operator -C. ha" been o!erloa"e" @ptimi ation $or the no"e "ata type. Impro!ing an" re$ining co"e% particularly to operate more e$$ecti!ely $or a particular ta k. 3or e&ample% graphic ubroutine may be re/#ritten an" optimi e" to #ork e$$iciently #ith large block o$ "ata that are commonly 222

proce e" in graphic operation . A proce u e" in a compiler to maller an" generate co"e that i

e&ecute more 'uickly. A large number o$ techni'ue are u e" by compiler to optimi e co"e% inclu"ing re/arranging tatement to pre!ent unnece ary recalculation % an" generating peci$ic machine co"e in truction $or certain circum tance . A proce u e" to pro"uce the ma&imum or minimum or a particular !alue% ba e" on a"<u ting $igure #ithin con traint . 3or e&ample% the proportion o$ the input to a chemical proce may be optimi e" to pro"uce the ma&imum yiel" o$ the "e ire" output% ub<ect to the con traint that the proportion umme" to 100O% an" that no $igure #a a @ptimi e" negati!e number. +rogram co"e or a generate" 223

e&ecutable $ile that ha been @r ub<ect to an optimi ation proce . The Boolean operator -or.. A logical Boolean -@E. e&pre ion i TEI; i$ either part o$ the e&pre ion i TEI; or both part are TEI;% other#i e it i 3A6S;. A bit#i e Boolean e&pre ion ha the !alue 1 i$ either o$ the !alue i 1 or they are both 1% other#i e it ha the !alue 0. Al o kno#n a the inclu i!e/or. See al o -e&clu i!e/ @rthogonality or.. Meaning -in"epen"ent.. @rthogonality re$er to a ituation #here e!eral option or $unction are in"epen"ent% an" one !alue can be change" #ithout a$$ecte" another !alue. The implication o$ thi i that all combination o$ the !alue #oul" be po ible% a a re triction on certain combination #oul" imply that the !alue #ere "epen"ant on each other% an" coul" not be electe" 22,

in"epen"ently. A general principal applie" to the peci$ication o$ programming language % an" the "e!elopment o$ general/purpo e @!er$lo# $acilitie . A ituation #here a calculation generate a !alue that i too large $or the "ata type. 3or e&ample% a igne" 2/byte integer can repre ent a number up to 32%525. I$ a !alue o$ 30%000 #a a""e" to a !alue o$ 20%000% then thi #oul" generate an o!er$lo# con"ition. Thi #oul" generate an error that coul" be trappe" by an error han"ling routine. In ca e #here the error #a not trappe"% in many ca e the program #oul" terminate at that point #ith a me age uch a -Integer @!er#ritten Memory o!er$lo#.. See al o -un"er$lo#. In ome programming en!ironment an" #ith ome language % an error in the co"e can re ult in an incorrect memory 22*

location being mo"i$ie". 3or e&ample% u ing a pointer to the #rong type o$ "ata ob<ect may re ult in the "ata item $rom one tructure type being #ritten into a memory location inten"e" $or a "i$$erent tructure type. In ome en!ironment thi may generate an error% #hile in other a memory corruption occur an" the program may continue operating% but cra h much later in an unrelate" ection +acket o$ the co"e. Block o$ "ata that are ent through a net#ork. )omputer "ata net#ork commonly u e packet +age "ata tran $er . A ection o$ memory. In ome y tem memory i manage" in page % #hich are tran $erre" bet#een "i k torage an" internal memory. Thi i generally tran parent to the running program% but in ome y tem thi may a$$ect per$ormance #ith 222

tructure

uch a !ery large

array . I$ the or"er o$ looping i electe" o that acce e occur at "i tant place in memory (re'uiring repeate" page $etche $rom "i k)% rather that rea"ing e'uentially through memory location % per$ormance may be +arallel +rogramming lo#er. A rarely u e" techni'ue that allo# ubroutine to be run imultaneou ly. +arallel programming language may be pecially mo"i$ie" !er ion o$ tan"ar" programming language . +arallel programming re'uire ynchroni ation co"e to pre!ent con$lict in up"ate % an" to en ure that proce e "o not run until other re'uire" proce e ha!e $ini he". The e y tem are e&tremely "i$$icult to "ebug% an" o$$er little bene$it o!er other +arallel approache . @perating t#o y tem an" 225

te ting

comparing the re ult "uring te ting. Thi may be an original y tem an" a re"e!elopment% or another combination uch a a pro<ect y tem an" a commercial y tem. A !alue that i pa e" to a ubroutine #hen it i calle". 3or e&ample% a ubroutine to con!ert the character in a tring to lo#er ca e letter #oul" take a tring a a parameter% an" return a tring re ult. A no"e in a "ata tructure% or a "ataba e recor"% that may ha!e e!eral -chil". ob<ect connecte" to it. In a one/to/many tructure% a parent recor" may ha!e e!eral chil" recor" % but a chil" recor" ha only one parent. The ymbol -(- an" -).. @$ten calle" bracket % but technically bracket are the 'uare bracket ymbol -P- an" -Q.. The proce o$ canning a tructure% an" breaking it "o#n 227

+arameter

+arent

+arenthe i

+ar e

into it component part . Thi i "one #ithin a compiler to "etermine the tatement % e&pre ion an" in"i!i"ual part o$ +ar er the program co"e. A program or ubroutine that per$orm a par e operation. See +a cal al o -par e. A thir"/generation programming language% name" a$ter the mathematician Blai e +a cal% #ho in!ente" the $ir t mechanical calculating machine o$ mo"ern +a ing +arameter time . )alling a ubroutine an" inclu"ing !ariable or e&pre ion . The !alue o$ the e !ariable or e&pre ion i then a!ailable to the ubroutine to per$orm calculation +atch#ork Sy tem +attern Matching an" proce ing. A y tem that ha been ub<ect to many change an" i poorly tructure". A metho" u e" to earch $or certain type o$ te&t. 3or e&ample% $or e&ample% the pattern -i$Dthen. 22:

may match the letter -i$.% $ollo#e" by a erie o$ letter (the D)% $ollo#e" by the letter -then.. +attern matching i u e" in te&t proce ing ta k uch a compiling an" earching. +attern matching i al o u e" in other application % uch a han"#riting recognition $or e&ample. See al o +i&el -regular e&pre ion.. A ingle point #ithin a graphic image. A pi&el ha a number a ociate" #ith it that repre ent a color. A graphic image i compo e" o$ multiple pi&el % peci$ying the color o$ each point +lat$orm +ointer #ithin the image. See -e&ecution en!ironment. A !ariable that contain the a""re o$ a location in memory. Some programming language upport pointer . +ointer are u e" to link "ynamic tructure together to create "ata tructure uch a linke" li t . In ome language %

230

pointer can al o be increa e" an" "ecrea e" to can through memory% an" per$orm operation on "ata uch a array % tring an" +olling block o$ binary "ata. )hecking a 'ueue% bu$$er or regi ter to "etermine #hether "ata ha been place" there% uch a #hen communicating #ith a har"#are "e!ice. +olling i generally "one repeate"ly. See +@+ al o -interrupt.. The operation per$orme" on a - tack. tructure #hen the "ata item on the top o$ the tack i remo!e". See al o - tack.% +opulate -+IS1.. To a"" "ata to a "ataba e or "ata tructure. Thi i u ually u e" in the conte&t o$ a""ing large !olume o$ "ata to an empty tructure% uch a a$ter a "ataba e con!er ion% or through manual keying #hen a ne# $eature i a""e" that re'uire a large !olume

231

+ortability

o$ "ata entry 8riting co"e in uch a #ay that a minimum number o$ change #oul" be re'uire" to mo"i$y the co"e to run on another type o$ computer y tem% or in another operating en!ironment. An e&pre ion that inclu"e the operator a$ter the !alue that they operate on. 3or e&ample% the in$i& e&pre ion -1 C 3 D ,. #oul" corre pon" to the po t$i& e&pre ion -3 , D 1 C.. +o t$i& e&pre ion "o not re'uire bracket . ;&pre ion are ometime con!erte" to po t$i& e&pre ion $or internal torage% a po t$i& e&pre ion can be "irectly e&ecute" $rom le$t/to/right u ing a tack. See al o -in$i&. The or"er that operation are per$orme" in. 3or e&ample% in arithmetic a multiplication i pre$orme" be$ore an a""ition% o in the ca e o$ -* J 2 D ,.% the

+o t$i& ;&pre ion

+rece"ence

232

multiplication #oul" be per$orme" be$ore the ubtraction. +rece"ence al o applie to other language operator uch a ->?. an" -A04.. Al o kno#n a -bin"ing +reci ion trength o$ an operator. The number o$ "igit o$ accuracy o$ the number. 3or e&ample% a $loating/point number type may inclu"e appro&imately 1* igni$icant "igit % along #ith an e&ponent that allo# the magnitu"e o$ the number to !ary +rimary 4ata $rom% $or e&ample% 10/32, to 10307 4ata tore" in a "ataba e that contain $un"amental in$ormation. Thi "ata may be ource" $rom manual keying% or uploa" $rom other ource . See al o -4eri!e" +rimary Hey 4ata.. A uni'ue "ata !alue that i"enti$ie a "ata recor" #ithin a relational "ataba e. Thi may be a ingle "ata $iel"% or a !alue that i compo e" o$ e!eral "ata $iel" .

233

+ri!ate

See al o -compo ite key.. A key#or" u e" in ome programming language to in"icate that a !ariable or ubroutine can only be u e" #ithin a particular mo"ule. See al o -public. A programming language that inclu"e a et o$ tatement that are e&ecute" in or"er. Mo t program are #ritten u ing proce"ural language . See al o -"eclarati!e language. A name u e" in ome programming language to re$er to a - ubroutine.. See al o - ubroutine. A et o$ operation to be per$orme". A running program. In ome ca e a running program may in!ol!e t#o or more proce e that e&ecute in parallel% uch a a main program an" a eparate $unctional engine. See -)entral +roce ing Init. 23,

+roce"ural

+roce"ure

+roce

+roce or

+rogram

A et o$ tatement an" e&pre ion #ritten in a programming language. A program i a complete et o$ tatement that can be compile" to machine co"e by a compiler% an" run a an in"epen"ent unit. See -logic. A -"eclarati!e. programming language. +rolog program con i t o$ a et o$ tatement o$ $act % rather than tatement that are e&ecute" in or"er. The prolog engine then u e the e $act to try an" ol!e a problem that i pre ente". 3or e&ample% a #eather/pre"iction program in prolog may inclu"e "etail o$ likely #eather ba e" on pre ure change % current tempreture etc. The prolog engine #oul" then u e the "e$ine" relation hip % together #ith the current "ata% to generate a #eather pre"iction. 23*

+rogram 6ogic +rolog

+ eu"o )o"e

A type o$ #ritten co"e that i inclu"e" in "ocumentation o$ a y tem "e ign% but i inten"e" $or a human rea"er% rather than a compile" computer program. Thi may inclu"e general tatement uch a -rea" ne&t recor".. A key#or" u e" in ome programming language to in"icate that a !ariable or ubroutine can be acce e" $rom co"e out i"e the mo"ule. An operation on a - tack. "ata tructure that in!ol!e a""ing a ne# "ata item to the top o$ the tack. See al o - tack.% -+@+. A tatement in a "ataba e 'uery language. Thi may "e$ine the tructure o$ a et o$ recor" to be retrie!e" or up"ate". A -'ueue. i a "ata tructure #here the $ir t "ata item place" in the 'ueue i the $ir t "ata item that i retrie!e". Kueue are u e" in internal operating y tem proce ing% imulation o$ ome 232

+ublic

+IS1

Kuery

Kueue

proce e % an" in "ata tran $er bet#een t#o ob<ect . See al o Kuick ort Eagge" Array -3I3@.% - tack. A $a t general purpo e orting algorithm. An array #here each column "oe not nece arily ha!e the ame length. Thi coul" be implemente" a a et o$ linke" li t % a large array #here the in"e& po ition #a calculate" $rom a $ormula% or by u ing a ha h table or tree #ith the ro# an" column !alue combine" Eea" Eecor" into a ingle key. To input "ata $rom a "ata $ile into a program !ariable. A "ata ob<ect in a "ataba e that i tore" an" retrie!e" a a ingle ob<ect. A recor" may contain multiple "ata item kno#n a Eecur ion -$iel" . A techni'ue #here a ubroutine call it el$. Thi metho" i u e" $or proce ing ome "ata tructure uch a tree % an" al o uch a 235 in ome algorithm

recur i!e/"e cent par ing. Eecur ion i a imple an" po#er$ul techni'ue but i "i$$icult in concept. Eecur ion i imilar to a chain o$ ubroutine #ith the Eecur i!e 4e cent +ar er ame co"e calling each other. A imple top/"o#n par ing metho" that u e recur i!e ubroutine % #ith one ubroutine $or each rule in the language grammar. See al o -par e.% Ee"un"ant )o"e -recur ion.. )o"e that calculate a re ult that i not u e"% or rea" a "ataba e recor" that i not acce e". Ee"un"ant co"e can occur a$ter change are ma"e to a y tem% #here one ection o$ co"e i re/ #ritten to u e a "i$$erent metho"% but an earlier ection o$ co"e that calculate" an input $igure remain Ee/entrant co"e in place. Technically a ection o$ co"e that can be e&ecute" by t#o or more proce e imultaneou ly% in a

237

multiple/proce

en!ironment. In

a #i"er en e% thi i ue applie to ubroutine that can be calle" $rom "i$$erent ection o$ the one program in an o!erlapping Ee$erence manner% #ithout con$licting. The a""re o$ a !ariable. Thi may be a igne" to a pointer% o that the "ata can be acce e" in"irectly by u ing a pointer. Al o% in ome language re$erence are u e" to pa ubroutine Ee$erential Integrity a""re e to o that the original

!ariable can be mo"i$ie". An i ue that ari e in relational "ataba e y tem #hen the primary key o$ a recor" i change". 3or e&ample% i$ a primary key o$ a client recor" #a change"% but other recor" re$erre" to the client co"e #ere not up"ate"% then the other recor" #oul" no longer be linke" to the client recor". Thi i ue can be a""re e" by u ing a -ca ca"ing 23:

up"ate. proce . See al o Eegi ter -ca ca"ing up"ate.. A "ata item that i tore" #ithin a central proce ing unit an" i u e" $or calculation . Eegi ter are al o u e" in har"#are inter$acing% an" in ome ca e a peci$ic memory location may link "irectly to a Eegular ;&pre ion har"#are "e!ice. A type o$ te&t pattern e&pre ion. Eegular e&pre ion can be u e" $or te&t earching% but are particularly u e$ul $or i"enti$ying the in"i!i"ual component #ithin program co"e% $or u e in compiler . A regular e&pre ion can be automatically tran late" into a 3inite State Automaton% #hich enable the input te&t to be canne" in a ingle pa #ithout backtracking. An e&ample o$ a regular e&pre ion i a po ible "e$inition o$ the pattern $or a !ariable nameB Pa/AA/TUQPa/AA/ T0/:QD. Thi i interprete" a any 2,0

character in the range -a. to -A. or -A. to -T.% or an un"er core character% $ollo#e" by any character in the range -a./-A.% -A./-T.% -0./-:. or an un"er core% repeate" Aero or more time . The -D. character igni$ie that the pre!iou character i repeate" Aero or more time . See Eelational 4ataba e al o -3inite State Automaton.. A "ataba e mo"el #here "ata i tore" in -table .. A table i a collection o$ "ata recor" % #ith each recor" being in the ame $ormat. Eecor" are i"enti$ie" by a "ata item kno#n a a -primary key.% uch a a tran action number on a tran action recor". )onnection bet#een recor" are implemente" by inclu"ing the primary key o$ the recor" being linke" a a "ata item on the other "ata recor" .Thi i kno#n a a -$oreign key.. See al o -recor".% -$iel".% -table.% -primary key.% 2,1

Eelational @perator

-$oreign key.% -in"e&.% -'uery. The operator le than% ->.% le than or e'ual to ->?.% greater than -_. an" greater than or e'ual to -_?.% e'ual% an" not e'ual. The operator $or e'uality !arie bet#een language but i o$ten -?.. In other language -??. or -.e'.. may be u e". The not/e'ual operator al o !arie % #ith ymbol uch a ->_. an" -Y?. being u e". A relational operation i a Boolean e&pre ion% o -3 >? *. ha a !alue o$ either TEI; or 3A6S; Ee$er to relea ing an allocation or lock that ha been place" on a re ource uch a program memory. See al o -4e/Allocate. A "ocument peci$ying the broa" purpo e an" role o$ a y tem% an" the ma<or operation that the y tem houl" per$orm. Thi may be upplie" a an input to the y tem "e!elopment proce % or may be compile" "uring an early

Eelea e Ee ource

Ee'uirement Speci$ication

2,2

analy i Ee er!e" 8or"

tage prior to y tem

analy i . A #or" that i u e" a a key#or" #ithin the language% an" cannot be u e a a !ariable name. 3or e&ample% -i$.. Al o kno#n a a key#or". The $ir t no"e in a tree or "ata tructure. The other no"e in a tree branch out $rom the root note. To hi$t the bit in a binary !alue to the le$t or the right% an" mo!e the bit that e&it the !alue into the po ition at the oppo ite en" o$ the !alue. See al o - hi$t.. To change a number to re"uce the number o$ igni$icant "igit . 3or e&ample% the number -3,.235. roun"e" to t#o "ecimal place i -3,.2,.. Eoun"ing may be to a number o$ "ecimal place % or a number o$ igni$icant "igit . See al o - igni$icant "igit . An i ue that ari e #ith calculation % particularly "i!i ion. Mo t programming language "o 2,3

Eoot 0o"e

Eotate

Eoun"

Eoun"ing ;rror

not per$orm calculation #ith true $raction % an" W #oul" be calculate" a 1 "i!i"e" by three% an" tore" a a number uch a 0.33333333. 1o#e!er% thi number multiplie" by three i 0.:::::::::% not 1.0% o W Sa$e multiplie" by 3 #oul" not e'ual 1. 1. A program tructure or tatement that "oe not re ult in a memory corruption #hen an error occur . 3or e&ample% a - a$e pointer. i a !ariable that #oul" re ult in an error me age being generate" i$ an incorrect !alue #a a igne" to the !ariable% rather than memory being o!er#ritten an" a program cra h occurring at a later time. 2. A language operation that pro"uce a clearly "e$ine" re ult. An -un a$e operation. i a language tatement that #ill compile an" e&ecute #ithout error% but #here the re ult o$ the 2,,

operation may !ary $rom compiler to compiler or ituation to ituation. See al o -corrupt "ata.% -o!er#ritten memory.% Scope -"ocumente".. The area o$ a program #ithin #hich a "ata !ariable or ubroutine can be acce e". 3or e&ample% local !ariable #ithin a ubroutine can only be acce e" #ithin the ubroutine it el$% an" not $rom co"e out i"e the ubroutine. =lobal !ariable can be acce e" $rom any point in a program. Some programming language ha!e imple coping le!el % #hile other language "e$ine multiple le!el o$ cope $or both "ata !ariable an" ubroutine . See al o -public.% Script 6anguage -pri!ate.% -global.% -local.. ;ither a -macro language.% #hich i ho te" #ithin an application% or a language u e" $or running 2,*

program an" managing $ile on a batch ba i . See al o -macro Search language.. 1. The proce o$ locating a "ata

item #ithin a "ata tructure. 4ata can be re$erence" "irectly in an array by an in"e& !alue% ho#e!er locating "ata that i i"enti$ie" by a te&t tring generally in!ol!e a earching proce . 3or e&ample% in a orte" array a -binary earch. metho" can be u e". 2. Scanning te&t or "ata to locate an item or pattern. 9ariou algorithm are u e" to peci$y an" earch $or pattern . See al o -regular e&pre ion.% -pattern matching.% -binary Semantic earch.. The meaning o$ programming language tructure . 3or e&ample% the le&ical analy i o$ a program may i"enti$y an operator -P-% the ynta& analy i "uring par ing may recogni e the pattern 2,2

-"ataP&Q.% an" the emantic proce ing #oul" interpret thi a a re$erence to the array -"ata. u ing the !ariable -&.. See al o Serial -le&ical analy i .% - ynta&.. @ccurring a ingle e!ent at a time% in or"er. 3or e&ample% a erial har"#are "ata inter$ace i a connection to a "e!ice% uch a a printer% that en" a ingle Ser!ice character at a time. A o$t#are component that per$orm a range o$ relate" $unction % an" "eli!er "ata or re ult . 3or e&ample% a calculation engine #oul" accept $ormula an" block o$ "ata% calculate the re ult % an" return them to the calling program. See al o Set -application program inter$ace. A collection o$ item % #ithout an or"er. Some programming language pro!i"e $eature $or "ealing #ith et . 3or e&ample% the collection o$ plant in a

2,5

greenhou e i a et% a there i no or"er to the item . The $un"amental operation on et are the -union. o$ t#o et % #hich i the et that contain item that are in either or both et % an" the -inter ection. o$ t#o et % #hich i the et o$ item that occur #ithin both et . See al o -li t.. To et the !alue o$ a boolean !ariable to TEI;% or to et a bit to Shi$t the !alue 1. A bit operation that in!ol!e hi$ting all the bit in a binary !alue% uch a a byte% a certain number o$ po ition to the le$t or the right. Thi i "one in ome bitmapping proce ing% an" al o a an optimi ation o$ multiplication by a po#er o$ t#o. Shi$ting bit one po ition to the le$t i e'ui!alent to multiplying the number by t#o% an" i u ually a $a ter operation. ;mpty pace may be $ille" by Aero% 1% or the 2,7

pre!iou character repeate". See Signe" al o -bitmap.% -rotate.. A numeric !ariable or calculation that recogni e both po iti!e an" negati!e number . Some programming language both igne" an" un igne" !ariable . In igne" arithmetic a ume that the bit pattern repre ent a po iti!e number% o a 2/byte integer !alue coul" repre ent /32%527 to C32%525 a a igne" number% or 0 to 2*%*3* a Signi$icant 4igit an un igne" !alue. The number o$ "igit #ithin a number that contain in$ormation. 3or e&ample% the number ,02200000 an" 0.0000,022 both ha!e $our igni$icant "igit . The accuracy o$ mea urement may be ba e" on igni$icant "igit % not "ecimal place % o a mea urement that #a accurate to 1 part in 1000 #oul" be accurate to three igni$icant "igit . See al o 2,: upport

Simulation

-roun".. A program that create a mo"el o$ a particular proce % an" multiple !alue to "etermine the po ible output . 3or e&ample% the $lo# o$ air o!er an aircra$t #ing may be mo"elle" by u ing calculation % an" u e" in "e igning the hape o$ the #ing. The $lo# o$ tra$$ic on a roa" net#ork may be imulate" by a uming tra$$ic !olume at "i$$erent time % an" calculating a!erage tra!el time . Simulation o$ten in!ol!e a large number o$ calculation . A horte" !er ion o$ - ingle preci ion $loating point number.. Some programming language u e the #or" - ingle. to "e$ine a !ariable o$ thi type. See al o -"ouble.. A linke" li t tructure% #here each no"e ha a ingle connection to the ne&t no"e in the li t. See al o -linke" li t. )omputer program . See al o 2*0

Single

Singly/linke" li t

So$t#are

So$t#are Tool

-program. A program that i u e" in "e ign% calculation an" per$orming a range o$ electable $unction % a oppo e" to a proce ing y tem that per$orm a range o$ $i&e" proce e . Arranging the item in a li t into an or"er% uch a an alphabetical or"er $or printing% orting a li t o$ item into the or"er o$ a te&t key% o that they can be 'uickly locate"% or orting a li t o$ number $or a numerical algorithm that proce e the large t "i$$erence or malle t "i$$erence $ir t. A number o$ "i$$erent orting algorithm are a!ailable% #ith large "i$$erence in proce ing pee". Sorting i a time/ con uming proce % an" a large proportion o$ all computer proce ing time i pent in orting. See al o -bubble ort.% -Kuick ort.% -Search.. -)ollating 2*1

Sort

Source )o"e

Se'uence.. Statement an" e&pre ion in a programming language. The co"e i tran late" into an e&ecutable machine co"e !er ion o$ the program by a compiler. Al o kno#n a -program co"e. or imply -co"e.. See 9er ion )ontrol Sy tem.

Source )o"e )ontrol Sy tem Spar e Array

A large array that contain many unu e" element . 3or e&ample% "ata recor"ing earth'uake o!er a long time perio" #oul" be par e "ata% a there #oul" be large an" !arie" gap bet#een the "ate o$ the e!ent . A "ataba e 'uery language. SK6 can be u e" to elect group o$ recor" to be retrie!e" or up"ate"% an" al o inclu"e tatement $or altering the tructure o$ "ataba e

SK6

S'uare Array

table an" other "ataba e ta k . An array or matri& that ha the ame number o$ column in e!ery 2*2

ro#% an" the ame number o$ ro# in e!ery column. Thi al o applie to higher/"imen ion array . See Stack al o -ragge" array.. A "ata tructure #here the $ir t element retrie!e" i the la t element that #a place" on the top o$ the tack. Stack are u e" "uring calculation to hol" temporary re ult % to hol" the local !ariable o$ ubroutine % an" in algorithm uch a ome bottom/ up par ing metho" . See al o State Statement -6I3@.% -'ueue.. See -3inite State Automaton. A ingle e&ecutable in truction #ithin a programming language. Thi may be a ingle line o$ co"e% or a tatement that contain an attache" co"e block. 3or e&ample% Static -i$ a _ b then. I e" $or !ariou purpo e in "i$$erent programming language % but a common u e i to igni$y that a !ariable retain it !alue. 3or e&ample% a tatic !ariable 2*3

#ithin a ubroutine #oul" retain it !alue $rom one call to the ubroutine to the ne&t% in contra t to the local !ariable that are ne#ly allocate" each time a Statically 6inke" ubroutine i calle". Subroutine in a ubroutine library that are linke" into a program an" become part o$ the e&ecutable $ile. Stre Te ting See al o -4ynamically 6inke". Te ting a y tem u ing large !olume o$ "ata% inten i!e automate" input% an" other proce e inten"e" to "etermine #hether the y tem #ill continue operating% or #ill operate #ith acceptable per$ormance le!el % un"er high/ tre con"ition . 3or e&ample% race betting y tem u ually recor" an e&tremely high rate o$ tran action in the $e# Strict type checking minute be$ore betting clo e . Strict type checking i a $eature o$ ome programming language that check the type o$ "i$$erent "ata

2*,

item #ithin program e&pre ion an" tatement . 3or e&ample% the e&pre ion -a!erageUcount ? totalUcount. may be an acceptable tatement in ome language i$ the !ariable -totalUcount. #a an integer numeric !ariable an" the !ariable -a!erageUcount. #a a $loating/point numeric !ariable% #hile in trictly type/checke" language thi may generate an error. Strict type checking i u e$ul in "etecting or a!oi"ing ome bug % ho#e!er it can make program co"e unnece arily in$le&ible an" lea" to a range o$ String minor problem . A mall te&t item% uch a an in"i!i"ual letter or a $e# #or" . String are u e" e&ten i!ely in Structure Type programming. Al o calle" a -recor". an" by other name in "i$$erent language % a tructure type i a "ata tructure that i compo e" o$ 2**

e!eral in"i!i"ual "ata item % uch a numeric !ariable an" tring . 4epen"ing on the particular language% tructure can be tore" in array % contain other tructure % be create" "ynamically a a program run % an" be linke" together u ing pointer . See al o Subroutine -pointer.% -linke" li t.% - tring.% A ubroutine i a ection o$ co"e that can be calle" a a eparate unit. 8hen a ubroutine name i re$erence" in co"e% e&ecution tran $er to the tart o$ the ubroutine co"e an" continue at that point. 8hen the ubroutine en" % e&ecution return to the ne&t tatement $ollo#ing the original call to the ubroutine. 4ata item can be pa e" to ubroutine a -parameter .. Subroutine can contain "ata !ariable kno#n a -local !ariable .. Al o kno#n a proce"ure % $unction an" metho" . See al o - tatic.% 2*2

-local.. -parameter% -call/by/ re$erence.% -call/by/!alue.% Symbolic )omputation -ne te".. Mo t programming language treat an e&pre ion a an operation to be per$orme"% rather that a mathematical tatement. 3or e&ample% the e&pre ion -y ? a C 2. #oul" be interprete" a -"etermine -a.% a"" t#o to the !alue% an" place the re ult in !ariable -y.. ;&pre ion uch a -y D & ? " J 3. #oul" generate an error. Some program $or #orking #ith mathematic upport ymbolic computation% in #hich the pre!iou e&pre ion #oul" be a !ali" e'uation. The y tem coul" then generally re/arrange the e'uation% an" ol!e $or the !alue Synchroni ati on o$ a particular !ariable. )o"e inclu"e" in parallel programming routine to co/ or"inate the $lo# o$ e&ecution in "i$$erent e&ecution tream . 3or 2*5

e&ample% co"e coul" be inclu"e" to pre!ent con$lict #hen t#o point o$ e&ecution attempt to up"ate the ame "ata. Al o% co"e coul" be inclu"e" to en ure that a point in the co"e "i" not commence e&ecution until other pre/re'ui ite ta k ha" complete". Synta& See al o -parallel programming.. Synta& "e$ine the #ay that in"i!i"ual element can be combine" to $orm e&pre ion an" tatement #ithin the language. 3or e&ample% the ynta& o$ a -$or. tatement may be "e$ine" a -$or >!ariablename_ ? >e&pre ion_ Table to >e&pre ion_. A et o$ "ata item o$ the ame tructure type. In a "ataba e% thi #oul" be the et o$ "ata recor" #ith the ame $ormat. In program co"e% thi may be an array o$ tructure type . A et o$ con tant "ata that i u e" a a re$erence #hile the program 2*7

i running. See al o -recor".% Tag - tructure.. A !alue u e" to i"enti$y a "ata ob<ect. 3or e&ample% ob<ect that are i"enti$ie" by te&t tring coul" be allocate" mall number i"enti$ier % to be u e" in proce ing $or "irect array lookup Terminal an" $a ter proce ing than tring . A !i"eo "i play unit% particularly one that "oe not per$orm any proce ing but connect to a Terminal 9alue computer by a "ata connection. A !alue u e" to igni$y the en" o$ a et o$ "ata. 3or e&ample% the !alue Aero may be u e" a a terminal !alue to in"icate the en" Te t +rogram o$ a te&t tring. A te t program or te t routine i a program or ection o$ co"e that i #ritten to te t a mo"ule o$ co"e% by calling the mo"ule% pa ing Thir" =eneration 6anguage "ata% an" interpreting the re ult . A proce"ural programming language that operate at the le!el o$ "ata !ariable % -i$. tatement % 2*:

loop % etc. 8i"ely u e" 3=6( inclu"e 3ortran% )% +a cal an" Ba ic. Some o$ the e language ha!e "eri!ati!e language that are e&ten ion o$ the original language. A large proportion o$ all program are #ritten u ing thir" Threa" generation language . An in"epen"ent e&ecution tream #ithin a program. In ome en!ironment % a running program can create a -threa". #hich i a eparate proce that e&ecute concurrently #ith the main program. Thi may be u e" $or backgroun" printing or up"ating% $or e&ample. A threa" u ually contain le proce ing than a complete program% but i not inten"e" to operate at the le!el o$ in"i!i"ual ubroutine e&ecuting Time licing in parallel. ;&ecuting e!eral proce e $or hort time perio" in a rotating e'uence% to create the ability to 220

run e!eral proce e Time tamp imultaneou ly. A "ate an" time !alue place" in "ata to in"icate #hen an e!ent occurre". 3or e&ample% a batch proce up"ating recor" may inclu"e a time tamp on each recor" in"icating #hen the recor" #a up"ate". Thi may al o inclu"e a""itional in$ormation uch a a u er logon an" program name. Time tamp are u e" in "ebugging% reconciling "ata% an" e tabli hing a e'uence o$ e!ent #hen mi ing or con$licting in$ormation occur . Time tamp al o are u e" in ituation #here real/time e!ent are important% uch a Token ynchroni ation bet#een no"e in a large net#ork. A numeric co"e u e" to repre ent an e!ent or type o$ item% uch a ingle ba ic element #ithin a programming language. The !alue o$ the token "oe not ha!e 221

particular igni$icance% in contra t to a numeric !ariable repre enting a number. 3or e&ample% a le&ical canner may tran late the ource co"e into a e'uence o$ token % #hile a proce communicating through a "ata channel may en" a token% to igni$y that a particular e!ent ha" occurre"% or that a particular re pon e #a re'ue te". Tolerance See al o -le&ical analy i .. The thre hol" "i$$erence bet#een t#o number . 3or e&ample% an iterati!e proce $or ol!ing an e'uation may continue until the re ult ha" been "etermine" to #ithin an accuracy o$ i& "ecimal place . See al o -roun"ing error.% Trace -iteration. A log $ile #ritten o$ the !alue o$ a !ariable a a program run % an" u e" in "ebugging. Al o u e" in Tran $ormatio n other conte&t . See al o -log.. A calculation that tran $orm one et o$ "ata to another% u ually a

222

ingle calculation applie" to a matri& o$ $igure . 3or e&ample% in graphic proce ing% the -per pecti!e. i generate" by applying a tran $ormation% ba e" on the !ie#er( po ition% to a Tran parent matri& containing the image "ata. A proce that "oe not a$$ect another proce % or i not a -!i ible. part o$ operation. 3or e&ample% i$ a "ataba e y tem upgra"e inclu"e" a change in the internal caching y tem% then thi #oul" be tran parent to the calling program% a the ame re ult #oul" Tree occur a the pre!iou $unction. A linke" "ata tructure that commence #ith a root no"e% #hich may ha!e t#o o$ more no"e connecte" to it% "epen"ing on the type o$ tree. In turn% each o$ the e no"e ha no"e connecte" to it. Thi $orm a tructure imilar to an up i"e/"o#n tree% branching out to more no"e at each le!el. 223

Tree are u e" in a number o$ "ata tructure an" algorithm % uch a orting% par ing% an" con!er ion $rom in$i& to po t$i& e&pre ion . See al o -no"e.% -binary tree.% -B True tree.. @ne o$ the Boolean "ata !alue % the other being -$al e.. See al o Truncation -Boolean.. Truncation occur in "i!i ion #hen the $ractional part o$ the re ult i "i car"e". Mo t integer "i!i ion pro"uce a truncate" re ult. In contra t% roun"e" re ult may be higher or lo#er% o !alue o$ -0.*. an" greater may be roun"e" up% #hile !alue le that -0.*. are roun"e" "o#n. The term -truncation. i al o u e" in other conte&t #hen part o$ a tructure i "i car"e". 3or e&ample% in an algorithm that generate" a large tree in earching $or a olution to a problem% the tree may be truncate" at !ariou point % "i car"ing ub/ 22,

tree % a part o$ the algorithm. See Tuple al o -roun". The technical name $or a -recor". in the relational "ataba e mo"el. Type Earely u e". In ome programming language all !ariable u e the ame tructure% but mo t language upport -type .. A language may upport e!eral type o$ numeric !ariable % tring an" "ata !ariable . I er/"e$ine" type may inclu"e tructure type an" array . See al o -array.% -integer.% -$loating point.% - tring.% Type )on!er ion - tructure type.. A con!er ion o$ a "ata item $rom one type to another% uch a $rom a numeric !ariable to a tring. 4epen"ing on the language thi may be "one u ing an operator uch a a ca t% #hich may take the $orm -(integer). $or e&ample% or a $unction uch a -ToInt().. )on!er ion may happen

22*

automatically #ithin e&pre ion % uch a #hen an attempt i ma"e Inary @perator to multiply a number by a tring. A unary operator i an operator that operate on a ingle !alue. 3or e&ample% the unary minu % a in -/ 3.% i a eparate operator to the ame ymbol u e" in ubtraction. The Boolean -not. operator i a unary operator% a in the e&pre ion -printUalpha ? 0ot printUnumeric.. See al o -binary Inatten"e" +roce operator. A proce "e igne" to run #ithout input $rom a u er. 3or e&ample% an automate" o!ernight up"ate that e tabli he" a connection to another computer an" per$orme" a "aily "ata up"ate. See al o -batch Inbalance" proce .. A "ata tructure% uch a a tree% that i not e!enly proportione". 3or e&ample% in a balance" binary tree% there are appro&imately log2(n)/1 le!el $or a large n.

222

1o#e!er% i$ the number are alrea"y orte" an" are in erte" u ing the tan"ar" metho"% then the tree "egenerate into a imple In"er$lo# linke" li t% #ith -n. le!el . A calculation that pro"uce a re ult that i too mall to be recor"e" #ith a numeric !ariable o$ that type. 3or e&ample% a $loating point number may repre ent number "o#n to 1 & 100/30,% but i$ a calculation pro"uce" a number maller than thi % but greater than Aero% then an un"er$lo# error #oul" occur. See In"ocumente " Inencrypte" In igne" Iploa" I er Inter$ace al o -o!er$lo#. See -"ocumente". See -encrypte". See - igne". See -import. The interaction bet#een a y tem an" the y tem u er. Thi can be "one #ith menu % comman" button % keyboar" input an" creen 9ariable "i play . A "ata item #ithin a program that 225

i i"enti$ie" by a name. A !ariable may recor" a ingle "ata !alue uch a a number or tring% or may contain multiple entrie 9ector uch a an array. See al o - tring.% -array.. A mathematical ob<ect that con i t o$ a li t o$ number % an" i imilar to a one/"imen ional array or matri&. A large proportion o$ numeric calculation % uch a engineering mo"elling an" graphic tran $ormation % in!ol!e calculation #ith !ector an" matrice . See al o -matri&.% 9er ion )ontrol Sy tem -array.% -central proce ing unit.. A y tem $or managing ource co"e mo"ule . Thi pro!i"e t#o main $acilitie \ the ability to -regre . to pre!iou !er ion o$ a $ile an" acce pre!iou co"e% an" the ability to -lock. $ile a they are being change" o a to pre!ent problem #hen t#o people attempt to change a ingle ource $ile at the ame time. Al o kno#n 227

8eight

a a ource co"e control y tem. A proportion. 3or e&ample% a !alue may be plit into e!eral component % #ith the component repre enting 20O% 2*O an" 1*O o$ the total amount. The e #oul" be recor"e" a #eight o$ 0.2% 0.2* an" 0.1*. +ercentage o$ component um to 100O $or the um total amount% #hile #eight

8hile

to 1. A key#or" commonly u e" in thir"/generation programming language to repeat a loop% #hile a con"ition remain true. 3or e&ample% -8hile not en"/o$/$ile.. See al o -loop.. Blank line % pace an" tab . 8hite pace i u e" to eparate ection o$ co"e in or"er to make the co"e more rea"able. See -narro# inter$ace.. A rectangular ection o$ the creen in a graphical u er inter$ace% containing "ata relate" to one 22:

8hite pace

8i"e Inter$ace 8in"o#

program or ob<ect% uch a a ingle "ocument. 8in"o# may generally be mo!e"% re iAe"% an" 8ire$rame may o!erlap. A !i ual 3/"imen ional image that con i t o$ line connecting the ba ic tructure o$ an ob<ect% uch a the internal $rame o$ a buil"ing% or a ba ic connecte" ur$ace o$ an 8rite Vor ob<ect% #ithout te&ture or colour . To recor" "ata #ithin a "ata $ile on a "i k. The e&clu i!e/or Boolean operator. A logical V@E re ult i true only i$ one !alue i true an" the other i $al e. A bit#i e V@E ha the !alue 1 i$ one !alue i 1 an" the other i 0% other#i e i it 0. See al o -@E..

250

&. #ppendi # 2 Summar+ of operators


Bracket Arithmetic (a) aCb aJb aDb aNb a M@4 b /a aRb aLb a>b a >? b a_b a _? b a?b a >_ b 6ogical Boolean a V@E b 6ogical ;&clu i!e @E a A04 b 0@T a Bit#i e Boolean a V@E b a A04 b Bit#i e ;&clu i!e @E Bit#i e A04 a @E b 6ogical A04 6ogical 0@T Bit#i e Inclu i!e @E a @E b Brackete" ;&pre ion A""ition Subtraction Multiplication 4i!i ion Mo"ulu Inary Minu ;&ponentiation )oncatenation 6e Than 6e Than or ;'ual a a a""e" to b b ubtracte" $rom a a multiplie" by b a "i!i"e" by b a J b D int( a N b ) The negati!e o$ a ab a rai e" to the po#er o$ b b appen"e" to a True i$ a i le than b% other#i e $al e True i$ a i le than or e'ual to b% other#i e $al e True i$ a i greater than b% other#i e $al e True i$ a i greater than or e'ual to b% other#i e $al e True i$ a an" b ha!e the ame !alue% other#i e $al e True i$ a an" b ha!e "i$$erent !alue % other#i e $al e True i$ either a or b i true% other#i e $al e True i$ a i true an" b i $al e% or a i $al e an" b i true% other#i e $al e. True i$ a an" b are both true% other#i e $al e True i$ a i $al e% $al e i$ a i true 1 i either a or b i 1% other#i e 0 1 i$ a i 1 an" b i 0% or a i 0 an" b i 1% other#i e 0. 1 i$ a i 1 an" b i 1% other#i e 0

String Eelational

To =reater Than =reater Than or ;'ual To ;'uality Ine'uality 6ogical Inclu i!e @E

251

A""re e

0@T a re$ a "ere$ a aPbQ a(b) a.b a?b

Bit#i e 0@T Ee$erence 4ere$erece

1 i$ a i 0% 0 i$ a i 1 The a""re o$ the !ariable a The "ata !alue re$erre" to by pointer a The element b #ithin the array a A call o$ ubroutine a% pa ing parameter b Item b #ithin tructure a

Array Ee$erence Subroutine )all ;lement Ee$erence A ignment

A ignment

Set the !alue o$ !ariable a to e'ual the !alue o$ e&pre ion b

252

Anda mungkin juga menyukai