Introduction to ObjectOriented Software Development Introduction to Objectoriented
Introduction to Object-Oriented Software Development Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 1, 12/13/2021
Object-oriented modelling involves classes functioning as types describing their instances which are called objects. Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 2, 12/13/2021
Object-oriented modelling includes description of: - object properties - links between objects - object behaviour Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 3, 12/13/2021
Objects Icons representing “real world objects” of different types. my. Chair: Represented in the UML notation. : Bus Object name (id) and type Object name and no type : Truck : Plane : Ship PN 62001: Car Anonymous object, only type is given Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 4, 12/13/2021
Classify Objects = Decide Their Classes Some objects share the same type of qualities so we may formulate a general concept – that is to define a class. This is a form of abstraction - some of the differences between the objects are “abstracted away” (ignored). Furniture my. Chair: your. Chair: the. Brown. Sofa: A class describes a set of objects that have the same type of attributes, behaviour and relationships Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 5, 12/13/2021
Class and Objects in the UML Notation class objects Person Class name SSN name address attributes drive() Run(). . . operations (behaviour) person 1: Person SSN = 123. . . name= Jane address=Norway person 2: Person SSN = 122. . . name = James address = USA Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 6, 12/13/2021
Plato versus Aristotle • Plato talked about the ideas (classes) “behind the objects”, e. g. , you have the idée horse – which in his view existed - and you have concrete horses. • The programming language Self have only prototypes (objects). This is more in accordance with Aristotle: The classes have no existents by they own, the objects have an “immanent form” which makes it an object of a certain class. Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 7, 12/13/2021
• Does the ideas (/concepts/classes) “exist by themselves”? • Creating an object by copying a prototype is that different from creating an object by instantiating a class? Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 8, 12/13/2021
Making a Model • You have a problem domain and you want to make a system that solves some problem in this domain. • You single out what is essential for your problem, and you also typically simplify reality. • You make a model of your system, ”objects from reality” are mapped ”directly onto objects in the model. chair: Seated in Tom: car: reality mapping owner model Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 9,
Subclass and Superclass The class of human beings The subclass of ”female objects” People is superclass of Female Person Female Male Jane: James: Person The classes represented in the UML notation. Female Male Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 10, 12/13/2021
Class Hierarchy ~ Reuse by Inheritance An employee is a special type of person, so if you already have a Person class and needs an Employee class, then inheritance allows you to reuse class Person. superclass Person Jane: Employee SSN name address Employee is a specialisation of Person inheritance or specialization subclass Employee SSN = 123. . . name = Jane address = Norway title = accountant department = accounting An object of type Employee title department Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 11, 12/13/2021
Multiple Inheritance • UML supports multiple inheritance. • Some object-oriented theoreticians claim that multiple inheritance should not be used! (e. g. , Java). Cassette Book volume : Integer Cassette. Book Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 12, 12/13/2021
One Common Ancestor for All Classes In Java all classes have a common ancestor called Object, e. g. , in C++ this is not the case. Object hash. Code Person Car Employee Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 13, 12/13/2021
Linking Objects are typically connected in some way or another. For example: Jane is married to James, Jane owns a car. Person married Jane: Person : married ownership Car Class Model association : ownership some. Wreck: Car Object Model (model instance of class model) link James: Person Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 14, 12/13/2021
Part-of Relation Some objects can be seen as compost of other objects. Head 1 1 Arm 2 1 Person 1 2 Leg Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 15, 12/13/2021
There Are Typically Many Ways to Classify Objects Jim might be classified as a person, a male person, an employee, a student and so on, the context decides. xxx: xxx: xxx: xxx: xxx: the classes may overlap (or they may be disjoint) Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 16, 12/13/2021
Different Models May be Possible! Person Gender gender : String Female Male Person Gender Female Person Undecided ? Androgyni Person Gender Female Male Androgyni Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 17, 12/13/2021
Objects Have Behaviour operations ~ behaviour sending a message time Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 18, 12/13/2021
An Object-Oriented Program • Objects work together and solve problems. • Objects have state, state the values of the attributes defines the state. The state change when the values of the attributes change. Objects have identity. • Some objects are linked together • The objects communicate by sending messages to each other (messages follows the links). Sending a message is the same as asking an object to perform one of its operations. Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 19, 12/13/2021
- Slides: 19