Object vs Class composition By Marine Ruhamanya. Disciplined Inheritance  Problems with implementation inheritance: Encapsulation Fragile Base Class.

Slides:



Advertisements
Similar presentations
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Advertisements

Object-Oriented Analysis and Design
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Object-Oriented PHP (1)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
1 Introduction to CS Agenda Syllabus Schedule Lecture: the management of complexity.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Object-oriented Programming Concepts
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 24: Dynamic Binding COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
Component Software Beyond Object-Oriented Programming Clements Szyperski Chapter 7 – Object versus class composition or how to avoid inheritance Alexandre.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Ruby: Multiple Inheritance, Interfaces, Mixins 1.
Comparison of OO Programming Languages © Jason Voegele, 2003.
Programming Languages and Paradigms Object-Oriented Programming.
BCS 2143 Introduction to Object Oriented and Software Development.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
1 CS 456 Software Engineering. 2 Contents 3 Chapter 1: Introduction.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
OO as a language for acm l OO phrase l Mental model of key concepts.
Object Oriented Software Development
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
OOP Review CS 124.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
Testing in OO Environment The reasons for testing is not any different for any of the design and implementation methodologies, including OO methodology.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
CSCE 240 – Intro to Software Engineering Lecture 3.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Object Oriented Programming in Java Habib Rostami Lecture 2.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Multiple Inheritance, Interfaces, Mixins 1.
Cmpe 589 Spring 2006.
Object-Oriented Modeling
Chapter 1: Introduction to Systems Analysis and Design
Chapter 11 Object-Oriented Design
Behavioral Design Patterns
Introduction to Unified Modeling Language (UML)
Demeter Aspects Who We Are Aspectual Collaborations
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
MSIS 670 Object-Oriented Software Engineering
Objects and Aspects: What we’ve seen so far
Chapter 1: Introduction to Systems Analysis and Design
Workshop for Programming And Systems Management Teachers
Object-Oriented PHP (1)
Object-Oriented Programming
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Chapter 1: Introduction to Systems Analysis and Design
Presentation transcript:

Object vs Class composition By Marine Ruhamanya

Disciplined Inheritance  Problems with implementation inheritance: Encapsulation Fragile Base Class problem  However it is a powerful mechanism.  Several attempts to discipline the mechanism

The specialization interface  Special interface between a class and its subclasses  C++, Java, C# support the notion of protected features of a class

Typing the specialization interface  Overriding methods needs to be done carefully  Proposal (Lamping,1993): Type system to improve control  Declare method dependencies Acyclic graph => methods arranged in layers Cycles => all methods form a group  Subclass has to override methods group by group

Behavioral specification  Semantic issues of implementation inheritance: mostly related with re-entrance caused by self-recursion  Proposal (Stata and Guttag, 1995): View a class as a combined definitions of interacting parts objects Division of labor or method groups No direct access between divisions

Behavioral specification(2) Use of specification techniques and the notion of behavioral subtyping  Stata-Guttag vs Lampig: Stata-Guttag: split state and behavior into groups. Methods groups encapsulate part of the state Lampig: any dependency of methods on state  Tight semantic control leads to object composition.

Reuse contracts  Less restrictive forms of implementation  Proposal (Stayeart et al., 1996): Annotated interface: reuse contracts  Determine how reuse happens between classes and its subclasses Specify structural aspects of a base class Specify only the part of a call stucture subclasses can rely on.  New: set of modification operators

Representation Invariants & Methods Refinements  Proposal (Stephen, 1999): Associate invariants to a class specification that refers to protected variables  Proposal (Stata, 1999): Separate the notion of subtyping and subclassing to allow partial overriding Supercalls are allowed if overriding method is a proper refinement of the base class method.

Disciplined inheritance to avoid the FBC problem  Proposal (Mikhajlov-Sekerinski, 1998): Set of rules: Construction of subclasses based on superclass specification Eliminate the introduction of new cyclic method dependencies Superclasses instance variables are private and subclasses don’t introduce new ones.  Very restrictive, but interesting formal proof

Creating subclasses without seeing the superclass code  Proposal (Leavens et al., 2000):  Java Modeling Language defined  Focus on the inverse of FBC problem  Provide 3 parts to a class specification: 1 st and 2 nd : public and protected parts 3 rd : subclassing contract provide information accessed variables and methods call dependencies  Link to the FBC not further explored.

From Class to Object Composition  Object composition - simpler form of composition:  Object send message to other object asking for support; Outer and inner objects, forwading  Differences to implementation inheritance; Outer object does not reimplement inner object functionality ‘Implicit self-recursion’ or ‘possesion of common self’

From Class to Object Composition  ‘Implicit self-recursion’ or ‘possession of common self’: There is no ‘common self’ in object composition In implementation inheritance: upcalls due to method invocation Example ( page 135).  Advantage: dynamic

Forwarding vs Delegation  Message passing  Delegation: message-send is classified as either regular (forwarding) or self- recursive (delegation)  Example (page 136 &137)  Message resending  Complexity exploses under delegation  Interaction diagram similar to that of implementation inheritance

Delegation & Inheritance  Delegation – powerful programming tool  System based on OC and delegation are highly dynamic.  Languages are called prototype-based languages; e.g.: Self. Not yet mainstream  Delegation is behind in discipline and modularity while inheritance is behind in system dynamics and late compsition

End