Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Object Oriented Programming Development z By: Marc Conrad University of Luton z z Room: D104.

Similar presentations


Presentation on theme: "1 Object Oriented Programming Development z By: Marc Conrad University of Luton z z Room: D104."— Presentation transcript:

1 1 Object Oriented Programming Development z By: Marc Conrad University of Luton z Email: Marc.Conrad@luton.ac.uk z Room: D104

2 2 What are we doing today? zIntroduction of: ythe lecturer yObjects yBasic Terminology yC++ ythe module

3 3 What is Object Oriented Programming? An object is like a black box. The internal details are hidden. z Identifying objects and assigning responsibilities to these objects. z Objects communicate to other objects by sending messages. z Messages are received by the methods of an object

4 4 What is an object? zTangible Things as a car, printer,... zRoles as employee, boss,... zIncidents as flight, overflow,... zInteractions as contract, sale,... zSpecifications as colour, shape, …

5 5 So, what are objects? zan object represents an individual, identifiable item, unit, or entity, either real or abstract, with a well-defined role in the problem domain. Or zAn "object" is anything to which a concept applies. Etc.

6 6 Why do we care about objects? zModularity - large software projects can be split up in smaller pieces. zReuseability - Programs can be assembled from pre-written software components. zExtensibility - New software components can be written or developed from existing ones.

7 Example: The Person class #include class Person{ char name[20]; int yearOfBirth; public: void displayDetails() { cout << name << " born in " << yearOfBirth << endl; } //... }; private data public processes

8 8 The two parts of an object Object = Data + Methods or to say the same differently: An object has the responsibility to know and the responsibility to do. = +

9 9 Basic Terminology zAbstraction is the representation of the essential features of an object. These are ‘encapsulated’ into an abstract data type. zEncapsulation is the practice of including in an object everything it needs hidden from other objects. The internal state is usually not accessible by other objects.

10 10 Basic Terminology: Inheritance zInheritance means that one class inherits the characteristics of another class. This is also called a “is a” relationship: A car is a vehicle A teacher is a person A dog is an animal

11 11 Basic Terminology: Polymorphism zPolymorphism means “having many forms”. It allows different objects to respond to the same message in different ways, the response specific to the type of the object. E.g. the message displayDetails() of the Person class should give different results when send to a Student object (e.g. the enrolment number).

12 12 Basic Terminology: Aggregation zAggregation describes a “has a” relationship. One object is a part of another object. zWe distinguish between composite aggregation (the composite “owns” the part) and shared aggregation (the part is shared by more then one composite). A car has wheels.

13 13 Basic Terminology: Behaviour and Messages zThe most important aspect of an object is its behaviour (the things it can do). A behaviour is initiated by sending a message to the object (usually by calling a method).

14 14 The two steps of Object Oriented Programming zMaking Classes: Creating, extending or reusing abstract data types. zMaking Objects interact: Creating objects from abstract data types and defining their relationships.

15 15 Historical Notes zC++ owes most to C. Other ancestors are Simula67 and Algol68. zFirst versions of C++ in 1980 under the name “C with classes”. Since 1983 the name C++ is used. z1990: ANSI/ISO 9899 defines a standard for C z1998: ISO/IEC 14882 specifies the standard for C++ C++ 1987

16 16 C++ and C zC is a subset of C++. Advantages: Existing C libraries can be used, efficient code can be generated. But: C++ has the same caveats and problems as C (e.g. pointer arithmetic,…). zC++ can be used both as a low level and as a high level language. We focus on the high level aspects.

17 17 C++ and Java zJava is a full object oriented language, all code has to go into classes. zC++ - in contrast - is a hybrid language, capable both of functional and object oriented programming. So, C++ is more powerful but also more difficult to handle than Java.

18 18 Module Outline zIntroduction zThe non object oriented basics zClasses zDesign Approaches zTesting z Inheritance z Aggregation z Polymorphism z Multifile Development

19 19 Assessment Details z50% in course and 50% exam. zFor more details for the in course assignment see separate handout.

20 20 Books zTeach Yourself C++ in 10 minutes, J. Liberty, SAMS 1999. zC++ - How to program, Deitel & Deitel, Prentice Hall, 2001. zObject Oriented Programming with C++, David Parson, Letts Educational, London 1997.

21 21 Websites zA C++ online tutorial: http://www.cplusplus.com/doc/tutorial/ zThe C++ FAQ: http://www.parashift.com/c++-faq-lite zThe homepage of Bjarne Stroustrup, the inventor of C++: http://www.research.att.com/~bs And many, many more!


Download ppt "1 Object Oriented Programming Development z By: Marc Conrad University of Luton z z Room: D104."

Similar presentations


Ads by Google