Transcript poosd-B.ppt
Principles of Object-Oriented Software Development The language Eiffel The language Eiffel Introduction Terminology Expressions Control Objects Inheritance Techniques Summary Eiffel -- a language with assertions bottom-up development -- class design contracts -- specify client/server relationships Design principles -- correctness static typing -- type secure multiple inheritance -- polymorphism dynamic binding -- refinement generic classes -- abstraction The language Eiffel keywords • • • • • • • class -- a model for a set of objects feature -- attribute, function, procedure export -- interface declaration inherit -- class inclusion and subtyping (!) redefine, rename -- to change inherited features deferred -- to postpone the implementation require, ensure, invariant -- assertions Type expressions conformance • • • • basic types -- Boolean, Integer formal parameter types -- Array[T], List[T] class types -- user-defined anchored types -- like current Value expressions arithmetic, comparison, method evaluation -- o.m(...) Assignment var := expression Control method refinement • branching -- if ... then ... elsif ... else ... End • iterations -- from ... until ... loop ... end Eiffel -- control class counter export inc val feature count : Integer create is do count := 0 end inc( n : Integer ) is require n > 0 do count := count + n ensure count = old count + n end val : Integer is do Result := count end invariant count >= 0 end -- class counter Eiffel -- objects Multiple inheritance class Fixed_List[T] export ... inherit List[T] Array[T] feature ... end Eiffel -- inheritance Rename and/or redefine class C export ... inherit A rename m as m1 redefine p B rename m as m2 redefine q feature ... end Eiffel -- techniques The language Eiffel • • • • • design principles -- correctness terminology -- keywords syntax -- type conformance control objects -- counter example inheritance -- renaming, redefining