Understanding Objects and Classes

Slides:



Advertisements
Similar presentations
Introduction to Object Orientation System Analysis and Design
Advertisements

Object-Oriented Concepts
Systems Analysis and Design with UML Version 2.0, Second Edition
Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006.
Object-oriented modeling Class/Object Diagrams
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Ch 12: Object-Oriented Analysis
Object-Oriented Analysis and Design
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 11 Classes and Object- Oriented Programming.
Solving the Problem Analysis & Design.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Lecture 4 Class Responsibility Collaboration Cards
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
Object Oriented Analysis and Design Chapter 1 Applying UML and Patterns -Craig Larman.
Systems Analysis & Design Sixth Edition Systems Analysis & Design Sixth Edition Toolkit Part 5.
Software Engineering 3 rd Bachelor Informatics Ahmed Lamkanfi October 15, 2009.
More than Just Fun and Games Strategies for Integrating Technology into the Classroom Environment.
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology May 2006 Teaching Java using Turtles part 1.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
1 Chapter 2 (Cont.) The BA’s Perspective on Object Orientation.
CreatingClasses-part11 Creating Classes part 1 Barb Ericson Georgia Institute of Technology Dec 2009.
Object Oriented Design. Object-Oriented Design Method for designing computer programs –Useful for thinking about large problems Consider “objects” interacting.
Georgia Institute of Technology Creating Classes part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
Structural Modeling Chapter 7
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Object-Oriented Programming
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
CSC172 Class Design Pepper. Goals How to design classes How to think in terms of objects StarUML Code Generation.
1 Object-Oriented Modeling Using UML CS 3331 Section 2.4 Modeling Requirements with Use Cases.
CSC 395 – Software Engineering Lecture 14: Object-Oriented Analysis –or– Ripping the Band-Aid Off Quickly.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Chapter 1 Applying UML and Patterns. The Need for Software Blueprints Knowing an object-oriented language and having access to a library is necessary.
Structural Modeling Chapter 7. Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes in.
1 Structural Modeling Chapter 7. 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes.
COMP-350 Object-Oriented Analysis and Design Drawing System Sequence Diagrams Reference: Larman, Chapter 9.
ERD ( Conceptual data model From the statement of data requirements a conceptual data model is produced. This describes.
CSC480 Class Design Pepper. Goals How to design classes StarUML Code Generation.
Object-Oriented Analysis and Design ธนวัฒน์ แซ่ เอียบ.
Georgia Institute of Technology Simulations Barb Ericson Jan 2005.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 1 Introduction to Object-Oriented Development.
ITEC324 Principle of CS III Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
Object Oriented Analysis and Design Chapter 1 Applying UML and Patterns -Craig Larman.
PowerPoint Presentation for Dennis, Wixom & Tegardem Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Georgia Institute of Technology Introduction to Programming Part 1 Barb Ericson Georgia Institute of Technology Aug 2005.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Georgia Institute of Technology Comic Strip Analysis and Design Inheritance, Abstract Classes, and Polymorphism part1 Barb Ericson Georgia Institute of.
DOMAIN MODEL—PART 2: ATTRIBUTES BTS430 Systems Analysis and Design using UML.
Object Oriented Analysis & Design By Rashid Mahmood.
Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1.
Star UML and CRC Cards Pepper.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
CRC Cards: Overview Emerson Murphy-Hill Creative Commons Attribution 4.0 License. Material Produced by NCSU Software Engineering Faculty.
Diving Into Spending Plans!
Diving Into Spending Plans!
TCSS 305 (Stepp) OO Design with UML Class Diagrams
Chapter 11: Collaboration Diagram - PART1
Lecture on Design Phase and UML Class Diagrams
Object-Oriented Analysis
Barb Ericson Georgia Institute of Technology Oct 2005
Diving Into Spending Plans!
Diving Into Spending Plans!
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Understanding Objects and Classes Barb Ericson ericson@cc.gatech.edu Jan 2005 Georgia Institute of Technology

Georgia Institute of Technology Learning Goals What does object-oriented mean? What are objects? What are classes? Exercises for conceptually understanding objects and classes Scenarios Role-playing Georgia Institute of Technology

What is Object-Oriented? This means that we focus on the objects not just the procedures Focus on who (what objects?) as well as what (what do the objects do?) This contrasts with procedural programming in which we focus on the task that needs to be done. You may break that task up into smaller parts. In object-oriented programming we need to know who (what class) as well as what (procedures). Object-oriented programming is concerned with responsibility. Who (what object) is responsible for doing the job, not just what jobs need to be done. Georgia Institute of Technology

Georgia Institute of Technology What is an Object? A person, place, or thing That knows something about itself Has data (attributes, fields) A cashier has a id, name, and a password And can do something Has operations (methods) A cashier can total the items, take payment, make change Point out objects in the room (like a book, pen, computer, person, etc). Talk about what type of object it is, what data it has, what it can do. The picture is a cashier in a music store. The data is his name and password. The operations are how to “ring up” and “take payment”, and “make change”. Georgia Institute of Technology

Georgia Institute of Technology What is a Class? The type of an object The way we classify an object “The Idiot” by Dostoevsky is a book “War and Peace” by Tolstoy is a book Mary is a cashier Tasha is a cashier Grouping of objects with the same data and operations Objects are instances of a class. This slides shows two book objects of the class book. Georgia Institute of Technology

Georgia Institute of Technology Class: Example Mary is a cashier Tasha is a cashier Cashier is a class All cashiers have an id, name and password Each will have a different id, name, and password All cashiers can total an order, take payment, make change Georgia Institute of Technology

Georgia Institute of Technology Object Data Each object has its own data Tasha’s id is 4 and password is mhall Mary’s id is 3 and password is smile4 All cashier objects have an id, name, and password Changing Mary’s data won’t affect Tasha’s data Object data is also called instance variables, object variables, and object fields. Georgia Institute of Technology

Understanding Objects and Classes What “types” of objects are in the classroom? What data is known about each type and what operations can objects of that type do? Are there several objects of the same “type”. How are they the same and how different? There are probably computers in your room. What do we mean by a “computer”? What data does it have (manufacturer, size screen, size memory, etc). What can it do? Point out that nobody had to tell the students that these where computers. How did they know? They fit their idea of what a computer looks like. Georgia Institute of Technology

Georgia Institute of Technology Simulation Object-oriented development means creating a simulation of the problem We need to know the objects in the problem So we can create software objects to represent them We can’t put the “real” objects into the computer so we need to make software objects that represent the “real” objects. Georgia Institute of Technology

Classes Define the Objects The computer doesn’t know what we mean by a car or cashier We define the class Cashier so that the computer will understand what a cashier or bank account “is” and what it can “do” In the context of the problem we are trying to solve Then the computer can create objects to do the simulation Georgia Institute of Technology

Classes Create Objects The class can be thought of as a recipe, blueprint, or factory Many objects can be created from one class Objects keep track of the class that created them I am an object (instance) of the Cookie class When you create an object it has a reference to the object that represent the class that created it. So, objects always know what type (class) they are. Georgia Institute of Technology

Software Objects are Models The objects we create in software are models of the physical object We can’t stick a person in our software We can create a model of the person with the information we need to know for that person for our task Cashier id name password Georgia Institute of Technology

Using Scenarios to Identify Objects What objects are involved in going to the doctor because you are sick? What objects are involved in going to the movies? What objects are involved in a card game like blackjack? Ask people to walk through each of these scenarios. Then go back and see what objects they talk about or use. Bring a deck of cards with you and have two or more people play blackjack. Georgia Institute of Technology

Objects have Responsibilities An object-oriented design Determines the tasks to be done Determines what objects will be responsible for each task No one object does everything Objects work together to accomplish tasks The assignment of responsibilities is the key skill in object-oriented design Georgia Institute of Technology

Georgia Institute of Technology Identifying Classes What type of thing was each thing in the scenario? How would you classify it? Patient, Doctor, Nurse, Insurance … Movie, Ticket Seller, Ticket Taker, Ticket, Popcorn, Drink … Card, Deck, Player, Suit … How many objects of that types were in each scenario? What data did each object have associated with it? What could it do? What type of thing is each item? For example popcorn is a type of food (or snack). For each snack we would need to know at least the name and price. Georgia Institute of Technology

Learning about Objects and Classes Walk through scenarios Do role-playing Underline nouns in scenarios to identify the objects and classes Create CRC cards Draw UML diagrams Write methods and classes Specialize a parent class Use a debugger to step through execution Georgia Institute of Technology

Role Playing Exercises Page at http://web.sbu.edu/cs/dlevine/RolePlay/roleplay.html has links to exercises Powerpoint slides you can hand out developed by Joseph Bergin of Pace University FirstDayRolePlay-Bergin.ppt Georgia Institute of Technology

Georgia Institute of Technology Summary Object-oriented programs are simulations Objects simulate the “real world” and interact to accomplish a task Classes define the data all objects will have and what things they can do Ways to start understanding Objects and Classes Scenarios Role-Playing Georgia Institute of Technology