Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 An introduction to object-oriented design.

Similar presentations


Presentation on theme: "Chapter 11 An introduction to object-oriented design."— Presentation transcript:

1 Chapter 11 An introduction to object-oriented design

2 Objectives To introduce object-oriented design To define objects, classes, attributes, operations and information hiding To introduce public and private operations, accessors and mutators To list the steps required to create an object-oriented design solution to a problem

3 11.1 Introduction to object-oriented design

4 Objects – Can be considered as a container for a set of data and the operations that need to be performed on it – Objects have the following properties It has an identity that is unique for the lifetime of the object It has data in a form of a set of characteristics or attributes A set of operations or methods that can be performed on the date It is a instance (example) of a class

5 Introduction to object- oriented design Classes and objects – Object is created from a template or pattern, called a class which defines the basic relationship, attributes and operations available to the objects of that class – Each class in a system should bear a unique name – Process of creating objects from classes is called instantiation and an object is described as an instance of its class

6 Introduction to object- oriented design Attributes – An object’s data is stored in attributes – Attributes are the properties or characteristics that describe that particular object – Objects of the same class will have an identical set of attributes

7 Introduction to object- oriented design Methods – Objects usually have a set of operations called ‘methods’ – Includes all operations required to be performed on an object, and are the same as modules in procedural programming

8 Introduction to object- oriented design Inheritance – Allows a new object to inherit the same attributes and methods as an existing object

9 Introduction to object- oriented design Class diagram – Object-oriented programming requires classes, attributes and methods to be represented in a class diagram – Consists of a rectangular box divided into three section with the name of the class at the top, the attributes of the class in the middle and the methods at the bottom

10 Introduction to object- oriented design Encapsulation and information hiding – Objects are said to be encapsulate (enclose together in a single indivisible unit) – In object-oriented design, each object can be regarded as a ‘black box’ whose internal workings are hidden from all other objects

11 11.2 Public and private access methods

12 Necessary to consider whether the attributes and operations of an object are to have private or public access This concept is called ‘visibility’ Private access means that the attribute and methods are invisible to the rest of the system Public access means that the operation is visible other objects

13 Public and private access methods Instantiating objects – Every time an object is instantiated from a class, a special operation, or set of instructions known as a ‘constructor’ method is called or invoked – Constructors may: Have no parameters – new objects is assigned all the default vales for its attribute Have parameters that initialise the attributes with specific values

14 Accessors and mutators – The values in the attributes of an object should be available to all operations in that object, but hidden from external objects – Accessor operations pass attribute values to external objects – Mutator operations enable objects to change the values stored in attributes Public and private access methods

15 Message – Communication is achieved when one object passes a message to another – Message from one object to another usually initiates the processing of an operation in the receiving object Public and private access methods

16 11.3 Steps in creating an object- oriented solution

17 Three steps in creating an object- oriented solution for a problem with just one class: 1.Identify the objects and their attributes, responsibilities and operations 2.Design the algorithms for the operations and methods using structured design 3.Develop a test or driver algorithm to test the solution

18 Summary Object-oriented design focuses on the objects that make up a program rather than on the processes. An object can be defined as a container for both a set of characteristics and a set of operations that can be performed on the data. Objects encapsulate their data and operations, and can be regarded as ‘black boxes’ for the purposes of large system design.

19 Summary Operations that are accessible by external objects are described as having public access. Operations that are internal to the object are described as having private access.

20 Summary The steps in designing an object- oriented solution for a programming problem are: 1.Identify the classes and their attributes, responsibilities and operations. 2.Design the algorithms for the operation, using structured design. 3.Develop a test or driver algorithm to test the solution.


Download ppt "Chapter 11 An introduction to object-oriented design."

Similar presentations


Ads by Google