SlideServe
Menu
Préférences
© SlideServe · v2026

OBJECT ORIENTED DESIGN

ursa-bright avatar
14 diapositives · 291 Views · Nov 06, 2014

This document explores the fundamentals of Object-Oriented Design (OOD), detailing the identification of objects within applications, their structures, values, and operations. It emphasizes the importance of abstraction in creating user interfaces and hiding implementation complexities. Utilizing practical examples such as ATM interfaces and custom data types (like DateType), it showcases the significance of interaction via message passing, class enforcement, and procedural control in effective program design. Ultimately, it outlines best practices in defining and implementing object structures for robust software development.

OBJECT ORIENTED DESIGN - slide 1
01 / 14OBJECT ORIENTED DESIGN
1 / 17

Télécharger la présentation

OBJECT ORIENTED DESIGN
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. OBJECT ORIENTED DESIGN CMPS260 ULL Computer Science Department

  2. OBJECT DEFINITION • IDENTIFY THE OBJECTS IN AN APPLICATION • SPECIFY THEIR STRUCTURES, VALUES AND OPERATIONS • HOOK THEM TOGETHER TO SOLVE THE PROBLEM (SWE)

  3. OBJECTS • OBJECTS ARE THE ENTITIES IN THE PROBLEM STATEMENT (NOUNS) • OBJECTS HAVE STRUCTURES, VALUES AND OPERATIONS • OBJECTS INTERACT WITH OTHER OBJECTS (VISIBILITY) • OBJECTS ARE ABSTRACTIONS

  4. ABSTRACTION • THE REMOVAL OF NON-ESSENTIAL DETAILS • PROVIDES AN INTERFACE FOR THE USER • HIDES THE IMPLEMENTATION FROM THE USER • PROVIDES FOR ENFORCEMENT

  5. CLASSES • ABSTRACT DATA TYPES • SPECIFICATION (INTERFACE) • IMPLEMENTATION • COMPILED SEPARATELY • INTERACT VIA MESSAGE PASSING

  6. DRIVER • PROCEDURAL CONTROL PROGRAM • CREATES OBJECTS • USES OBJECTS • CONTROLS SYSTEM FLOW • THE SMALLER THE BETTER

  7. SUMMARY • OBJECTS ARE THE BASIC COMPONENTS • ABSTRACTIONS ARE DEFINED AND ENFORCED • PROCEDURAL ASPECTS ARE INCLUDED IN THE CLASSES AND THE DRIVER

  8. SAMPLE OBJECTS • PERSON • STUDENT (DERIVED FROM PERSON) • COURSE • CLASS (INSTANCE OF A COURSE) • SCHEDULE (CONTAINS A STUDENT AND THEIR CLASSES)

  9. EXAMPLE ATM MACHINE INTERFACE VERIFY, WITHDRAW … ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ IMPLEMENTATION HIDDEN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENFORCEMENT CRITICAL

  10. ATM OBJECT DIAGRAM IMPLEMENTATION (HIDDEN) (BETTER BE) INTERFACE (PUBLIC) ACCT DATA ??? USERS VERIFYACCT WITHDRAW FUNDS IN & OUT ??? DEPOSIT CHK BAL

  11. ~~~~~~~~~~~~~~~~~~~ SPECIFICATION FILE ~~~~~~~~~~~~~~~~~~~// Declare a class to represent the date ADT// This is file DateType.hclass DateType{public: void Initialize(int newMonth, int newDay, int newYear); int YearIs() const; // returns year; int MonthIs() const; // returns month; int DayIs() const; // returns day; enum RelationType {LESS, EQUAL, GREATER}; RelationType ComparedTo(DateType aDate);private: int year; int month; int day;};

  12. ~~~~~~~~~~~~~~~~~~~ IMPLEMENTATION FILE ~~~~~~~~~~~~~~~~~~~// Define member functions of class DateType.// This is file DateType.cpp.#include "DateType.h" // gain access to the specificationvoid DateType::Initialize(int newMonth, int newDay, int newYear)// Post: year is set to newYear.// month is set to newMonth.// day is set to newDay.{ year = newYear; month = newMonth; day = newDay;}// Accessor funtions for the private data membersint DateType::MonthIs() const// Accessor function for month.{return month;}int DateType::YearIs() const// Accessor function for year.{return year;}int DateType::DayIs() const// Accessor function for day.{return day;}

  13. RelationType DateType::ComparedTo(DateType aDate)// Pre: Self and aDate have been initialized.// Post: Function value = LESS, if self comes before aDate.// = EQUAL, if self is the same as aDate.// = GREATER, if self comes after aDate.{ if (year < aDate.year) return LESS; else if (year > aDate.year) return GREATER; else if (month < aDate.month) return LESS; else if (month > aDate.month) return GREATER; else if (day < aDate.day) return LESS; else if (day > aDate.day) return GREATER; else return EQUAL;}

  14. ~~~~~~~~~~~~~~~~~~~ DRIVER ~~~~~~~~~~~~~~~~~~~#include "DateType.h"#include <iostream>using namespace std;int main(){ DateType today; DateType anotherDay; today.Initialize(8, 24, 2006); anotherDay.Initialize(8, 25, 2006); cout << " Today is " << today.MonthIs() << "/" << today.DayIs() << "/" << today.YearIs() << endl; cout << " Another date is " << anotherDay.MonthIs() << "/" << anotherDay.DayIs() << "/" << anotherDay.YearIs() << endl; switch (today.ComparedTo(anotherDay)) { case LESS : cout << "today comes before anotherDay"; break; case GREATER : cout << "today comes after anotherDay"; break; case EQUAL : cout << "today and anotherDay are the same"; break; } return 0;}