Download presentation
Presentation is loading. Please wait.
Published byTabitha Daniel Modified over 9 years ago
1
CS 432 OOAD Spr 8W1 Session 1
2
Agenda Introductions First night roster Student Rep Course Overview OO Concepts OO SDLC Rational Site Homework I discussion Form Groups
3
Introductions One paragraph on background and interests Contact sheet: Public phone and email if available Meet your neighbor
4
Course Overview Syllabus Project Overview Expectations
5
OO Concepts
6
What’s a class? What’s an object? A class is a “template” for a specific type of objects. –Generally classes generally represent real world objects e.g. (bank account), but also may represent transactions (deposit) –An object is an instance of a class– a member of a class that has a unique identity (e.g. my bank account, the deposit I made yesterday) –Classes have attributes (variable values) that distinguish them from other classes and their instances from each other. –Classes have methods, which allow them to perform tasks for themselves Behavior is what a class is capable of doing, based on the methods at its disposal Class Name: Bank Account Attributes: Owner Account Number Balance Date Established Methods: MakeDeposit ( double amt) MakeWithdrawal (double amt)
7
Can you really inherit class? No, but you can inherit attributes that may or may not be classy! Inheritance: The creation of a new class from an existing superclass The new class is called a subclass or child It “inherits” the attributes and methods from the superclass and can change or add to them CheckingAccount and SavingsAccount are subclasses of BankAccount They inherit all of the attributes and methods from BankAccount (previous slide) They can add their own (next slide) Bank Account Savings Account ? Checking Account ?
8
Inheritance and Subclasses In our hypothetical bank, all accounts have an Owner, Account Number, Balance, and a Date Established. Savings Accounts: The interest rate paid varies based on the current balance. Statements will show all common attributes and the interest rate. Checking Accounts: A penalty is assessed once the balance drops below a minimum value. Statements will show all common attributes and the penalty assessed. Bank Account Savings Account intRate SetIntRate(double balance) printStatement() Checking Account minimumBal SetMinBalance(double minBal) AssessPenalty(double minBal, double balance) printStatement()
9
Object Communications— Messages from Beyond… Objects and classes communicate using messages –Messages are of the form object_being_addressed. method(args) –The message signature must be correct for the method being addressed: JayzDismalCheckingAccount minimumBal SetMinBalance(double minBal) AssessPenalty(double minBal, double balance) printStatement() JayzDismalCheckingAccount.SetMinBalance(5000.00) Here we see the message to set the balance for the JayzDismalCheckingAccount object to $5000.00
10
Polymorphism isn’t a science fiction creature Polymorphism is the ability for different objects to respond differently to the same message. Namely, each object responds appropriately printStatement() SavingsAccountCheckingAccount When a SavingsAccount object is sent a message invoking the PrintStatement() method, it prints out the Owner, Account Number, Balance AND the applicable interest rate When a CheckingAccount object is sent a message invoking the PrintStatement() method, it prints out the Owner, Account Number, Balance AND the applicable penalty
11
Abstraction and Encapsulation NASA Strikes Again???? The general idea here is that to use an object you don’t need to know how it does stuff or anything about its internal variables. –Easier to use. Send it a message that fits the required signature. Why do I care how the SavingsAccount object prints a statement or an Integer object converts a string? –Easier to maintain. If Sun rewrites the conversion routine, it doesn’t affect how I use the conversion routine. Its still Integer.parseInt(arg) to me. Encapsulation: Variables within the object are set using the object’s methods, not accessed directly by outside entities Much more to come…
12
OO Software Lifecycle Requirements analysis –What does the customer need from his perspective? –The system needs to record whenever a part is received at the warehouse? Analysis –How do we do it? What are the primary real world “abstractions”– classes and objects-- we need to work make and work with? What are the mechanisms used in the real world? –The warehouse people unload each pallet, break open each box, count each part by part number. A barcode on each part is available.
13
OO Software Lifecycle (con't) Design –Identifying the objects that make up the solution/ technical infrastructure. –Builds on the analysis and results in the detailed specs for the construction phase. –User interface that allows for entry of the number of each item, manually or using a barcode reader. For each shipment, if a part is entered at several different times the numbers will be combined into a single entry in the receiving record.
14
OO Software Lifecycle (con't) Construction/Implementation –Writing the code using an OO programming language Test –Unit tests– does each piece of code meet its spec? –Integration test- doe the pieces of code work together? –System test- does the system meet the users needs as identified in the spec/model? –Acceptance test- does it really do the job?
15
OO Software Lifecycle (con't) Verification- Am I building the right product? Validation- Am I building the product right? Prototyping- a version of product developed early on to demonstrate or experiment with a concept (e.g. a user interface) –Generally not complete functionality, throw away –User may view the job "almost done" –Types: Horizonal- I/F no functionality Vertical- Narrow focus to test a specific funciton Analysis- Proof of concept Domain- Incremental part of a final product –RAD –Component Based Development
16
Extra- OO Concepts Object Basics What is an object? –"…a real-world entity, identifiably separate from its surroundings." –"… a combination of data and logic that represents a real world entity Data = attributes, properties, fields Logic = methods, functions Behavior = "…the collection of methods that abstractly describes what an object is capable of doing." –An object is a uniquely identifiable entity (i.e. you).
17
Extra-OO Concepts Object Basics con't An Object is an instance of a Class A class –"…is a set of objects that share a common structure and a common behavior" –can be thought of as "an object template" The me object is an instance of the human class –Attributes that are common to humans/ set us apart from other species or things? set us apart from each other? –Methods that are common to humans/ set us apart from other species or things? set us apart from each other?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.