80 likes | 198 Views
Software Engineering Lecture 4. Vladimir Safonov , Professor, head of laboratory St. Petersburg University Email: v_o_safonov@mail.ru WWW: http://user.rol.ru/~vsafonov. The role of the programming paradigms under consideration.
E N D
SoftwareEngineeringLecture 4 Vladimir Safonov, Professor, head of laboratory St. Petersburg University Email: v_o_safonov@mail.ru WWW: http://user.rol.ru/~vsafonov
The role of the programming paradigms under consideration • Structured programming – systematic design and development of (mainly) the control flow parts (statements) • Stepwise refinement – convenient top-down technique of rapid application prototyping • Modular programming – systematicprogram decomposition into relatively independent parts (modules) • Also of great importance aretechniques for design and development of data types and structures (C) Vladimir O. Safonov, 2004
Abstract Data Types (ADT) • Founders (1970s): - Sir Tony Hoare: Oxford University , MSR; - Prof. Barbara Liskov: Massachusetts Institute of Technology - Prof. David Parnas (U.S. and Canadian universities) • Basic principles - Type = concrete representation+ set of abstract operations - Direct access to concrete representation is not allowed - Handling values (or objects) of the typeT is possible only via its abstract operationsP1, … Pn, so the type T is encapsulated • ADT can be regarded as a kind of modularity (name and set of operations – interface; concrete representation and bodies of operations – implementations • Before ADTsimilar approach was applied topredefined (primitive) types: VAR i: INTEGER; BEGIN … i := i+1; … END (C) Vladimir O. Safonov, 2004
ADT specifics • “Types are not sets” (F. Morris) • Encapsulation • Formal specification of ADT semantics necessary • R. Floyd’s – C.A.R. Hoare’s method: P { S } Q • Denotational semanticsof ADT (D. Scott, J. Donahue): program is a transformer of predicates the kind:P(X1, … Xn), whereXi – set of variables • Algebraic specification of ADT (theADJ group, lead – prof. J.A. Goguen, the author of OBJ specification language): type – multi-sorted algebra; S1, … Sk – sorts (carrier); P1, …, Pm – operations (signature); semantics – set of equates of the kind:T1 = T2 where T1 and T2 - terms (C) Vladimir O. Safonov, 2004
ADT advantages • Modularity • Increasing reliability • Formal specification and verification of ADT • ADT libraries and reusability (C) Vladimir O. Safonov, 2004
ADT issues and how to solve them • “ADT are non-efficient” (each abstract operation is a routine!) -> using macros and inline routines; program optimization (the task of the compiler rather than user) • “ADT are too complicated” (it seems simpler to code “from scratch” and to write explicitly something like: P^.X [index]^.Y := something ) -> such “coding technique” leads to buggy and non-readable programs. ADT is a comfortable technique of abstraction from details: SetMyProp(P, something); (C) Vladimir O. Safonov, 2004
ADT languages • FORTRAN & PASCAL - predefined types are regarded as ADT with infix:X+Y or functional:SIN(X) style of operations • CLU (B. Liskov) – the first ADT language; played outstanding partin all subsequent development ofprogramming languages – M.I.T., 1974 • ALPHARD (M. Shaw, Carnegie-Mellon Univ.) – the“competitive project” toCLU; based on similar ideas, butHoare-style specification and verification added to the language • Ada (package, task); Modula-3 (interface); Java, C# … - contain elements of ADT concept (C) Vladimir O. Safonov, 2004
References and home task to lecture 4 • Please read the following papers and get acquainted to their approached to ADT: • Liskov B, Guttag J. Using abstractions and specifications in program development. – Addison-Wesley, 1986 • Hoare, C.A.R. Proof of correctness of data representation (article, 1972) (C) Vladimir O. Safonov, 2004