SE450: Lecture 2 (The UML, Object Oriented Development, Intro to Patterns)

Contents [0/18]

Overview of Today's Class [1/18]
An Example Homework Solution [2/18]
Java Collections: Overview [3/18]
Software Development [4/18]
Software Development: Desired qualities [5/18]
Incremental/Iterative Development [6/18]
Rational Unified Process [7/18]
eXtreme Programming [8/18]
UML [9/18]
UML: Tools [10/18]
UML: Why? [11/18]
Use Cases [12/18]
UML Class Diagrams: Basics [13/18]
UML Class Diagrams: Classes [14/18]
UML Class Diagrams: Relationships [15/18]
CRC Cards [16/18]
Package Diagrams [17/18]
Homework [18/18]

Overview of Today's Class [1/18]

Review Homework assignment

Introduction to the UML.

CRC Cards

Development Methodologies

More 00/Java

Homework Assignment #2

An Example Homework Solution [2/18]

So...here's one possible solution.

MyFavoritePoem.java

If you had trouble with this homework, you need to evaluate whether you can handle the workload in this class. If you know what you need to learn, you can learn it, but the Java details will not be covered in this class (at least not continually).

If the homework was trivial, you have a good grasp of the Java command line tools and your OS. You should be able to move onto the advanced topics right away.

If you struggled a bit (it happens to everyone) but knew how to find the answer in the documentation, then expect to have to do that every week in the homework assignment. But you will need to add a couple orders of magnitude into the complexity over the course of the quarter

Java Collections: Overview [3/18]

Bags - a.k.a MultiSets. This is a Collection in Java

Sets - unorderd collection. This is a Set or SortedSet in Java

Lists - ordered collection - This is a List in Java

Map - unordered collection of key/value pairs. This is a Map or SortedMap in Java.

Iterator - allows traversal of a Collection

Software Development [4/18]

Software Development usually involves:

In the waterfall process, these were just done in big blocks, one at a time

waterfall

Software Development: Desired qualities [5/18]

Usefulness

Timeliness

Reliability

Maintainability

Reusability

User Friendliness

Efficiency

Incremental/Iterative Development [6/18]

When doing OO development, it has become clear over the years that the old style of waterfall life-cycle development consisting of analysis, design, and construction doesn't work (but companies companies continue to use it anyway).

This doesn't mean uncontrolled development with no planning

Instead, each increment of the system builds a subset of the entire system. An increment includes

Before the first increment is executed, an exploration phase is entered. This phase consists of

How long should each iteration be? Some say as little as 2-3 weeks (XP) whereas many say 2-3 months. It depends on the project and the developers. For this class, it will need to be 1-2 weeks for the project so that enough iterations can be completed before the project is due.

Increments should always start with the hardest parts first. A usable product should be delivered to the user as soon as possible.

The increments will need to be testable. This can assure whether or not the requirements and project plan is being met.

Rational Unified Process [7/18]

The Rational Unified Process is a process that was developed by Rational Software. They define it and sell it as a product that integrates with other tools that they sell, but the process can be used separately from the tool.

The key practices of RUP are:

There are 9 models

  1. Business
  2. Domain
  3. Use Case
  4. Analysis
  5. Design
  6. Process
  7. Deployment
  8. Implementation
  9. Test

There are 9 process workflows

  1. Business modeling
  2. Requirements
  3. Analysis and Design
  4. Implementation
  5. Test
  6. Deployment
  7. Configuration Management
  8. Project Management
  9. Environment

There are 4 phases to RUP:

The last three phases may contain multiple iterations.

Certain documents are maintained throughout the project:

Rational Unified Process

eXtreme Programming [8/18]

"Extreme Programming is a discipline of software development based on values of simplicity, communication, feedback, and courage. It works by bringing the whole team together in the presence of simple practices, with enough feedback to enable the team to see where they are and to tune the practices to their unique situation."

There are 13 core practices in XP.

  1. Whole Team: XP centers around the "whole team", with the customer being the business representative who sits with the team daily.
  2. Planning Game: The customer presents the desired features to the programmers, they estimate how long it takes to complete. The customer then plans what goes in the release. An iteration is performed every 1-2 weeks, and the programmers present to the customer what they can complete. The customer decides what goes in each iteration. Each iteration is a working version of the code.
  3. Customer Tests: The customer defines tests that prove to them that the system is working. The programmers write these and run them (they are automated) to prove the release is working.
  4. Small Releases: Every iteration works. The team also releases to the end users frequently.
  5. Simple Design: Design is continual, not just up front. Through unit testing and refactoring, the design is kept simple and improved continually.
  6. Pair Programming: Programming takes place in pairs. Improves code, communication, and training.
  7. Test-driven Development: Write tests first. Run them before code is checked in, and every time it is updated. Here is an excellent example of this.
  8. Design Improvement: Code is refactored. Increase cohesion, lower coupling. We'll look at some refactoring examples soon.
  9. Continuous Integration: Multiple builds a day. Cuts down on integration problems.
  10. Collective Code Ownership: Everyone owns all the code. Anyone can change any code. Prevents programmers from putting functionality in the wrong place.
  11. Coding Standard: Team follows a common coding standard
  12. Metaphor: A common description of the program, and a common system of names. Everyone should understand how the system works and where the code should go for new features.
  13. Sustainable Pace: Minimize overtime. In general, this means no overtime two weeks in a row. (40 hour work week)
eXtreme Programming

UML [9/18]

The Unified Modeling Language is the successor to a number of Object-Oriented analysis and design (OOA&D) languages

The UML is a language, not a development methodology (we'll talk about methodologies later). It is a language for visualizing, specifying, constructing, and documenting.

OO Modeling languages started to appear in the late '70s and early '80s, with more than 50 approaches in the early '90s

Mostly a combination of the work of Booch, Rumbaugh, and Jacobson (the three amigos)

Three goals stated for the UML

  1. To model systems, from concept to executable artifact, using OO techniques
  2. To address the issue of scale inherent in compolex, mission-critical systems
  3. To create a modeling language usable by both humans and machines

By the later '90s, most notable software tool vendords had adopted the UML as their OO modeling language

UML maintenance (of the specification) is now under the control of the Object Management Group (OMG)

UML: Tools [10/18]

What about tools for UML?

Most companies select a UML tool that integrates with their IDE and programming languages

Unfortunately, most of these are fairly complex and expensive. However, in the past few years, a number of free versions, and open source versions, have come available. There is a list at http://www.objectsbydesign.com/tools/umltools_byCompany.html that you might find helpful. Unfortunately, I don't have time to review any of the tools or give you support on using them, but you are encouraged to try some of them. I will always accept drawings by hand for the final project (assuming they are legible and correct).

I have tried Posieden and ESS-Model. You may find others more (or less) helpful. Some of the non-free versions have limited time versions that might work for this class.

Newer versions of Visio support most of the UML diagrams, but will not support reverse engineering of code (from non Microsoft tools).

UML: Why? [11/18]

Importance and Principles(from The Unified Modeling Language User Guide, by Booch, Rumbaugh, and Jacobson):

Importance

Models help us:

  1. Visualize the system as it is or we want it to be
  2. Permit us to specify the structure or behavior of a system
  3. Give us a template that guies us in constructing a system
  4. Document the decisions (usually design decisions) that we have made

You need models for larger systems because you cannot comprehend the system in its entirety

Principles of Modeling

  1. The choice of what models are created has a profound influence on how a problem is attacked and how a solution is formed.
  2. Every model may be expressed at different levels of precision This one is important for you to remember when working on your project
  3. The best models are connected to reality
  4. No single model is sufficient

Use Cases [12/18]

Use Cases exist to capture the intended behavior of a system without having to specify how the behavior is implemented. They are very good for specifying user requirements, and for developing good user acceptance tests

Example: p 45-46

Scenario: a sequence of steps describing an interaction between a user and the software system.

Use Case: a set of scenarios that meet a common user goal. Each use case has a name as well.

Use cases are written out as a series of Main Success Scenarios (Main flow of events), and a set of alternative Scenarios (Exceptional flow of events)

Use cases describe what not how

Use cases can be diagrammed using UML. They consist of actors (users of the system) and the use cases that they interact with. The actors carry out the use case.

Use cases can use inclusion and extension. Both of these cases help you save time writing and diagramming. This is similar to generalization, but it limits the generalization to only certain extension points. It is a special case.

For use cases c1 and c2

UML Class Diagrams: Basics [13/18]

Three perspectives

Conceptual - not a direct mapping to classes. Generally is language independent.

Specification - Interfaces, not the implementation. Types rather than classes.

Implementation - lays the entire thing bare.


Shows classes, interfaces, and their relationships (collaborations, generalizations, associations, and dependencies)

UML Class Diagrams: Classes [14/18]

Notation:

Top is the class name (required)

Fields (attributes in UML) in the middle. Two types of syntax: Java or UML.

Java Syntax: [Visibility] [Type] Name [[Multiplicity]] [= Initial Value]

UML Syntax: [Visibility] Name [[Multiplicity]] [:Type] [= Initial Value]

Methods (operations in UML) on the bottom. Two types of syntax: Java or UML.

Java Syntax: [Visibility] [Type] Name ([Parameter,...])

UML Syntax: [Visibility] Name ([Parameter,...]) [:Type]

Visibility can be one of

Parameters in UML are given Name:Type, in Java Type Name

Class Diagrams can be given in abbreviated forms

Static is indicated by underlining the method

Stereotypes are used to extend the UML. It is like an adjective to describe a core UML type and make it better understood when there is not UML type to describe exactly the role you are assigning a part of your model

Interfaces are drawn as a stereotype of a class (older versions will show a circle)

Constructors can be distinguished from other methods by using a Constructor stereotype

Ellipsis (...) are used to show that more methods or variables exist that aren't shown

UML Class Diagrams: Relationships [15/18]

Relationships

Association - relationships between instances of Types.

Aggregation

Composition


Generalization (Specialization)


Dependency - dashed arrow with open arrowhead


Constraint Rules

UML uses { } to show contraints.

Design By Contract and assertions will be used to enforce contraints. This is native to languages like Eiffel. We'll talk more about this later.

Examples: p 31,33,35

CRC Cards [16/18]

CRC (Class-Responsibility-Collaboration)

On a 4x6 card, write Class

Responsibility = summary of attributes and methods. A high level description of the purpose of the class.

Collaborations = classes needed by this class to fulfull its resonsibilities.

Very informal. Meant to promote discussion. Use with Class and Interaction diagrams.

Package Diagrams [17/18]

Used for larger systems to show dependencies between packages.

Packages dependencies are not transitive.

The goal is to keep dependencies to a minimum.

Note: Java's package import statement can be easily broken. Dependencies could exist that you don't see in the import statements.

Example: p 26

Homework [18/18]

Read Jia Chapters 4 and 5. Pay special attention to the StringTokenizer, the BufferedReader, and the FileReader as you read chapter 4.

Read pages 1-23 of Principles and Patterns by Robert Martin.


Goal: Learn more of the Java APIs. Practice writing more code, debugging, and using multiple source files. Develop some base code for further homework assignments. Improve practices from first homework assignment.

Assume that you have a file of flight records. It is a text file in which each line contains a single record, and each record consists of the following colon-delimited fields:

Airline Code: Airplane Type: Flight Number : Departing Airport : Arriving Airport: Time

A sample line is as follows:

ASA:B73Q:144:ORD:SFA:13

Assume that the time is just a whole hour in 24HH format, as an integer. All other records are strings

Write a Java application that will read in a data file from a command line argument and do the following:

Implement the solution in at least two source files, one called se450.studentid.hw2.Main, one called se450.studentid.hw2.Airline, and one called se450.studentid.hw2.Flight. Replace studentid with your DePaul id.

Choose a good container for the flights as you work with them in your code, and use an Iterator when you have to traverse the collection of flights.

The Flight class should contain a reference to the Airline, and store the airport codes and airplane types as Strings. The time should be stored as an Integer.

Override toString to provide a meaningful String representation of the flight.

The program should take one argument, the filename of data, and provide the output for parts (a), (b), and (c) all at once. If you are having trouble with "screen blindness", then redirect the output to a file for offline reading like this: java se450.studentid.hw2.Main flights.txt > output.txt

Ask questions on the discussion board!

Submit a zip file that contains all necessary .java files as well as grader.txt, in the correct package structure, just as last week.

Don't include any class files

Due next Monday at 5:30 PM.


Revised: 2003/1/12