Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Programming

Similar presentations


Presentation on theme: "Object Oriented Programming"— Presentation transcript:

1 Object Oriented Programming
Introduction

2 What is object-orientation all about?
Principles and techniques for system modeling which: Aim to produce a model of a system manage complexity inherent in analysis, design, and implementation provide methodology for system development provide integrated view of hardware and software 2

3 How? “Using object-orientation as a base, we model a system as a number of objects that interacts.”

4 Object Oriented System (OOS)
Modelling the system by representing a collection of objects in it Each object represents some part of the system that is independent of other parts The different objects can collaborate to perform a task Interaction between objects through messages

5 Is it any good? A system which is designed and modeled using
an object-oriented technology is: Easy to understand Directly related to reality - reduces the semantic gap between reality and models Natural partitioning of the problem More flexible and resilient to change - allows local modification to models Systems can be developed more rapidly and at a lower cost

6 OO Programming

7 Object-oriented Programming
What is OOP? OOP is a programming paradigm based on three simple core concepts: Classes: Are “types” of “things” that we can talk about. Objects: Are “instances” or examples of classes. Message passing: Objects interact with each other by passing messages to ask each other to carry out their methods (behaviours).

8 Why OO programming? Modularity - large software projects can be split up in smaller pieces. Reusability - Programs can be assembled from pre-written software components. Extensibility - New software components can be written or developed from existing ones.

9 Objects Objects are key-concept to understand object-oriented technology. Objects are entities of the real-world that may interact with their environments by performing services on demand. Examples of real-world objects: your Car, your Cell-phone, the coffee slot-machine. Each Iphone 5s cell-phone is an object and may execute some services.

10 What is an object? Tangible Things as a car, printer, ...
Roles as employee, boss, ... Incidents as flight, overflow, ... Interactions as contract, sale, ... Specifications as colour, shape, …

11 what is an object? An object represents an individual, identifiable item, unit, or entity, either real or abstract, with a well-defined role in the problem domain. An object is anything to which a concept applies. An object is a “noun”

12 How to define an object? An object is defined by: Example
Attributes (also called fields) Behaviour---what it can do? (also called methods) Example A man can be defined by: Attributes: name, age, job, address,..etc Behaviour: talk, walk, eat, work, study,...etc How to define a bird? A car? A flight?

13 Classes Objects of the real world may be classified into types: Cars, Cell-Phones, CD Players, etc. Objects of the same type have the same characteristics and are manufactured using the same blueprint. A class is a blueprint or prototype from which objects of the same type are created. A class describes a set of objects having the same characteristics and offering the same services.

14 Class A class represents a template for several objects and describes how these objects are structured internally Objects of the same class have the same definition both for their operations and their information structure Classes are types of things

15 Class vs. Object Class People Class Vehicle Class Car
John , George, Sara are objects that can be instantiated from the people class Class Vehicle Bus, car, train are objects (instances of the vehicle class) Class Car The blue Nissan, the red Vauxhall, my uncle’s car are objects (instances of the car class)

16 Class vs. Object (cont.) Find a class to represent the following items: dog, cat, lion, tiger chair, table, wardrobe banana, orange, apple breakfast, lunch, dinner Provide examples of objects that can be instantiated from the following classes Students, Courses, Modules

17 Instance An instance is an object created from a class
A class describes the behavior and information structure of an instance, while the current state of the instance is defined by the operations performed on the instance System’s behavior is performed via the interactions between instances

18 Object-oriented Basics
Fields/attributes Classes define fields (e.g. a Person class could contain fields name, age, sex, etc.) Objects have attributes, which are values stored in fields (e.g. person_1 has attributes “John Smith”, 25, Male) An object’s state is defined by its attributes Methods Classes define methods, which can access or change attributes Objects communicate by calling (invoking) each others’ methods Parameters Methods can have parameters to pass additional information during execution 18

19 Summary – OO Basics Fundamental concepts Objects Classes
Object, Class, Field/attribute, Method, Parameter Objects Represent “things” from the real world, or from some problem domain (e.g. “the red car in the car park”) Classes Objects are created from classes Represent all objects of a kind (e.g. all “cars”) 19


Download ppt "Object Oriented Programming"

Similar presentations


Ads by Google