PrinciplesMacLennan’s PrinciplesMacLennan’s Principles (2)MacLennan’s Principles (3)MacLennan’s Principles (4)MacLennan’s Principles (5)MacLennan’s Principles (6)MacLennan’s Principles (7)MacLennan’s Principles (8)More Principles (Ghezzi & Jazayeri)More PrinciplesMore Principles (Yemini & Berry)More Principles (Yemini & Berry) (2)What’s this violate?Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33990128; P.F. Reynolds CS655 1Principles990128; P.F. Reynolds CS655 2MacLennan’s Principles•Abstraction–Avoid requiring something to be stated more than once; factor out the recurring pattern.–Subprograms, user defined types, inheritance•Automation–Automate mechanical, tedious, or error-prone activities.–Garbage collection; looping structures990128; P.F. Reynolds CS655 3MacLennan’s Principles (2)•Defense in Depth–Have a series of defenses so that if an error isn't caught by one, it will probably be caught by another.–Array bound being part of type; definite loops.•Information Hiding–The language should permit modules to be designed so that (1) the user has all of the information needed to use the module correctly, and nothing more; and (2) the implementor has all of the information needed to implement the module correctly, and nothing more.–Modules, packages, objects990128; P.F. Reynolds CS655 4MacLennan’s Principles (3)•Labeling–Avoid arbitrary sequences more than a few items long. Do not require the user to know the absolute position of an item in a list. Instead, associate a meaningful label with each item and allow the items to occur in any order.–Case statement, position-independent parameters.•Localized Cost–Users should only pay for what they use; avoid distributed costs.–Violations: Algol60 loops, dynamic type binding.990128; P.F. Reynolds CS655 5MacLennan’s Principles (4)•Manifest Interface–All interfaces should be apparent (manifest) in the syntax.–Module specifications; function prototypes•Orthogonality–Independent functions should be controlled by independent mechanisms.–Algol68 types; Ada parameter passing990128; P.F. Reynolds CS655 6MacLennan’s Principles (5)•Portability–Avoid features or facilities that are dependent on a particular machine or a small class of machines.–Ada prohibition of aliasing; C/Algol60 I/O•Preservation of Information–The language should allow the representation of information that the user might know and that the compiler might need.–Definite looping structures990128; P.F. Reynolds CS655 7MacLennan’s Principles (6)•Regularity–Regular rules, without exception, are easier to learn, use describe and implement.–Violations: strings in most langs; Pascal functions.•Security–No program that violates the definition of the language, or its own intended structure, should escape detection.–Strong typing in Algol60, Pascal, Ada, C++990128; P.F. Reynolds CS655 8MacLennan’s Principles (7)•Simplicity–A language should be as simple as possible. There should be a minimum number of concepts, with simple rules for their combination.–Pascal; Ada name equivalence•Structure –The static structure of the program should correspond in a simple way to the dynamic structure of the corresponding computations.–Single entry / single exit; violation: Pascal’s upside-down procedures first form.990128; P.F. Reynolds CS655 9MacLennan’s Principles (8)•Syntactic Consistency–Similar things should look similar; different things different.–Violations: ,/; in Algol68; blocks vs compound statements; Ada private / limited private•Zero-One-Infinity–The only reasonable numbers are zero, one, and infinity.–Array dimensions; identifier sizes; function nesting990128; P.F. Reynolds CS655 10More Principles (Ghezzi & Jazayeri)•Efficiency–translation & execution•Readability•Writability•Reliability–rigorous semantics; clear distinction between static and dynamic checks; modularity990128; P.F. Reynolds CS655 11More Principles•Predictability•Learnability•Maintainability•Verifiability•??? Must it end in “ility”?990128; P.F. Reynolds CS655 12More Principles (Yemini & Berry)•Wide horizon:–Whenever the semantics of a construct, C, in a language for concurrent programming implies the delay of a process (task) executing in C, C should be able to have other alternatives, and all such constructs should be able to serve as alternatives to each other.–Not satisfied by semaphores, monitor calls or Ada select statement.990128; P.F. Reynolds CS655 13More Principles (Yemini & Berry) (2)•Closure under binding:–For every concurrent program, there exists a sequential, possibly non-deterministic, program with an equivalent semantics.–No unitask program in Ada can simulate:declare task t1 is s1.e1() end t1; task t2 is s2.e2() end t2; begin end; -- s1 and s2 are called in arbitrary order.990128; P.F. Reynolds CS655 14What’s this violate? COMMON a, b, lab . . .3 WRITE(6,5)5 FORMAT( . . .) ASSIGN 3 TO lab CALL sub2 END SUBROUTINE sub2 COMMON c, d, lab . . . GOTO lab3 i = 1/0 RETURN END990128; P.F. Reynolds CS655 15What’s this violate?10 i=0 call doThing(... i ...) i=i+1 IF i <= n THEN GOTO 10990128; P.F. Reynolds CS655 16What’s this violate?i = 10;s = 10; . . .s = "this is a string"; . . .IF i != 10 THEN someFunc(i); . . .s = 3.14159; . . .IF s = pi THEN . . .990128; P.F. Reynolds CS655 17What’s this violate?val = -7a= val >> 2val = 15a = val << 18990128; P.F. Reynolds CS655 18What’s this violate?GOTO i-- branch to i-th statement <statement 1> <statement 2> . . . <statement i> . . . <statement n>990128; P.F. Reynolds CS655 19What’s this violate?990128; P.F. Reynolds CS655 20What’s this violate?DIMENSION a(20)CALL subr(a) . . .ENDSUBROUTINE subr (n)DIMENSION n(25); . . .IF n(22) = ... . . .END990128; P.F. Reynolds CS655 21What’s this violate?i:= 1;WHILE i < n DO BEGIN WRITE ( exp(i)); i:= i+1 END;i:= 1;REPEAT WRITE ( exp(i)); i:= i+1UNTIL i = nFOR i:= 1 TO n-1 DO WRITE ( exp(i))990128; P.F. Reynolds CS655 22What’s this violate?FOR (; curr != NULL ; curr = temp){ temp = curr->next; FREE ((char *) curr);}990128; P.F. Reynolds CS655 23What’s this violate?IF ( I = 0 ) …IF ( I == 0 ) ...990128; P.F. Reynolds CS655 24What’s this
View Full Document