Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.

Similar presentations


Presentation on theme: "Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented."— Presentation transcript:

1 Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented Analysis & Design Object Concepts part1

2 Instructor: Tasneem Darwish2 Learning Objectives  Understand what we mean by a software object  Understand how objects can communicate, using messages, to accomplish some task  Understand what happens when an object is no longer needed  Understand what we mean by a class.  Understand how to reuse code.

3 Instructor: Tasneem Darwish3 Introduction  The object-oriented approach was invented because of the difficulties people were having trying to get good quality systems produced on time and within budget, especially for large systems with many people involved.

4 Instructor: Tasneem Darwish4 Introduction  Some advantages of object-oriented approach: Code can be reused more easily Objects are easier for people to understand Specialists can communicate better

5 Instructor: Tasneem Darwish5 What is an object?  An object is a thing (an entity)  All objects have attributes:  Objects also have behaviour: a car can move from one place to another ObjectAttributes A cara manufacturer, a model number, a colour and a price

6 Instructor: Tasneem Darwish6 What is an object?  In programming terms, objects become stand-alone modules with their own knowledge (attributes) and behaviour  Not all aspects of a real-world object are needed to be considered as attributes or behaviours For example a student object shouldn’t have a height attribute in a university registration software system.

7 Instructor: Tasneem Darwish7 What is an object?  To create a new object in an object-oriented programming language we can use a creation expression ( a constructor). oldPerson = new Person("Sue Smith");

8 Instructor: Tasneem Darwish8 Identical or Equal  Consider holding a blue pen in your left hand and a blue pen in your right hand. The pens are equal but not identical.  In every country people see the Sun and its identical because there is only one sun.

9 Instructor: Tasneem Darwish9 Identical or Equal  To create two Pen objects and their colour is blue. bluePen_1 = new Pen(“blue”); bluePen_2 = new Pen(“blue”);  The bluePen_1 and bluePen_2 are equal because they have the same attributes values “blue” but they are not identical.  The objects bluePen_1 and bluePen_3 are identical bluePen_3 = bluePen_1

10 Instructor: Tasneem Darwish10 depicting objects  To represent an object on paper we can use a special notation called the Unified Modelling Language (UML) object diagram

11 Instructor: Tasneem Darwish11 depicting objects  An example of an object is a coffee machine object. (1) we should decide what operations (behaviour) a coffee machine needs: display drinks select drink accept money dispense drink

12 Instructor: Tasneem Darwish12 depicting objects (2) we should think about what the coffee machine needs to know in order to perform (the attributes) the operations: available drinks drink prices drink recipes

13 Instructor: Tasneem Darwish13 Encapsulation  Encapsulation refers to an object hiding its attributes behind its operations.  Hidden attributes are said to be private  Private attributes can be accessed through the object operations only.

14 Instructor: Tasneem Darwish14 Association and aggregation  All objects are connected to other objects, directly or indirectly, strongly or loosely.  When we’re modelling with objects, we can connect them in two principal ways: association or aggregation  Association is a weak form of connection: the objects may be part of a group, or family, of objects but they’re not completely dependent on each other.  Aggregation means putting objects together to make a bigger object.

15 Instructor: Tasneem Darwish15 Association and aggregation  Association example: A car, a driver, a passenger and another passenger are assosiated The Figure is an association on an object diagram – the attributes and operations have been omitted here in order to emphasize the structure.

16 Instructor: Tasneem Darwish16 Association and aggregation  Aggregation example: A House is an aggregation object

17 Instructor: Tasneem Darwish17 Association and aggregation  Some examples of aggregation and association: Friends: We would expect friends to be an association 1.there is no sense in putting the friends together to make a larger friend; 2.friends come and go over time. Components in a television set: its an aggregation 1.The components together form a television 2.If one component is removed the TV will not work Books on a bookshelf: This is an association Windows in an office block: this is an aggregation

18 Instructor: Tasneem Darwish18 Graphs and Trees  A tree is another name for a hierarchy.  aggregation is often referred to as a tree

19 Instructor: Tasneem Darwish19 Graphs and Trees  A graph is an arbitrary set of connections between a group of objects.  Objects in an association often form a graph.

20 Instructor: Tasneem Darwish20 Graphs and Trees  A tree is a special case of a graph  each node (object) in a tree has only one parent node but it can have any number of children.  Any group of connected objects forms an association, but only associations which have one parent for each child structure (aggregations) qualify as trees.


Download ppt "Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented."

Similar presentations


Ads by Google