1 / 11

Object Oriented Design

Object Oriented Design. What is it? Why do it? Simon Woodworth, 19 August 2004. Introduction. Purpose of this presentation Explain what Object-Oriented Design (OOD) is Explain why it is important as a design and programming methodology OOD is important because …

Download Presentation

Object Oriented Design

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. Object Oriented Design What is it? Why do it?Simon Woodworth, 19 August 2004 Simon Woodworth

  2. Introduction • Purpose of this presentation • Explain what Object-Oriented Design (OOD) is • Explain why it is important as a design and programming methodology • OOD is important because … • It allows complex programming projects to be broken down into more mangeable sections • It reduces the cost of maintaining software

  3. Object:Red Setter Object:Labrador Object:Terrier Object:Bulldog What is Object-Oriented Design? • It promotes thinking about software in a way that models how we think about the real world • It organises program code into classes of objects Class: Dog • Every object is an instance of a class • Every object has attributes and behaviours

  4. What is a Class? • A class is a collection of things (objects) with similar attributes and behaviours. • For example: • Dogs • Attributes: Four legs, a tail • Behaviours: Barking • Cars • Attributes: Four wheels, engine, 3 or 5 doors • Behaviours: Acceleration, braking, turning

  5. What is an Object? • An object is a specific instance of a class • For example: • Volkswagen is an instance of the Car class • Attributes (what it looks like): • Blue • Front wheel drive • Max speed 115 mph. • Behaviours (what it does): • Accelerate • Turn • Stop

  6. In programming terms … • A class is a section of program code that defines how to create and use a specific group of objects. • It’s a template for creating new objects • An object is a specific instance of a class and has its own place in computer memory • Its attributes are stored as data values • Its behaviours are defined by program code • Every object is different – even if they look exactly the same! • For example: My blue Volkswagen is not the same as your blue Volkswagen

  7. Classes and Objects:An Example Object: Alice’s Account Attributes:Name = AliceNumber = 04701Balance = €1003.22 Behaviours:WithdrawLodge Class: Account Attributes: NameNumberBalance Behaviours:WithdrawLodge Object: Bob’s Account Attributes:Name = BobNumber = 28804Balance = €81.66 Behaviours:WithdrawLodge

  8. Why is this important? • It models how we view the real world • Humans tend to categorise what they see into groups • Even very small children do it • Reduces cost of software development • Large complex projects can be subdivided into classes • Reliability – the workings of objects can’t be interfered with • Classes can be reused in other projects • Classes can be maintained without rewriting other program code • Introduces new programming concepts • Encapsulation • Inheritance

  9. Object Oriented Design Concepts • Encapsulation • We can hide how an object works from other parts of the program • Increases reliability because the internal workings of objects are protected from interference • Allows us to reuse objects in other programs because their behaviour and attributes are well-defined • Allows us to change the way an object works on the inside without changing the way it looks on the outside • Example: Car Stereo • Standard case size and fittings, regardless of features • Can be upgraded without affecting rest of car

  10. Object Oriented Design Concepts • Inheritance • We can create new classes of objects by inheriting attributes and behaviours from existing classes and then extending them • No need to reproduce or duplicate work done in creating original class • We can build hierarchies (family trees) of classes • Example: Rally Car • Inherits properties of class Car … • … and extends class Car by adding a rollcage, racing brakes, fire extinguisher, etc.

  11. Conclusion • Object Oriented Programming Languages: • Java, C++, Visual Basic .NET, C# • Object Oriented Design allows us to create program code that is : • Reusable • Adaptable • Maintainable • Reliable

More Related