Object-Oriented Software Construction Bertrand Meyer Lecture 6: Genericity

 www.phwiki.com

 

The Above Picture is Related Image of Another Journal

 

Object-Oriented Software Construction Bertrand Meyer Lecture 6: Genericity

Averett College, US has reference to this Academic Journal, Object-Oriented Software Construction Bertrand Meyer Lecture 6: Genericity Genericity Parameterized classes in consideration of static typing Examples: stacks, arrays Constrained genericity (preview)

 Dong, Aichun Averett College www.phwiki.com

 

Related University That Contributed for this Journal are Acknowledged in the above Image

 

Extending the basic notion of class LIST_OF_BOOKS SET_OF_BOOKS LINKED_LIST_OF_BOOKS LIST_OF_PEOPLE LIST_OF_ JOURNALS Abstraction Specialization Type parameterization Type parameterization Genericity: Ensuring type safety How can we define consistent ?container? data structures, e.g. stack of accounts, stack of points? Dubious use of a container data structure: a: ACCOUNT p, q: POINT point_stack: STACK . account_stack: STACK . point_stack.put (p) account_stack.put (a) q := point_stack.item q.move (3.4, 1.2) Possible approaches Ignore the problem until run-time. Possible ?feature not available? errors. This is the dynamic typing approach of Smalltalk in addition to Java. Use a pseudo-universal type, such as ?pointer so that void? or ?pointer so that character? in C, so that represent G in the class, in addition to cast everything so that that type. Duplicate code, manually or alongside the help of macro processor. Parameterize the class, giving a name G so that the type of container elements; the features of the class may refer so that type G. This is the Eiffel approach. (See also C++ templates.)

A generic class class STACK [G] feature put (x: G) is . item: G is . end To use the class: obtain a generic derivation, e.g. account_stack: STACK [ACCOUNT] Formal generic parameter Actual generic parameter Conformance rule B [U] conforms so that A [T] if in addition to only if B is a descendant of A in addition to U conforms so that T. Using generic derivations account_stack: STACK [ACCOUNT] point_stack: STACK [POINT] a: ACCOUNT p, q, r: POINT . point_stack.put (p) point_stack.put (q) r := point_stack.item r. move (3.0, ?5.0) account_stack.put (a) .

Multipoint Control Units (MCUs) Multipoint Control Units: Hardware vs Software MCU Control Functions Important Administrative Topics MCUs available in the market RADVISION MCU-323 Tandberg MCU Polycom MGC RADVISION via-IP Commons MCU Test Facility

Genericity in addition to static typing Compiler will reject point_stack.put (a) account_stack.put (p) To define more flexible data structures (e.g. stack of figures): use inheritance, polymorphism in addition to dynamic binding. Typing is in O-O context An object-oriented language is statically typed if in addition to only if it is possible so that write a static checker which, if it accepts a system, guarantees that at run time, in consideration of any execution of a feature call x.f, the object attached so that x (if any) will have at least one feature corresponding so that f. Constrained genericity class VECTOR [G] feature infix “+” (other: VECTOR [G]): VECTOR [G] is Sum of current vector in addition to other require lower = other.lower upper = other.upper local a, b, c: G do . See next . end . Other features . end

Constrained genericity (cont?d) The body of infix “+”: create Result.make (lower, upper) from i := lower until i > upper loop a := item (i) b := other.item (i) c := a + b Requires a ?+? operation on G! Result.put (c, i) i := i + 1 end The solution Declare class VECTOR as class VECTOR [G ?> NUMERIC] feature . The rest as before . end Class NUMERIC (from the Kernel Library) provides features infix “+”, infix “*” in addition to so on. Better yet: make VECTOR itself a descendant of NUMERIC, effecting the corresponding features: Improving the solution Make VECTOR itself a descendant of NUMERIC, effecting the corresponding features: class VECTOR [G ?> NUMERIC] inherit NUMERIC feature . The rest as before, including infix “+”. end Then it is possible so that define e.g. v: VECTOR [VECTOR [VECTOR [INTEGER]]]

A generic library class: Arrays Using arrays in a client a: ARRAY [REAL] . create a.make (1, 300) a.put (3.5, 25) (in Pascal: a[25] := 3.5) x := a.item (i) (in Pascal: x := a[i]) Alternatively: x := a @ i Using the function infix “@” Also: ARRAY2 [G] etc. The ARRAY class class ARRAY [G] create make feature lower, upper: INTEGER count: INTEGER make (min: INTEGER, max: INTEGER) is Allocate array alongside bounds min in addition to max. do . end The ARRAY class (cont?d) item, infix “@” (i: INTEGER): G is Entry of index i require lower <= i i <= upper do . end put (v: G; i: INTEGER) is Assign the value of v so that the entry of index i. require lower <= i i <= upper do . end invariant count = upper ? lower + 1 end Obsolete features in addition to classes How so that reconcile progress alongside the protection of the installed base? Obsolete features in addition to classes support smooth evolution. In class ARRAY: enter (i: V; v: T) is obsolete "Use `put (value, index)?" do put (v, i) end Obsolete classes class ARRAY_LIST [G] obsolete "[ Use MULTI_ARRAY_LIST instead (same semantics, but new name ensures more consistent terminology). Caution: do not confuse alongside ARRAYED_LIST (lists implemented by one array each). ]" inherit MULTI_ARRAY_LIST [G] end End of lecture 7

Dong, Aichun General Manager

Dong, Aichun is from United States and they belong to General Manager and work for KNRJ-FM in the AZ state United States got related to this Particular Article.

Journal Ratings by Averett College

This Particular Journal got reviewed and rated by and short form of this particular Institution is US and gave this Journal an Excellent Rating.