CS212: Object Oriented Analysis and Design Lecture 4: Objects and Classes - I.

Slides:



Advertisements
Similar presentations
ACM/JETT Workshop - August 4-5, :Design of Classes using CRC cards.
Advertisements

GCSE ICT By the end of this session, you will be able to: Explain main features of ATM machines Identify features of credit cards, debit cards, smart cards.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
ATM Case Study A Discussion.
CPSC 333: Foundations of Software EngineeringJ. Denzinger Small Test: Bank account manager System has to run on an automated teller machine. User must.
Lecture 8 Electronic Commerce Modelling Techniques
Sequence Diagrams. Introduction A Sequence diagram depicts the sequence of actions that occur in a system. The invocation of methods in each object, and.
Chapter 12 ATM Case Study, Part 1: Object-Oriented Design with the UML
 2009 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CS-2135 Object Oriented Programming
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes and Objects Systems Programming.
 2008 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 11: Classes and Data Abstraction
Software Engineering Principles and C++ Classes
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
ACM/JETT Workshop - August 4-5, Object-Oriented Basics & Design.
 2009 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Using Classes Object-Oriented Programming Using C++ Second Edition 5.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
1 CSC103: Introduction to Computer and Programming Lecture No 13.
You gotta be cool. Introduction to Classes, Objects and Strings Introduction Defining a Class with a Member Function Defining a Member Function with a.
1.  A method describes the internal mechanisms that actually perform its tasks  A class is used to house (among other things) a method ◦ A class that.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
ICT and Banks Banks use mainframe computers to maintain customer accounts. They store a record of each customer’s withdrawals and deposits. Each bank mainframe.
SFWR ENG 3KO4 Software Development Fall 2009 Instructor: Dr. Kamran Sartipi Software Requirement Specification (SRS) for the Automated Banking Machine.
CS212: Object Oriented Analysis and Design Lecture 5: Classes and Objects - II.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Rational Requirements Management with Use Cases v5.5 Copyright © Rational Software, all rights reserved 1 Requirements Management with Use Cases.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Lecture OO05 Object Scenarios Object Interaction Diagrams
Chapter 4 Introduction to Classes, Objects, Methods and strings
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Chapter 3 (B) 3.5 – 3.7.  Variables declared in a function definition’s body are known as local variables and can be used only from the line of their.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
CS212: Object Oriented Analysis and Design Lecture 32: Use case and Class diagrams.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
計算機程式語言 Lecture 03-1 國立台灣大學生物機電系 林達德 3 3 Introduction to Classes and Objects.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Chapter 3 Part II. 3.8 Placing a Class in a Separate File for Reusability.cpp file is known as a source-code file. Header files ◦ Separate files in which.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 6 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
CLASSES AND OBJECTS Chapter 3 : constructor, Separate files, validating data.
© 2004 Pearson Addison-Wesley. All rights reserved3-1 Objects Declaration: String title;  title (object variable) of type String( Class )  title is just.
Inf 43: Introduction to Software Engineering May 7, 2016.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Introduction What would our society be like now if we did not have ATm’s? Not able to access money when we urgently want it. You will have to go to the.
Unified Modeling Language (UML)
Introduction to Classes and Objects
Introduction to Classes and Objects
CS212: Object Oriented Analysis and Design
Introduction to Classes and Objects
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
Classes, Objects, Methods and Strings
Object Oriented Programming in java
Introduction to Classes and Objects
Lecture 8 Object Oriented Programming (OOP)
Classes and Objects Systems Programming.
Introduction to Classes and Objects
Presentation transcript:

CS212: Object Oriented Analysis and Design Lecture 4: Objects and Classes - I

Recap to Lecture 3 Introduction to objects and classes Identification of classes and object Class Responsibility and Collaboration

3 A CRC card: SnackItem Class name: SnackItem ResponsibilityCollaborator Knows its price and calories

A CRC card: Vending Machine 4 Class name: VendingMachine ResponsibilityCollaborator Maintains a collection of SnackItems. Allows addition and removal of SnackItems

The Advantages of CRC Model The experts do the analysis User participation increased. Breaks down communication barriers It’s simple and straightforward It’s non-threatening to users It’s inexpensive and portable It goes hand-in-hand with prototyping It leads directly into class diagramming

Disadvantages It’s threatening to some developers It’s hard to get users together CRC cards are limited

Case study 2: ATM An Automated Teller Machine (ATM) allows bank customers to perform a number of financial transactions: to withdraw and deposit funds to an account, query the balance of any account. The ATM offers an user interface with a display screen, keypad, cash dispenser, deposit slot and a card reader. Once a customer’s card is verified, the customer can query to see the balance in all her account (s), deposit, withdraw or transfer money from one account into another.

Case study 2: ATM An Automated Teller Machine (ATM) allows bank customers to perform a number of financial transactions: to withdraw and deposit funds to an account, query the balance of any account. The ATM offers an user interface with a display screen, keypad, cash dispenser, deposit slot and a card reader. Once a customer’s card is verified, the customer can query to see the balance in all her account (s), deposit, withdraw or transfer money from one account into another.

Example: GradeBook A gradebook is one which an instructor uses to keep student test score.

Creating the blue print in C++ Defining a class Access specifier Function header

Executing the blue print

Data Members, get and set functions Attributes are represented as variables – data members Each object of a class maintains its own copy of attributes in memory Get function: used to obtain the value of a member variable, e.g. getStudentName(int id) Set function: used to assign a value to a member variable, e.g. setStudentName(string sName) mutators accessors

Access Specifiers PublicPrivateProtected Class members declared under public will be available to everyone No one can access the class members declared private outside that class. It makes class member inaccessible outside the class, except its subclass. Access specifiers in C++ class defines the access control rules.

Best practices Data members to be declared as private Member functions to be declared as public Access specifiers must not be mixed Explicit use of access specifiers Easy to localize the error while debugging

Software engineering with get and set function Private access specifier facilitates data hiding Public set and get function allows clients to access data, but not indirectly Class may store data in one way, however shows to the client in a different way Get and set function helps the client to interact with the object The private data member remains safely encapsulated

Reusability When packaged properly, classes can be reused by programmers Function ‘int main(void)’ already has a body Redefinition of ‘int main()’ Placing the main in the same file where the class is defined prevents reuse Use of header files

Software engineering issues The entire implementation of the class is revealed to the clients To access object of a class, client should only know, Which function to call What are the parameters to be passes What is the expected return type How the function is implemented is not important to the client

Class Interface Header files supports reusability Interface defines and standardize the way in which things such as people and system interacts with each other Interface of a class defines what services a client can use and how to request those services However, NOT how the class carry out those services A classes interface consists of the public member functions

Separating Interface from Implementation It is better software engineering to define member functions outside the class definition Their implementation can be hidden from the clients code This practice ensures that programmers do not write client code that depends on the class’s implementation

Thank you Next Lecture: Classes and Object - II