1 / 20

Introduction to Object-oriented Software Development

Introduction to Object-oriented Software Development. Object-orientation Is a Modeling Technique. We perceive the world as a world of objects . Y ou look around and you see a chair, a table, a person, and the objects are related in one way or another.

Download Presentation

Introduction to Object-oriented Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction toObject-oriented Software Development

  2. Object-orientation Is a Modeling Technique • We perceive the world as a world of objects.You look around and you see a chair, a table, a person, and the objects are related in one way or another. • The object-oriented technique tries to imitate the way we think, a system developed by using the object-oriented technique can be seen as a system consisting of a number of objects which cooperate to solve a task.

  3. myChair: :Bus :Plane Object name and type Object name and no type :Truck :Ship PN62001 :Car Anonymous object, only type is given Objects • You find objects of different types in the real world. • At this moment you have x number of busses, one of them is represented by the buss picture. • The picture of the bus is a symbol and not the real thing. • In UML you can use icons to represent objects or: use rectangles and specify object name and object type.

  4. Furniture myChair: yourChair: theBrownSofa: The class of ”people objects” People The subclass of ”female objects” Female Male Jane: James: When You Classify Objects You Decide Their Type

  5. xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: The classes overlap 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.

  6. 1-Objects and Class • By watching the objects we recognize that some objects share the same type of qualities (a person has a name, the same number of chromosomes, ... ) so we might formulate a general concept – that is define a class. This process is called abstraction. • Plato talked about the ideas behind, you have the idée horse and you have concrete horses. For him, the ideas had their own existence, this idée concept is very close to the class concept. • When you program in an object-oriented language you can define your own classes and make objects of the different classes.(So is object-oriented programming a divine activity or what?)

  7. 2-Objects and Class • There are object-oriented languages were you do not have classes, only objects (e.g. Self). This is more like the way Aristoteles figured the world: the classes have no exsistens by they own, the objects have an immanent form which makes it an object of a certain class. • The more common languages like C++ and Java lets you define classes and than make objects of this classes. • A class describes a set of objects that share the same attributes, behaviour and relationships.

  8. Objects in UML ”A concrete manifestation of an abstraction; An entity with a welldefined boundary and identity that encapsulates state and behavior; An instance of a class.”

  9. chair: Seated in Tom: car: owner relation (link) reality model mapping Making a Model • You have a problem domain and you want to make a system that solves some problemin 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 into objects in the model.

  10. class objects Person Class name SSN name address Jane:Person James:Person attributes SSN = 123... name= Jane address=Norway SSN = 122... name = James address = USA drive() Run() ... operations Class and Objects in UML • You when you declare the class you select which attributes and operations are of interest for your system. • Objects of the given class will have individual values for the specified attributes.

  11. superclass Person Jane:Employee SSN name address SSN = 123... name = Jane address = Norway title = accountant deparment = accounting Employee is aspesialization of Person inheritance or specialization Employee subclass An object of type Employee is also a Person. An will have all attributes that a Person has plus all of its own. title department Class Hieararchy ~ Inheritance • An employee is a special type of person, so if you already have a Person class and need a Employee class then it should be possible to take advantage of the already existing Person class.

  12. Cassette Book volume : Integer volume : Integer CassetteBook MultipleInheritance • Some times when we describe a new class we see that this new class should have characteristics from two (or more) existing classes.It is then possible to inherit from both classes. • Not all object-oriented language support multiple inheritance (e.g. Java), some object-oriented theoreticians claim that multiple inheritance should not be used!

  13. One Common Ancestor for All Classes • In Java all classes have a common ancester called Object, this is not the case in C++.

  14. 1 - Relationships • Objects are typically connected in some way or another. For example: Jane is married to James, Jane owns a car. Jane:Person James:Person SSN = 123... name= Jane address=Norway SSN = 122... name = James address = USA married owns someWreck:Car

  15. 2 - Relationships • Some objects can be seen as consisting of other objects. Head 1 1 1 Person Arm 2 1 2 Leg

  16. operations ~ behaviour sending a message time Objects Have Behaviour

  17. An Object-orientedProgram • Objects work together and solves problems. • Objects have state, the values of the attributes defines the state. The state change when the attribute values changes. • 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 it’s operations.

  18. 1 - Paradigms of programming • Imperative programming (FORTRAN, C): • Algorithm abstraction (give name to a sequence of instructions) • Focus on the algorithms • Data in separate structures • Stepwise refinement (structured programming) • Datamodelling (COBOL, SQL): • Focus on data an the static relationships • Data abstractions, give name to a group of data (records)

  19. 2 - Paradigms of programming • Object-oriented programming (Smalltalk, C++, Java): • Data and behaviour is put together • More mathematical approaches: • Logical programming (Prolog) • Functional programming (Lisp)

  20. The First Object-orientedLanguage: Simula • Introduced in 1966 (or earlier). • Created by Ole-Johan Dahl and Kristen Nygaard. • A language for simulation but became a general purpose programming language. • Allan Key: “Simula is a major improvement of most of its sucessors”

More Related