Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Object-Oriented Design II: Applying Object-Oriented Design in Computer Science, Study notes of Computer Science

An overview of object-oriented design ii, focusing on the concepts of objects, classes, inheritance, and applying object-oriented design in the department of computer science at the university of maryland, college park. It covers the definition, properties, and forms of inheritance, as well as the process of finding classes and messages in a system.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-ts1
koofers-user-ts1 🇺🇸

10 documents

1 / 24

Toggle sidebar

Related documents


Partial preview of the text

Download Object-Oriented Design II: Applying Object-Oriented Design in Computer Science and more Study notes Computer Science in PDF only on Docsity! CMSC 132: Object-Oriented Programming II Object-Oriented Design II Department of Computer Science University of Maryland, College Park Overview Object-oriented design Objects, methods ⇒ Last lecture Classes, inheritance ⇒ This lecture Applying object-oriented design Classes Properties Classes provides classification for objects Every object belongs to some class Objects ⇒ instances (instantiations) of a class Example Class Given a class Car Objects can include MyHonda, YourHonda HerMiniCooper HisSUV All Car objects Share same properties & behavior May have different values for properties Car Inheritance Definition Relationship between classes when state and behavior of one class is a subset of another class Terminology Superclass / parent ⇒ More general class Subclass ⇒ More specialized class Superclass Subclass Inheritance Hierarchy Example Classes Thermostat Analog thermostat Digital thermostat Programmable thermostat Forms of Inheritance Specification Defines behavior implemented only in subclass Guarantees subclasses implement same behavior In Java → abstract method in superclass Specialization Subclass is customized Still satisfies all requirements for parent class In Java → override method Specialization Example Clock Implementation provided : by superclass inherited farrene: dane by subclasses. SS SetCurrentTime GetCurrentTime | _ Specification only DisplayTime <—] not implemented. L\ AnalogClock Digitalclock DisplayTime > DisplayTime This specialization provided by subclass. Specification of behavior inherited from parent class. Applying Object-Oriented Design 1. Look at objects participating in system Find nouns in problem statement (requirements & specifications) Noun may represent class needed in design 2. Look at interactions between objects Find verbs in problem statement Verb may represent message between objects 3. Design classes accordingly Determine relationship between classes Find state & methods needed for each class 1) Finding Classes Thermostat uses dial setting to control a heater to maintain constant temperature in room Nouns Thermostat Dial setting Heater Temperature Room Finding Classes Analyze each noun Does noun represent class needed in design? Noun may be outside system Noun may describe state in class 2) Finding Messages Thermostat uses dial setting to control a heater to maintain constant temperature in room Verbs Uses Control Maintain Finding Messages Analyze each verb Does verb represent interaction between objects? For each interaction Assign methods to classes to perform interaction Analyzing Verbs Uses “Thermostat uses dial setting…” ⇒ Thermostat.SetDesiredTemp() Control “to control a heater…” ⇒ Heater.TurnOn() ⇒ Heater.TurnOff() Maintain “to maintain constant temperature in room” ⇒ Room.GetTemperature()
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved