Object-Oriented Principles Applications to Programming.

Slides:



Advertisements
Similar presentations
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Advertisements

Problem Solving and Algorithm Design
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Objects First With Java A Practical Introduction Using BlueJ Designing object-oriented programs How to write code in a way that is easily understandable,
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
Stéphane Ducasse«ChapterNr».1 Arthur Riel Design Heuristics from Object-Oriented Design Heuristics by Arthur Riel Read the Heuristics… –Find reasons why.
Algorithms and Problem Solving
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
SOS OOP Fall 2001 Object Oriented Programming in Java Week 1 Read a design Design a small program Extract a design Run a VAJ program Change that program,
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Data Abstraction: The Walls
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
1 Working with Classes Chapter 6. 2 Class definition A class is a collection of data and routines that share a well-defined responsibility or provide.
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
CS2110: SW Development Methods Design of methods (functions) Class design – CRC cards – UML class and sequence diagrams Software Design.
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
Implementation & Integration Phase Implementation, then integration: Implementation, then integration:  Each module is implemented by member of programmer.
Introduction to Object-oriented programming and software development Lecture 1.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
CSE 303 – Software Design and Architecture
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Java Classes Using Java Classes Introduction to UML.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
S.Ducasse Stéphane Ducasse 1 Design Heuristics.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Systems Analysis and Design in a Changing World, 3rd Edition
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
Lecture 3 : Object Oriented Design (chapter 3. of Timothy Budd’s “Intro to OOP” book) Acknowledgement : courtesy of Prof. Timothy Budd lecture slides.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
Data Abstaraction Chapter 10.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Abstraction ADTs, Information Hiding and Encapsulation.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
Lecture 14 22/10/15. The Object-Oriented Analysis and Design  Process of progressively developing representation of a system component (or object) through.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Lecture 3 : Object Oriented Design (chapter 3
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
1 Using const in C++ Classes In the presence of pointers we must take steps to ensure the integrity of the object Can use const method definitions The.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Object-Oriented Programming (OOP) and C++
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
GRASP – Designing Objects with Responsibilities
Coupling and Cohesion Rajni Bhalla.
More Sophisticated Behavior
Reference: COS240 Syllabus
Slides by Steve Armstrong LeTourneau University Longview, TX
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Presentation transcript:

Object-Oriented Principles Applications to Programming

Main Principles Generate Reusable SW Components Generate Reusable SW Components Strongpoint of OOP technology Strongpoint of OOP technology Supported by inheritance and composition Supported by inheritance and composition Always prepare for change Always prepare for change If your SW is successful, your client will want a new, different version If your SW is successful, your client will want a new, different version Identify the points of change in your application (tension points) and try to minimize them Identify the points of change in your application (tension points) and try to minimize them Isolate and reduce non-portable code Isolate and reduce non-portable code Reduce coupling (later) Reduce coupling (later)

More Principles Put your data first Put your data first It is less likely to change over time It is less likely to change over time Tasks are mutable Tasks are mutable Assign responsibilities Assign responsibilities Determine what your classes and methods do Determine what your classes and methods do Decide what needs to be done, then decide who will do it Decide what needs to be done, then decide who will do it Walk through a scenario and assign activity to components as responsibility Walk through a scenario and assign activity to components as responsibility Use CRC cards Use CRC cards

Any Yet More Team programming coordination Team programming coordination Keep what each team members knowledge of what other team members provide ata minimum Keep what each team members knowledge of what other team members provide ata minimum Encapsulate, i.e. isolate and insulate data Encapsulate, i.e. isolate and insulate data Data Hiding (closely related to the above) Data Hiding (closely related to the above) Keep SW component interaction at a minimum Keep SW component interaction at a minimum

Documentation Document so others after you do not have to reinvent the wheel Document so others after you do not have to reinvent the wheel User Manual: Do this prior to design to make sure the client’s requirements are satisfied User Manual: Do this prior to design to make sure the client’s requirements are satisfied Design Documentation: Make explicit decisions made during the design phase Design Documentation: Make explicit decisions made during the design phase Do this right after assignment of responsibilities Do this right after assignment of responsibilities

Software Components State vs Behavior State vs Behavior Behavior consists of the actions the SW can perform. Complete description is the protocol Behavior consists of the actions the SW can perform. Complete description is the protocol State is the data of the component State is the data of the component Most components are a combination of these Most components are a combination of these E.g. a Student (SW component) studies (behavior), but has a record of courses completed (state) E.g. a Student (SW component) studies (behavior), but has a record of courses completed (state)

SW Components Cohesion: the degree to which the responsibilities of a SW component cohere, or form a logical unit Cohesion: the degree to which the responsibilities of a SW component cohere, or form a logical unit Associate methods that are logically related Associate methods that are logically related Try to maximize Try to maximize Consider a common data area Consider a common data area Coupling: the degree of program dependence between components Coupling: the degree of program dependence between components Discourage outside methods from accessing private data Discourage outside methods from accessing private data Minimize this dependence Minimize this dependence

Interfaces When offering component use, state only what is being offered, not how it is implemented (information hiding) When offering component use, state only what is being offered, not how it is implemented (information hiding) E.g. offer a Vector class that allows insertions, deletions, printing of objects E.g. offer a Vector class that allows insertions, deletions, printing of objects Bottom Line: whether you use a list, an array or whatever is not important, no irrelevant. Bottom Line: whether you use a list, an array or whatever is not important, no irrelevant. Programming with no knowledge of implementation detail is called programming to an interface Programming with no knowledge of implementation detail is called programming to an interface

Interface Quality Cohesion – all of its methods are related to a single abstraction e.g., public class MyContainer {} public void addItem(Item anItem) {….} public Item getCurrentItem() { … } public Item removeCurrentItem() { … } public void processCommand(String command) { … } …} Don’t need processCommand here!!

Interface Quality Completeness – interface should support all operations that are a part of the abstraction that the class represents.   e.g.,   The Stack class should contain a method to check if the Stack is empty

Interface Quality Convenience – ensure that the interface makes it convenient for clients to do associated tasks, especially common tasks.   e.g.,   Prior to Java 5 System.in could not read lines of text or numbers. This was fixed by the addition of the java.util.Scanner class

Interface Quality Clarity – the interface should be clear to programmers   e.g.,   LinkedList list = new LinkedList (); list.add(“A”); list.add(“B”); list.add(“C”);   …

Interface Quality Consistency: the operations in a class should be consistent with each other with respect to names, parameters, return values and behavior Consistency: the operations in a class should be consistent with each other with respect to names, parameters, return values and behavior e.g. e.g. from the Java Library: from the Java Library: new GregorianCalendar(year,month-1,day); new GregorianCalendar(year,month-1,day); The month is between 0 and 11 but the day is between 1 and 31 The month is between 0 and 11 but the day is between 1 and 31

Parnas’s Principle How something is implemented should never affect other SW components How something is implemented should never affect other SW components Certainly not: side effects Certainly not: side effects Always program to an interface Always program to an interface Interfaces do not have any information on how their specified behavior is implemented Interfaces do not have any information on how their specified behavior is implemented