Introduction to Object-Oriented Design Concepts. Object-Oriented Design Overview Object-Oriented design is basically a set of guidelines/concepts for.

Slides:



Advertisements
Similar presentations
Systems Analysis and Design 8th Edition
Advertisements

Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Inheritance Inheritance Reserved word protected Reserved word super
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Object-Oriented Analysis and Design
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Introduction To System Analysis and Design
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
UML – Class Diagrams.
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,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
Object Oriented System Development with VB .NET
Basic OOP Concepts and Terms
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 9 Objects and Classes.
C++ fundamentals.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
Introduction To System Analysis and design
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
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.
Introduction To System Analysis and Design
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Systems Analysis and Design in a Changing World, 3rd Edition
Systems Analysis & Design 7 th Edition Chapter 5.
Systems Analysis and Design 8 th Edition Chapter 6 Object Modeling.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 02 – Classes, Objects, Instances Richard Salomon and Umesh Patel Centre.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
Design Model Lecture p6 T120B pavasario sem.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Chapter 17 – Object- Oriented Design. Chapter Goals To learn about the software life cycle To learn about the software life cycle To learn how to discover.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design,
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.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
Introduction to UML and Rational Rose UML - Unified Modeling Language Rational Rose 98 - a GUI tool to systematically develop software through the following.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Object-Oriented Analysis and Design
MPCS – Advanced java Programming
Chapter 3: Using Methods, Classes, and Objects
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Introduction to Classes
Introduction to Classes
Corresponds with Chapter 7
Object-Oriented Programming
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Presentation transcript:

Introduction to Object-Oriented Design Concepts

Object-Oriented Design Overview Object-Oriented design is basically a set of guidelines/concepts for developing software that is bug free and easily maintained

Object-oriented vs. Procedural Procedural –Programmer is dependent on language- defined data types (primitives) –C offers the struct concept to create compound data types but no way to create operators that work on those user defined types –For function calls data must be passed in via argument lists or globally scoped variables

Object-oriented vs. Procedural Object-oriente d –Programmer can create their own data types –In some languages (e.g. C++) the programmer can define operators to work on the defined data types –There are no function calls Object methods are activated via message passing Data can be passed via –Argument list –Globally scoped variables –Receiver scoped variables

Objects In an Object-Oriented design, attributes and behaviors are grouped together into a single container –Attributes are data items (member variables) –Behaviors are methods (member functions) –The container is the class Avoid global data and functions –Data and functions that are declared outside any class –Some OO languages do not even allow this (Java)

Data Hiding Access to class methods and attributes should be restricted –Attributes should be private Access to attributes is provided by –Accessors (“getters”) –Mutators (“setters”) –Behaviors may be public or private, depending on their functionality Public methods are message handlers –Only the interface is exposed to the “outside world” –Implementation details are hidden Private methods are helpers –Existence is completely withheld from the “outside world”

Class and Object A class is a high-level data item (abstract data type) that will be useful in designing your software but not supplied natively by the language –A class has no physical existence Objects are the data items instantiated (declared) of type class –An object has a physical existence in computer memory

Attributes Can be native (primitive) data types (int, double, float, char, …) Can be abstract data types (class) Should be private

Methods Constructors – for initialization of the newly instantiated object Destructor (C++) – for clean-up of an unneeded object (finalize in Java) Message handlers – publicly accessible for communication among objects Helpers – private functions for use within the object

Encapsulation Interface –The type-signature of the message handlers Name, argument types, return type –May be a language specific construct as in Java –May be a header file as in C++ –VB??? C#??? Implementation –The code that performs the desired task –Hidden from the outside world

Composition/Aggregation A form of code reuse –Break a large object into small objects that may be useful in other places Easier to –Understand –Design –Implement –Debug The “has-a” test is used to determine if an aggregation relationship between two classes is appropriate

Inheritance Another form of code reuse –Grouping of attributes and behaviors that are common to two or more classes –The common attributes/behaviors are formed into a class called the base class, super class, or parent class New classes may extend the base class to include additional functionality not common to other classes –Called the Derived class, sub-class, or child class The “is-a” test is used to determine if an inheritance relationship between two classes is appropriate

Inheritance An inheritance tree or inheritance hierarchy is formed by deriving new classes from the previously derived classes – all with heritage (ancestry) back to the root class Some languages (C++) allow for multiple inheritance – Java does not [directly] –What problems arise with multiple inheritance?

Polymorphism A single message that can be handled by anyone of a number of message handlers The specific message handler is determined by the context of the message The determination is made at run time (unless the compiler can do it based on the type-signature of the message) –Inheritance relationships can cause confusion –Object-oriented languages usually offer some form of real-time-type-identification (RTTI)

Object-Oriented Design Process (actually, all design processes) Conceptualization –Analyze the problem specification –Identify primary classes and their relationships Representation –Model the system –Refine classes (change, add, delete) Implementation –Convert the model to code

Conceptualization Make sure you understand the given task before you start working on it –Read the specification –Ask the customer/user questions –Create informal scenarios –Identify useful classes/objects –Clear up any ambiguities that may exist –Create UML Use Case diagrams –Identify test cases to validate proper system operation –Present your understanding to the team (informal walk-thru) and to the customer (structured walk- thru)

Representation Create a model of the system –Unified Modeling Language Class diagrams Interaction diagrams –Sequence –Collaboration (Communication) State diagrams Deployment diagrams Others as necessary –Code prototypes How detailed should the UML be? –Sketch –Blueprint –Programming Language

Implementation Convert models (UML diagrams) to code –Class skeletons Method signatures Pseudo code (comments) –Operational programs

Use Case Diagram Chapter 9

Informal Scenario When there are parts of the system… –…that you just don’t understand by reading the specification… –…that are obvious from reading the specification… …you should “play computer” This is what informal scenarios are for

Informal Scenario Describe in excruciating detail, exactly how the system (hardware + software + user) operates under various conditions –Cover a very small “snippet” of the system operation –They are not beginning-to-end descriptions! –If you make enough informal scenarios, you could conceivably link them together to make a beginning-to-end description

Informal Scenario Consider a tic-tac-toe game Title: End-Game Current State: X has markers in the upper-left and right squares O has markers in the upper and middle-middle squares It is O’s turn Scenario: O places a marker the lower-middle square Seeing that O has three of its markers unblocked, horizontally, in the middle column O declares itself the winner X concedes defeat Next Scenario(s): 1) Request rematch 2) Throw tantrum XOX O XOX O O

Informal Scenario Guidelines –Should be short –Should address only one system activity –Should utilize specific/concrete values –Should address pass (expected behaviors) and fail (unexpected behaviors) situations –Should not contain implementation details –Should describe the state of the system going into the scenario –Should indicate the next scenario(s)

Informal Scenario Bad scenario: Title: End-Game Current State: X has two markers on the board O has two markers on the board Scenario: O places another marker on the board O declares itself the winner because it has three markers in a row Next Scenario(s): 1) Request rematch 2) Throw tantrum

Scenario A scenario is a sequence of informal scenarios chained together to describe an end-to-end behavior of the system Note that depending on how informal scenarios are chained together, multiple scenarios can be created

Use Case Capture the functional requirements of a system Describe typical interactions between the users and the system –Users may be people, data sources, or other systems Represent a set of scenarios that are of similar functionality (but may differ in their detail)

UML Does not provide any diagrams or guidelines for developing informal scenarios or scenarios Does provide facilities for creating use case diagrams

Use Case Diagram Actor System boundary Actor Use cases

Use Case Diagram It’s merely a graphical representation of the functions performed by the system Don’t try to add a lot of detail to them, just capture the essence of the system functionality Detail will come in later diagrams –You can think of the Use Case Diagram as a “table of contents” and the other diagrams to be the “content”

Project Deliverables Write a formal specification document including my functional specifications and the answers I gave to your questions Due next class meeting (Deliverables continued on next page)

Project Deliverables Create informal scenarios Create scenarios Create a use case diagram –Note that this is probably a very simple diagram since we are designing a very simple system Due week after next (I want to see progress next week and answer any questions you may have)