Object-Oriented Software Engineering Anton Eliëns Vrije Universiteit, Amsterdam 27 april 1999 http://www.cs.vu.nl/~eliens/cmg/html/oo http://www.cs.vu.nl/~eliens/online/courses/cmg/oo Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Topics: • • • • • • Basic OO technology Application Framework(s) Universal Modeling Language Design Patterns Project Management Current developments and trends Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Introduction If OO is the Answer, What is the Question? Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Keywords and phrases • the OO lifecycle -- modelling • encapsulation, inheritance, delegation, polymorphism • specification and implementation inheritance • design by contract • interfaces, components and frameworks • idioms, patterns, software architecture Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Basic OO Technolology Technology determines the effectiveness of the approach Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Concepts • • • • Encapsulation Data hiding Inheritance Polymorphism Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Encapsulation • • • • An object contains data and methods It provides a boundary: to the world outside to its ‘children’ Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Information hiding • • • • Reduces complexity Allows you to defer implementations Remember: Ignorance is bliss Helps in decoupling components Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Inheritance • • • • A mechanism for code-sharing Supports incremental development Organize by classification Allows for abstract interfaces Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Polymorphism • • • • • An object may have multiple types An abstract type: when it is used A concrete type: when it is created An object’s type is determined by its behavior An object’s type is determined by the messages it allows Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Design by Contract • formal basis -- pre and post conditions • refinement -- by inheritance or polymorphism • runtime checks -- division of responsibility see Ch. 3, Contracts Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam The San Francisco Framework How useful is an OO framework? Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam •Example - San Francisco Framework Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam A framework is ... • • • • a collection of components a generic solution for a class of problems a frame of mind for solving problems a set of architectural constraints Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam The San Francisco Framework • • • • • • is meant to develop business applications is based on Java technology may solve 70% of your problem leaves 30% (minimum) to solve for you may set a standard or may fail to do so ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam San Francisco - motivation • The project was started when several software vendors asked IBM to help modernizing their application products • However, there were several barriers preventing them from being able to update their applications Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Barriers to modernizing • (1) The problem of how to retrain their development staff to effectively use OO technology. • (2) The risk involved in moving to a new technology. • (3) moving -> the cost of the change • The software developers realized they needed some basic infrastructure. • Many companies could not develop this infrastructure themselves. Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam San Francisco - the press • The San Francisco project helps to solve these problems by offering developers Business Process Components, • designed as frameworks that provides an object oriented infrastructure, • a consistent application programming model, and • some default business logic • The frameworks make it easier to move to OO technology because developers use well-tested services instead of building their own. Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam San Francisco Framework - layers • Core Business Process Layer - the highest • Common Business Objects Layer - middle • Foundation Layer - lowest Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Core Business Processes • The objective for this layer is to create a sound architecture and highly extensible OO implementation for the basic structure and behavior which any application provider delivering a solution in the application doamin would require: • Accounts Receivable/Payable Ledger • General Ledger Framework • Sales Order Management Framework • Purchase Order Management Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Common Business Objects • • • • • • • Business Objects common to multiple domains Common Application level Services CBO: Business Partner Address Number - decimal structure Currency - how many euros in a dollar? Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Foundation Layer • Foundation Object Model Classes • Utilities • in other words: it provides the infrastructure • comment: reinventing the wheel is not a big problem, because the wheel is a terrific invention Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Foundation Object Model Classes • • • • • Command Entity Dependent Collection/Iterator Factory • you need to study Design Patterns to appreciate these ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Using the San Francisco Framework • … The San Francisco Frameworks are designed to make many types of extensions easy for application dvelopers: • overriding the default business logic in supplied methods • adding additional attributes to existing classes • adding additional methods to existing classes • from the report: Complete documentation will be provided … Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Example • • • • • • • Two classes: Receipt and Purchase order Line default attributes, methods default business logic: inspect Quality on receipt Extension: enhance this logic subclass Receipt override inspection method change logic to include checks against supplier tables, and hazardous or high value products Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam San Francisco - issues • Standards: OMG/CORBA Business Issues • Technology Integration: • Compound Documents: Lotus Notes, JavaBeans, Active X • Business process Modelling and Control: workflow engines may be used as glue … • Internet/Intranet and Java: applications may be designed …. • Conclusions: … a bit premature ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Universal Modeling Language • • • • • • … why you need models? Models are necessary to communicate, to stabilize abstractions as a reference for the implementation and maintenance and you need an agreement on the notation and formalisms in which you express your models Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Unified Modeling Language • • • • • class diagrams -- conceptual structure use cases -- functional requirements interaction diagrams -- operational aspects package and deployment -- implementation state and activity -- dynamic behavior • See http://www.rational.com/uml and UML Distilled, [Fowler97]. Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam UML - Quick Reference and Overview adapted from the Rational Rose Quick Reference at http://www.rational.com/uml/qr and Principles of O-O Software Development Appendix UML Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Class diagrams • Describe properties of classes • and their (inter) relations Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Interaction diagram • To gain an operational intuition • to check calling chains Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Use cases • Define the boundary between the system and its uses • Might be a good subject for a paper ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Collaboration diagrams • To further analyze the relations between classes • augments: class diagram and interaction diagram Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Visibility properties • More implementation oriented • But remember: ignorance is bliss ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Component and Deployment diagram • Primarily for the system architect Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Associations, roles, aggregations • You may augment the model to any extent • Personally, I believe in constraints • See for example: Fowler - Analysis Patterns Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Dynamic object behavior - state transitions • State transition diagrams are rarely used • except in applications that require scheduling: • workflow, simulation, concurrency Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Examples - interactive drawing tool - the reactor pattern (events) - business process modeling - the observer pattern Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Interactive drawing tool Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Reactor (event-handling) pattern Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Reactor - Interaction diagram (events) Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Business process modeling Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam (simulation) event state transition diagram Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Observer Pattern Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam A Catalogue of Design patterns • • • • a common design vocabulary documentation and learning aid an adjunct to existing methods a target for redesign see the GOF Design Patterns and the Patterns Homepage Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam The Pattern Schema: structure • Name - handle – increases design vocabulary • Problem - when to apply – explains the problem and the conflict • Solution - general arrangement – design, responsibilities, collaborations • Consequences - trade-off's – to understand the costs and benefit Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Causes for Redesign (1) 1. creating an object by specifying a class explicitly -- Abstract Factory, Factory Method, Prototype 2. dependence on specific operations -- Chain of Responsibility, Command 3. dependence on hardware & software platforms -- Abstract Factory, Bridge 4. dependence on object implementation or representation -- Abstract Factory, Bridge, Memento, Proxy Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Causes for Redesign (2) 5. algorithm dependence -- Builder, Iterator, Strategy, Template Method, Visitor 6. extending functionality by subclassing -- Bridge, Chain, Composite, Decorator, Observer 7. tight coupling -- Abstract Factory, Bridge, Chain of Responsibilities, Command, Facade, Mediator, Observer 8. inability to alter classes conveniently -- Adaptor, Decorator, Visitor Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Kinds of Patterns • creational patterns -- Factory, Singleton, ... • structural patterns -- Adaptor, Composite, Bridge, ... • behavioral patterns -- Mediator, Observer, Command, … see UML Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Managing O-O Projects Did YOU ever manage a project? Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Critical Success Factors • • • • use incremental scheduling and staging find and fix failing ideas develop a habit of delivering get: sponsor, project manager, technical leader Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Key Failure Indicators • absence of incremental development • use of C++ in commercial IS see Surviving Object-Oriented Projects: A Managers Guide Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam OO - Success and Failure • • • • OO = technology + mind-set it might be new technology to your organisation developers love it! requires and enables communication between groups • adopting OO may succeed or fail! Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Possible benefits - responsiveness • • • • • • • responsiveness - variations on a theme responsiveness to change! time-to-market communication - developers, users, executives maintenance, reuse, productivity GUI development morale -- cutting-edge technology Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Drawbacks • • • • • • • • Are YOU underestimating? productivity takes time hazards of C++ (and Java, ...) reuse is difficult establishing a software process business-modelling or software design? CASE helps? You will pay for: training, experience, tools, consultants, ... Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam The hazards of C++? • C++ won the language war over Eiffel, Objective-C, SOM, C@+, and Java? • Java -- relative simplicity and portability Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Managing (the complexity of) C++ • misconception: C++ is like C • consider using another language • Why does C++ exist? - engineering and systems programming • create a subset of the language • design and coding standards • use people with knowledge! Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Risk-reduction Strategies • • • • look carefully all around the project detect the risks! list the risks in order work on the risks in order of danger see Risk Avoidance Patterns Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Technology and Trends UML Risks Java Frameworks Contracts CORBA Patterns DOT Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Frameworks • Frameworks = Components + Patterns Ralph Johnson, CACM Nov. 1997 The benefits of frameworks stem from the inversion of control. A Framework defines an Architecture? Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Software Architecture Software Architecture = a set of rules, guidelines, interfaces, and conventions used to define how components and applications communicate and interoperate with each other ... see patterns Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam CORBA • • • • • the issue is standardisation by means of interfaces looking for consensus this differs from a de-facto standard imposed by market share ... see Ch 11: Application integration -- standards see frameworks Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Java - perspectives • • • • • • • Internet applications Software Engineering Language Design System Development Computer Science IT (in) Business Global Village Informatie, januari 99: Java - een kwestie van vraag en aanbod Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Dimensions of Risks • • • • • Knowledge Teaming Productivity Ownership Distractions Don't discuss risks, unless you know how to do Project Management Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Conclusions • OO offers – – – – a valid metaphor for SE powerful technology maturing design methods and notations a rich set of patterns Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Yet beware of • • • • the learning curve simplified hype cutting edge technology (over) ambitious projects Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Assignments: • Write a paper about one of the following topics. The paper may discuss concepts or focus on a case study. – The Unified Modelling Language -- UML – Frameworks -- for example San Francisco • Write a comparative study of object-oriented analysis and design methods, focussing on aspects of project management. • Describe a case study concerning the deployment of design patterns. Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam Course material • Chapter 1 • Additional material – Ch 3: Design by Contract – Ch 11: Methods and Tools – Object Tutorials • Resources – http://www.rational.com -- Rational Rose, UML – http://www.ibm.com/java/sanfrancisco -- IBM Java San Francisco Framework • Papers and Reports – http://www.rational.com/uml/html/summary -- UML Summary – http://www.ibm.com/Java/Sanfrancisco/prd_summary.html -- San Francisco Technical Summary Postacademische Cursus Informatie Technologie vrije Universiteit amsterdam