Object-Orientated Design Unit 3: Objects and Classes Jin Sa.

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

CIT731: Database Development Object Oriented Modeling (OOM)
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Introduction To System Analysis and Design
Objects First With Java A Practical Introduction Using BlueJ Designing object-oriented programs How to write code in a way that is easily understandable,
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
Object Oriented System Development with VB .NET
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Lecture 4 Class Responsibility Collaboration Cards
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
Creating Architectural Descriptions. Outline Standardizing architectural descriptions: The IEEE has published, “Recommended Practice for Architectural.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Requirements Analysis 4. 1 Use Case I b504.ppt © Copyright De Montfort University 2000 All Rights Reserved INFO2005 Requirements Analysis Use-Cases.
Classes Chapter 4. Terms and Concepts A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Computer Science 240 Principles of Software Design.
The chapter will address the following questions:
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
CS 5150 Software Engineering Lecture 15 Program Design 2.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes.
Why Analysis Process Refer to earlier chapters Models what the system will do makes it easier for understanding no environment considered (hence, system.
Lesson 7 Guide for Software Design Description (SDD)
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
CSCI-383 Object-Oriented Programming & Design Lecture 9.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
High-Level Design With Sequence Diagrams COMP314 (based on original slides by Mark Hall)
Introduction To System Analysis and Design
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
SE: CHAPTER 7 Writing The Program
Structural Modeling. Objectives O Understand the rules and style guidelines for creating CRC cards, class diagrams, and object diagrams. O Understand.
Systems Analysis and Design in a Changing World, 3rd Edition
GRASP: Designing Objects with Responsibilities
1 Software Development Software Engineering is the study of the techniques and theory that support the development of high-quality software The focus is.
1 Class Diagrams: The Essentials. 2 Terms and Concepts A class is... The most important building block of any object-oriented system. A description of.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
Lecture 6: Structural Modeling
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
Structural Modeling Chapter 7. Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes in.
1 Structural Modeling Chapter 7. 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes.
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.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Design Model Lecture p6 T120B pavasario sem.
Designing Classes. Software changes Software is not like a novel that is written once and then remains unchanged. Software is extended, corrected, maintained,
1 Introduction to Classes. 2 Terms and Concepts A class is... –The most important building block of any object- oriented system. –A description of a set.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Identification of Classes. Object Oriented Analysis (OOA) OOA is process by which we identify classes that play role in achieving system goals & requirements.
Unit 1 - Introducing Abstract Data Type (ADT) Part 1.
Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain –The solution domain is changing very rapidly.
Object-Orientated Analysis, Design and Programming
GRASP – Designing Objects with Responsibilities
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Data Abstraction: The Walls
OO Domain Modeling With UML Class Diagrams and CRC Cards
Service-centric Software Engineering
Software Design Lecture : 9.
Copyright 2007 Oxford Consulting, Ltd
Chapter 5 Architectural Design.
Object-Oriented PHP (1)
Presentation transcript:

Object-Orientated Design Unit 3: Objects and Classes Jin Sa

Session Aims introduce the concept of objects and classes. present methods for identifying classes given textual descriptions of required system functionality. illustrate the benefits of highly cohesive loosely coupled classes. explain the UML class and object notion. introduce the term encapsulation and show the benefits of applying encapsulation to classes.

What is an Object? -recap an object knows something – its data, and it knows how to do something – its functions. – E.g. a Bank account object may know the balance of the account and provide functions to add or withdraw funds. In object-orientated programming languages object behaviour is implemented in the form of methods.

Classes and objects A class is a blueprint for an object. The class defines the generic behaviour of an object and the type of data it may store Objects that behave in a manner specified by a class are called instances of that class. Example – A Film class : data could include title of the film and the certification rank Methods could be modifying certification rank – One instance of the Film class could contain details of the film “The Godfather” and another “The Dark knight”. – Each of the instances stores exactly the same type of data, film name, certification and classification yet each one represents a different film.

Classes and objects : summary Objects are instances of classes. Classes define the behaviour and the data types for an object Data held in instances of the same class will typically vary. Instances of the same class provide exactly the same services (subject to the data not controlling the flow).

Terms, Concepts and UML Notation In UML, a class is rendered as a rectangle.

UML notation: Class Every class must have a name, e.g. Student An attribute (data) is a named property of a class that describes a range of values that instances of the property may hold, e.g. every customer has a name and an address. An operation is an implementation of a service that can be requested from any object of the class to affect behaviour, e.g. setName

CRC Process Once you have a reasonable list of candidate classes in your OO design you can further evaluate their place in a particular system by identifying their responsibilities – what they do, and – who they need to work with to do this – their collaborations. – The process is referred to as the Classes Responsibilities and Collaborations process or more commonly as the CRC process.

CRC process write the names of all candidate classes on a series of cards. work through the textual narrative of the system requirements, i.e. the use case descriptions assigning responsibilities to classes, e.g. determining doing something, knowing something and decision making. Classes that have no responsibilities can be removed because they do not add value to the system

A Common technique– modelling the vocabulary of a system To model the vocabulary of a system, Identify those things users or implementers use to describe the problem or the solution. Use CRC and use case –based analysis to help find these abstractions. For each abstraction, identify a set of responsibilities. Make sure that each class is crisply defined and there is a good balance of responsibilities among all your classes. Provide the attributes and the operations that are needed to carry out there responsibilities.

Example Abstractions drawn from a retail problem domain could include: Customer, Order, Product, Shipment, Invoice and Warehouse. Abstract such as Transaction is a solution related abstraction.

Encapsulation encapsulation refers to the process of an object controlling outside access to its internal data. Client only knows how to call the methods, not how the methods are implemented. Data attributes are made private, i.e. protected from being directly accessed from outside Visible methods (services) are made public

Benefits of encapsulation The main benefit of encapsulation is that the programmer may change the implementation of the object without affecting the whole program, if he or she preserves the interface of the object. Any change of the data representation will affect only the implementation of the methods. By keeping data private and providing public well-defined service methods the role of the object becomes clear to other objects. This increases usability.

Cohesion and Coupling objects in the system must work together to achieve a common set of goals avoid placing too many responsibilities with a single object. create object that knows how to do one task and they are able to do that task well Example: a system goal such as “load the product catalogue”, – We may have one object that knows how to open and read a file, another object may know how to parse the XML text, a third object may know how to store in memory the data-type structures and so on – Alternatively, we could create a single object that did all of these tasks but not flexible for reuse elsewhere as it does too much. Also changing to the code may be difficult because all of the functionality is so tightly linked. Hence we would say the ease of maintenance for this object is poor.

Object coupling and cohesion

Cohesive object does one thing only and does that one thing well Low cohesive objects are unclear about their purposes Highly cohesive classes have clearly defined relationships with other classes, and collaborate in clear ways Classes of low cohesion have complex and confused relationships with other classes, and collaborate in complex ways. Within models of tightly coupled classes, a change to one class often has knock-on effects on many other related classes. Strong coupling results in complex models that are difficult to understand and maintain, With loosely coupled classes, a change to one class is often encapsulated to that class, preventing knock-on changes to related classes.

Object coupling and cohesion In summary, by creating well defined public services you are making it clear what the responsibilities of the object are. By allocating the appropriate responsibilities to a class and not overburdening it you are promoting cohesion and loose coupling. Assigning too many responsibilities to an individual class will promote loose coupling but at the expense of cohesion. Assigning too few responsibilities or misplacing responsibilities will create a system with tight coupling. Therefore as software designers we aim to create highly cohesive objects that are loosely coupling. In reality this will not always be possible and often the skill of the designer is finding the best tradeoffs, a happy medium!

Recap Classes exist in code and are the blueprints used to create objects Objects are instances of classes and exist at runtime A common modelling technique is to model the vocabulary of the system. Encapsulation is achieved by making data private and services public We seek to develop classes that are highly cohesive and loosely coupled.

Student activity Complete student activity 3.2