infsy 535. small systems larger systems 1.understand the program requirement- what 3. write and...
DESCRIPTION
1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify the solution- how Model/design (UML comes into play) Analysis I/O is critical implementation Planning, design, and testing deploymentTRANSCRIPT
Designing a Java ProgramPrinciples of Software Engineering
INFSY 535
Systems Small systems
Larger systems
1. Understand the program requirement-what
3. Write and test each part (unit testing) 4. Maintenance
2. Specify the solution-how
Model/design(UML comes into play)
AnalysisI/O is critical
implementation
Planning, design, and testing
deployment
The Waterfall Model
what
how
Write
The Spiral Model : deals with errors from previous phase (Boehm)
• Development process methodology by the inventors of UML
Rational Unified Process
• Focuses on best practices • Realistic planning Continuous integration• Small releases 40-hour week• Metaphor on-site customer• Simplicity coding standards• Testing • Refactoring • Pair programming • Collective ownership
Extreme Programming
Big Java by Cay Horstmann Copyright © 2008 by John Wiley
& Sons. All rights reserved.
• Interaction of a black box with outside world is well-defined
• Encapsulation
Levels of Abstraction: Black Box
Java Class Concept
Encapsulation◦ Blackbox concept
Data and method(s)Hidden details
Interface Effect(s)
methods called
class
Behavior of bank account (abstraction): • deposit money • withdraw money • get balance
A Class Example (from Chapter 3)
Methods of BankAccount class: • deposit • withdraw • getBalance
Support method calls such as the following: harrysChecking.deposit(2000); harrysChecking.withdraw(500); System.out.println(harrysChecking.getBalance());
Specifying the public Interface of a Class
access specifier (such as public) return type (such as String or void) method name (such as deposit) Parameters list (double amount, double deposit) method body { }
Public Interface of a Class or Method Definition
accessSpecifier returnType methodName(parameterType parameterName, . . .)
{ method body
}
Method Definition Format
Example:public void deposit(double amount) { . . . }
Method Definition Example
public BankAccount(){ // body--filled in later
Public Interface of a Class: Constructor Definition
Javadoc Method Summary
Model/design/represent the solution?
Show class relationships
UML Class Diagrams
Components of the UML
Class Diagram Object Diagram Use Case Diagram State Diagram Sequence Diagram Activity Diagram Collaboration Diagram Component Diagram Deployment Diagram
UML:Universal Modeling Language
Rectangles Three sections:
◦Class/object name ◦Class attributes (data)◦Operations (methods)
Arrows that indicates the relationship
Class Name
Attributes/ characteristics:variables
Methods/capabilities
Class Diagram with Variables and Methods
Visibility: private - public + (chapter 3)
Using VISIO 2007 to Produce UML Diagrams
Click on VISIO Select the Software Category
Visio Tutorial
Visio Lab
InheritanceAggregationDependency
Relationships Between Classes
Preparation:◦Verbally describe the situation (what)
◦(How) Find objects (methods) that will be part of model
Describe properties of the objects Establish relations between the objects
Place the objects in groups
UML Class Diagrams
Java facilitates working with Objects
Terminology: Objects are abstractions
Objects are manipulated by classes
• May be 1 or many class instances of any particular class/object.
• Each instance is instantiated.
Relationship Symbol Line Style
Arrow Tip
Inheritance-is-a
Solid Triangle
Interface Implementation
Dotted Triangle
Aggregation-has-a
Solid Diamond
Dependency
Dotted Open
UML Relationship Symbols
Aggregation is a stronger form of dependency-see page 467
has-a relationship
Establishes has-a relationship/association between classes BankAccount One can navigate from one class to another instantiation in Java – (note NOT inheritance)
Aggregation arrows
Arrow with diamond head: one class uses the other by linking methods of the other class. The arrow indicates the direction of the aggregation
dependency
Multiplicity (Cardinality)
• Place multiplicity notations near the ends of an association.
Lab and HomeWork
Program Exercises P3.1 and P3.2
Inheritance Inheritance : allows a
developer to derive a new class from an existing one
Parent class, or superclass, or base class.
Thechild class or subclass. Component hierarchy:
Inheritance-generalization
Establishes an is-a relationship between a more general class (superclass) and a more specialized class (subclass or base class)
Inheritance
Inheritance should create an is-a relationship, meaning the child is a more specific version of the parent
Deposit
BankForm parentIs-a component of
child