(Previous): C++ Classes
[ 07.html ]
Preparation
Study this page and
[ uml0.html ]
(handed out in meeting 07)
and write down the questions,
doubts, and surprises that you have on a piece of paper.
Assigned Work Due
Hand in one question, doubt or surprise with a page number.
Include your printed name!
Quick Demo -- UML on the web
[ search?q=%22Unified+Modeling+Language%22 ]
(5 million items!)
[ images?hl=en&ie=ISO-8859-1&oe=ISO-8859-1&q=UML&gbv=1 ]
(646,00 images).
Quick Exercise on the UML
[ links.png ]
(Dia
[ link.dia ]
model).
Quick Exercise -- Universal Widgets
Write a C++ main program that tests the Widget and Wodget classes
written in the last class
[ 07.html#Quick Exercise ]
Here is the code for the Widget classes
[ widgets.h ]
and my unit tests
[ testWidgets.cpp ]
Input on the UML -- Software Development -- Fruit to Nuts and back
Models: An object-oriented program keeps a simulation model of a
real system outside the computer. We also construct models of
computer software either to help design it, or or to help
understand it.
TBA -- possible CDROM played.
Demo based on
[ applications.2007spring.html ]
Questions
.What arrows are used in the UML
The ones used betweeen classes are here
[ links.png ]
and there are many other in other kinds of diagrams.
I must prepare a cheatsheet.
What about artifacts
Just the name for anything created when developing software.
Use a diagram when it gets complicated -- 10 or more of them.
How do algorithms fit into the UML
They describe how an operation soves a complex problem. A step towards
coding the body of functions.
What is an Algorithm
A precisely defined process for solving a problem -- typically as a
set of terminating steps.
Typically an algorithm is used to design the code inside a function.
As an example: the problem is to find the Student that has a given name.
Here is an algorithm called sequential search:
- Start with the first student
- If it has the right name, exit,
- Else go on to the next student and repeat the previous step.
- But if there are no more students, signal an error.
We will cover lots more of these later.
How do you decide what classes to create and what function to put in them
Good question. There are several answers. I like the one in
[ cs375 ]
which takes a quarter to start to learn:-(
The steps go:
- Analyse the users needs into use cases.
- Analyse use cases into scenarios
- Select an interstin scenario or two to work on.
- Draw a daomian model for the scenarios
- Draw an SSD naming the steps in a scenario as function calls to system
- For each step map out some interactions and objects needed. Use
the domain model to supply names for the classes.
- Collect the operations into a class diagram
- Code the classes, and test them
- Code the us case and test.
- With the user's help plan the next best scenario to tackle.
- Repeat with another scenario, or another usecase.
Who would we draw diagrams for
Your self, your future self, team members, managers, colleagues, the web, job interviewees, teachers,
and (future) your students.
Note --- putting UML diagrams where people can see them
in your office or cubicle, is a lot
more impressive than a picture of your favorite pop star or film actor.
Exercises If Time
Here is the code for some improved WIdget and Wodget classes:
[ widgets2.h ]
and my unit tests
[ testWidgets2.cpp ]
, draw the UML diagram of these classes. What changes have I
made and why did I do them?
Next -- Quiz 2 on chapter 6 thru 9 on Objects and Classes
Demonstrate one or more of these skills
- Given C++ classes draw UML diagram. May have generalization.
- Given UML class with attributes and operations write C++ Class declaration.
- Given small useless classes with inheritance predict what will compile in a program trying to use them.
- Given small useless classes with virtual functions and inheritance and
a program that uses them work out what it outputs. May involve pointers.
- Answer a series of T/F questions about C++ classes and their members
including the following words: inline, public, private, static, friend, virtual, const, this, protected, operator, class.
- Recognize where these words fit: inline, public, private, static, friend, virtual, const, this, protected, operator in a class.
- Complete a set of simple inline constructors for a class.
- Complete one of the common operators as members: +,-,*, ==, [], ...
- Complete one of the common IO operators as friends: << and >>
- Given class declaration and a short test program write/complete a definition for a member function.
Preparation for the quiz
Review this page plus
[ inheritance.html ]
[ polymorphism.html ]
[ abstraction.html ]
[ 05.html ]
[ 06.html ]
[ 07.html ]
[ lab04.html ]
Lab
[ lab04.html ]
TBA
where you will create a safe array class and practice some
of the above skills.