infsy 535. small systems larger systems 1.understand the program requirement- what 3. write and...

35
Designing a Java Program Principles of Software Engineering INFSY 535

Upload: jade-leonard

Post on 08-Jan-2018

214 views

Category:

Documents


0 download

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 deployment

TRANSCRIPT

Page 1: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Designing a Java ProgramPrinciples of Software Engineering

INFSY 535

Page 2: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Systems Small systems

Larger systems

Page 3: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 4: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

The Waterfall Model

what

how

Write

Page 5: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

The Spiral Model : deals with errors from previous phase (Boehm)

Page 6: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

• Development process methodology by the inventors of UML

Rational Unified Process

Page 7: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

• 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

Page 8: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 9: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Java Class Concept

Encapsulation◦ Blackbox concept

Data and method(s)Hidden details

Interface Effect(s)

methods called

class

Page 10: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Behavior of bank account (abstraction): • deposit money • withdraw money • get balance

A Class Example (from Chapter 3)

Page 11: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 12: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 13: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

accessSpecifier returnType methodName(parameterType parameterName, . . .)

{ method body

}

Method Definition Format

Page 14: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Example:public void deposit(double amount) { . . . }

Method Definition Example

Page 15: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

public BankAccount(){ // body--filled in later

Public Interface of a Class: Constructor Definition

Page 16: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Javadoc Method Summary

Page 17: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Model/design/represent the solution?

Show class relationships

UML Class Diagrams

Page 18: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Components of the UML

Class Diagram Object Diagram Use Case Diagram State Diagram Sequence Diagram Activity Diagram Collaboration Diagram Component Diagram Deployment Diagram

Page 19: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

UML:Universal Modeling Language

Rectangles Three sections:

◦Class/object name ◦Class attributes (data)◦Operations (methods)

Arrows that indicates the relationship

Page 20: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Class Name

Attributes/ characteristics:variables

Methods/capabilities

Class Diagram with Variables and Methods

Visibility: private - public + (chapter 3)

Page 21: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Using VISIO 2007 to Produce UML Diagrams

Click on VISIO Select the Software Category

Page 22: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Visio Tutorial

Visio Lab

Page 23: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

InheritanceAggregationDependency

Relationships Between Classes

Page 24: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 25: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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.

Page 26: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 27: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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)

Page 28: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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

Page 29: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

dependency

Page 30: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Multiplicity (Cardinality)

• Place multiplicity notations near the ends of an association.

Page 31: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

                                                                                                                            

Page 32: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Lab and HomeWork

Program Exercises P3.1 and P3.2

Page 33: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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:

Page 34: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

Inheritance-generalization

Establishes an is-a relationship between a more general class (superclass) and a more specialized class (subclass or base class)

Page 35: INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify

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