The Object-Oriented Thought Process Chapter 08

Slides:



Advertisements
Similar presentations
Component Oriented Programming 1 Chapter 2 Theory of Components.
Advertisements

OASIS Reference Model for Service Oriented Architecture 1.0
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS6th Edition.
THE OBJECT-ORIENTED DESIGN WORKFLOW Interfaces & Subsystems.
1 Object-Oriented Design. 2 Objectives F To become familiar with the process of program development. F To the relationship types: association, aggregation,
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
An Object-Oriented Approach to Programming Logic and Design
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
Advanced Object Oriented Programming – Abstract classes and Interfaces Chapter 27.
Hyper/J and Concern Manipulation Environment. The need for AOSD tools and development environment AOSD requires a variety of tools Life cycle – support.
Part VII: Design Continuous
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
CS2 Module 26 Category: OO Concepts Topic: Interfaces Objectives –Interfaces.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Object Oriented Programming Some Interesting Genes.
The Object-Oriented Thought Process Chapter 03
CompSci 280 S Introduction to Software Development
Object-Oriented Design
Unit II-Chapter No. : 5- design Patterns
Object-Oriented Programming Concepts
Sachin Malhotra Saurabh Choudhary
Lecture 12 Inheritance.
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Object-Oriented Analysis and Design
MPCS – Advanced java Programming
Object-Oriented Modeling with UML
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
The Object-Oriented Thought Process Chapter 1
Chapter 11 Object-Oriented Design
Chapter 10 Object-Oriented Modeling
Mastering UML with Rational Rose 2002
Copyright © by Curt Hill
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Chapter 13 Abstract Classes and Interfaces
Chapter 19: Interfaces and Components
Object Oriented Practices
Advanced Programming Behnam Hatami Fall 2017.
File Systems and Databases
The Object-Oriented Thought Process Chapter 05
The Object-Oriented Thought Process Chapter 07
Chapter 20 Object-Oriented Analysis and Design
Object Oriented Practices
The Object-Oriented Thought Process Chapter 02
Reference This talk is loosely based on the following
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
Chapter 19: Interfaces and Components
Chapter 19: Interfaces and Components
Introduction Object-Oriented Programming
Software Analysis.
Chapter 5.
CS 112 Programming 2 Lecture 02 Abstract Classes & Interfaces (2)
Object-Oriented PHP (1)
Interfaces and Components
Chapter 8 - Design Strategies
C++ Object Oriented 1.
Chapter 19: Interfaces and Components
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
The OOTP is intended to get you thinking about how OO concepts are used in designing object-oriented systems. Note: not talking about OO technologies that.
Presentation transcript:

The Object-Oriented Thought Process Chapter 08 Frameworks and Reuse: Designing with Interfaces and Abstract Classes

What Is a Framework? Hand in hand with the concept of code reuse is the concept of standardization, which is sometimes called plug and play. The idea of a framework revolves around these plug-and-play and reuse principles. A common framework makes it easier to learn various applications within the framework. It also makes a developer’s life easier by promoting maximum code reuse

Code Reuse Revisited Inheritance and composition allow for reuse for basically one class. Frameworks focus on reusing whole or partial systems.

What Is a Contract? In the context of this chapter, we will consider a contract to be any mechanism that requires a developer to comply with the specifications of an API. Often, an API is referred to as a framework. The online dictionary, Dictionary.com (http://www.dictionary.com), defines a contract as “an agreement between two or more parties for the doing or not doing of something specified” and “an agreement enforceable by law”.

The Term Contract The term contract is widely used in many aspects of business, including software development. Do not confuse the concept presented here with other possible software design concepts called contracts. Enforcement is vital because it is always possible (perhaps even easy) for a developer to break a contract.

Abstract Classes One way a contract is implemented is via an abstract class. An abstract class is a class that contains one or more methods that do not have any implementation provided. An abstract cannot be instantiated. Concrete classes can be instantiated.

Framework Caution Be aware that in the cases of Shape, Circle, and Rectangle, we are dealing with a strict inheritance relationship. As opposed to an interface. This is an important point because contracts are not used in cases of composition, or has-a relationships.

Protocols Some languages, such as C++, use only abstract classes to implement contracts. Java and .NET have another mechanism that implements a contract called an interface. In other cases, such as Objective-C, abstract classes are not provided by the language. Thus, to implement a contract in Objective-C, you need to use a protocol, which is Objective-C’s version of an interface.

Interfaces An interface is similar to an abstract class but it does not provide any implementation. The obvious question is this: If an abstract class can provide the same functionality as an interface, why do Java and .NET bother to provide this construct called an interface? And why does Objective-C provide the protocol?

Interfaces When using an interface, you do not have to concern yourself with a formal inheritance structure. You can theoretically add an interface to any class if the design makes sense. An abstract class requires you to inherit from that abstract class and, by extension, all of its potential parents.

Interface Terminology Be aware that you can use the term interface in several ways, so be sure to use each in the proper context. First, the graphical user interface (GUI) is widely used when referring to the visual interface that a user interacts with—often on a monitor. Second, the interface to a class is basically the signatures of its methods. Third, in Objective-C you break the code up into physically separate modules called the interface and implementation. Fourth, a Java-style interface and an Objective-C protocol are basically a contract between a parent class and a child class.

Tying It All Together If both abstract classes and interfaces provide abstract methods, what is the real difference between the two? Abstract classes require a strict inheritance relationship and must be related and can provide implementation. Interfaces can be used for classes that are not related and do not provide implementation.

Using Interfaces An interface specifies certain behavior, but not the implementation. By implementing an interface, you are saying that you will provide concrete behavior by implementing methods abstract methods. How you implement these methods is up to you. All you have to do is to provide the concrete methods.

System Plug-in Points Basically, contracts are “plug-in points” into your code. Anyplace where you want to make parts of a system abstract, you can use a contract. Instead of coupling to objects of specific classes, you can connect to any object that implements the contract.