Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS0514Slide 1 IS0514 Lecture Week 5 Introduction to Object Orientation.

Similar presentations


Presentation on theme: "IS0514Slide 1 IS0514 Lecture Week 5 Introduction to Object Orientation."— Presentation transcript:

1 IS0514Slide 1 IS0514 Lecture Week 5 Introduction to Object Orientation

2 IS0514Slide 2 Why Object Oriented? Based on domain analysis / subject matter analysis Close match to real world Nearly all Modern Technologies are Object Oriented –Java / C# / C++ / PHP (object extension) / Delphi –Oracle – Object relational database –=> closer match to end solution Widely accepted ( most common approach ) Extensible / Maintainable Reusable

3 IS0514Slide 3 Today's Lecture Introduction to object orientation concepts –Object –Class –Method –Attribute –Relationships Inheritance

4 IS0514Slide 4 What is the world? The world can be seen to consist: –Things –Relationships between things A thing can be: –Physical / Tangible –Idea / Concept / Non-Tangible In object orientation a thing is called an Object “Thing-Oriented Analysis!”

5 IS0514Slide 5 Exercise 1 Think about the objects in this room. Try to identify the objects in this room –What “things” are here Physical Conceptual / Ideas In groups of 3-4 spend 5 minutes discussing what objects there are. At the end of that time you will be asked to share your thoughts with the rest of the class.

6 IS0514Slide 6 Exercise 1 - Possible Objects Physical The lecturer Each of the students Each of the seats The handouts Computer Projector Crisps / Chocolate / Cans Each of the Mobile phone – switched off or silent! Ideas The lecture itself Exercise 1 Lecture slide

7 IS0514Slide 7 Attributes and behaviour Objects have properties called attributes –Attributes are the data associated with an object Objects have behaviour – we call these methods –These are the tasks an object will do (typically when we ask it to) –These may also be called operations / member functions but we will try and call them methods Example – A Car –Attributes Make Model Engine Size Current Speed –Methods break() accelerate() changeGear() honkHorn()

8 IS0514Slide 8 Exercise 2 Think about the object “a student” Try an identify its –Attributes –Methods Think about which of these are relevant as regard to the university? In groups of 3-4 spend 5 minutes discussing this. At the end of that time you will be asked to share your thoughts with the rest of the class.

9 IS0514Slide 9 Exercise 2 - Solution Attributes Name Registration Number Date of Birth Gender Address Programme etc Methods AttendLecture() AttendSeminar() CompleteAssignment() SitExam() etc

10 IS0514Slide 10 Categories of things Things naturally fall into categories (Car, Furniture, House) In object orientation, a category of things is called a class – an object is an instance of a class – my car => object Car => class Objects share behaviour as defined by their class – respond to the same set of methods –For example all cars can accelerate –Some value(s) can affect what a method does Objects share Class attributes e.g. every car has a colour Object attributes will have different values

11 IS0514Slide 11 Exercise 3 Think about the objects in the room and try to identify what classes these objects belong to. In groups of 3-4 spend 5 minutes discussing this. At the end of that time you will be asked to share your thoughts with the rest of the class.

12 IS0514Slide 12 Exercise 3 - Possible Classes Physical Person Lecturer Student Seat Furniture Handout Computer Projector Ideas Lecture Exercise

13 IS0514Slide 13 Classes and Objects –more formally Class – Template to define specific instances or objects Object – Instantiation of a class Attributes – Describes each object Behaviors – Specify what each object can do –Methods (a.k.a. operations)

14 IS0514Slide 14 Classes and Objects

15 IS0514Slide 15 Methods and Messages Methods implement objects’ behavior –Analogous to a function or procedure Messages are sent to trigger methods –Procedure call from one object to another object

16 IS0514Slide 16 Messages and Methods

17 IS0514Slide 17 Relationships between Classes Classes / Objects can be related –Student completes Assignment –Student is registered for a Module –Student has access to the Blackboard Some relationships are stronger than others –Student is a kind of Person –Lecturer is a kind of Person Inheritance –Is a generalisation / specialisation relationship between two classes –Is “a kind of” relationship

18 IS0514Slide 18 Class Hierarchy

19 IS0514Slide 19 Exercise 4 Think about the class hierarchy between Person, Student, Lecturer, Full Time Student and Part Time Student. Draw the class hierarchy In groups of 3-4 spend 5 minutes discussing this. At the end of that time you will be asked to share your thoughts with the rest of the class.

20 IS0514Slide 20 Exercise 4 - Class Hierarchy Person LecturerStudent PartTimeStudentFullTimeStudent

21 IS0514Slide 21 Inheritance – some terms Superclasses or general classes are at the top of a hierarchy of classes Subclasses or specific classes are at the bottom Subclasses inherit attributes and methods from classes higher in the hierarchy In our tree, which are the subclasses and superclasses?

22 IS0514Slide 22 Inheritance

23 IS0514Slide 23 Basic Characteristics of Object Oriented Systems Classes and Objects Methods / Messages Inheritance THE BASICS OF OBJECT ORIENTATION Next Week: Class Diagrams

24 IS0514Slide 24 This weeks reading ESSENTIAL READING Dennis A, Wixom B, and Tegarden D (2005) System Analysis and Design with UML version 2 second edition, Wiley Pages 23-29 Further reading Bennett, S., McRobb, S. and Farmer, R. (2002) Object- Oriented Systems Analysis and Design using UML, 2nd Edition, McGraw-Hill Chapter 4


Download ppt "IS0514Slide 1 IS0514 Lecture Week 5 Introduction to Object Orientation."

Similar presentations


Ads by Google