Title: http:www.cs.bgu.ac.iloosd042
1????? ????? ????? ?????
- ???? 2004
- http//www.cs.bgu.ac.il/oosd042
2??????
- UML
- Application Frameworks
- The GUI framework
- Design patterns
- Designing concurrent objects
- Designing components
- Applets and Servlets
3???? ?????
- 4 ????? ????
- 40
- ???? ????
- 60
- ??? ????? ?? ????? ?? ???? ???? ???? ??? ??????
?????? ?????.
4?????
- Xiaoping Jia Object-oriented software design
in Java , Addison-Wesley, 2000. - P. Stevens Using UML , Pearson Education,
2000.
5Object Oriented Concepts
6Evaluating Systems
- Dependency
- Module A depends on module B if a change in B may
cause a change in A. - Module A is a client of module B.
- Module B is a server of module A.
- Note that circular dependency may exist
7Evaluating Systems (cont)
- Coupling
- Dependency is sometimes known as coupling.
- High coupling A system with many dependencies.
- A good system has low coupling changes in one
part are less likely to propagate.
8Evaluating Systems (cont)
- Encapsulation low coupling
- Interface
- encapsulate knowledge about the module.
- Syntactic aspects of dependency
- Semantic dependency
- The module specification what clients can assume.
9Evaluating Systems (cont)
- Abstraction high cohesion
- When a client doesnt need to know more than the
interface. - (Encapsulation is when the client isnt able to
know)
10Components
- A unit of reuse and replacement.
- Pluggable.
11Objects
12What is an object?
- A thing you interact with.
- Send messages to an object (method).
- The object react to messages.
- An object behaves according to its internal
state. - State the data the object encapsulates.
- Attributes.
- Behavior
- The way an object acts and reacts in terms of
message passing and state changes. - Identity (name)
13The Object (public) Interface
- Defines the messages an object can accept.
- An object also have an internal (private)
interface. - An object may send messages to itself.
14Classes?!
- A class describe a set of object with an
equivalent role. - Defines
- Methods
- Attributes
- Creating a new object of a class is called
instantiating. The result is an instance. - A class is considered an object factory.
- Why classes?
- Write once.
- Single copy of the code (multiple data).
15Inheritance
- Objects
- Lecturer
- DirectorOfStudies (a special type of lecturer)
- DirectorOfStudies is a subclass (extension) of
Lecturer. - It can
- Override methods or attributes
- Inherit methods of the super class.
- Have new methods.
16Polymorphism and Dynamic Binding
- Polymorphism An entity may have several types
(super class, subclass or interface). - Binding is identifying the code to execute as a
result of a message. - Dynamic? because at runtime we need to find the
actual type of the object.
17UML
- Unified Modeling Language
18An Object
- First we need to identify the objects in the
system. - Object has a name, attributes and operations.
19Object Associations
- Called links (between objects)
- Class A and class B are associated if
- An object of A sends a message to an object of B.
- An object of A creates an object of B.
- An object of A has an attribute that is a value
of B. - An object of A receives a message with an object
of B as an argument.
20Object Hierarchy (generalization)
- A shop is selling
- Books
- Music CDs
- Software
- All the above are Item.
- An arrow representgeneralization.
Item title publisher yearPublished ISDB price
Book author edition volume
MusicCD artist volume
Software version
21Object Hierarchy (generalization)
- Inheritance is an implementation of
generalization. - Example Item and Book
- Book is a subclass of Item
- Consider the following
- Example List and AddressBook
- Q Should AddressBook extends List? or should
List be an attribute in AddressBook.
22Aggregation and Composition
- Open diamond describe aggregation when an
object is part of (and may be part of others). - Composition when the whole strongly owns its
part. (denoted by a filled diamond)
The numbers on the sides of the line denotes
occurrences.
ItemOrder item quantity
0..
ShoppingCart
23Example (of associations)
24Example Singleton class
- public class Singleton
-
- public static Singleton getInstance()
- if ( _theInstance null )
- _theInstance new Singleton()
-
- return _theInstance
-
- protected Singleton()
- // .....
-
- //
- // .... methods ....
- //
- private static Singleton _theInstance null
-
Singleton static Singleton _theInstance static
getInstance() Singleton operation()
void getData() int
25Use Case Models
- Documents the system behavior from the users
points of view. - It helps with
- Finding requirements.
- Validating systems.
- Planning development iterations.
- An actor is a users of the system
26Example Use Case in A Library
27Sequence Diagrams
- Shows both actors and objects that take place in
a behavior of the system. - Describes the sequence of state changes (and
therefore, behavior) of the code (and not data or
objects). - Resembles finite automates.
28Example Borrow a Book
29Message Sending Options
30State Diagrams
- Describe how to model the object decision as a
result of a message. - Example A state diagram of a Copy (of book)
- A copy has an attribute
- onShelf Boolean
- values on load / on the shelf
Initial State
31State Diagram (cont)
- States as boxes
- Transitions as arrows
- Events are shown as messages on the arrows
- Start marker is a black blob
32State Diagram (cont)
- Adding actions (as a result of messages)
- Actions (after the /) shows what action is
taken after the event. - Actions may be written as entry actions inside
the state box (or exit actions). - Useful when many transitions leads to a state.
33State Diagram (cont)
- Guards - adding conditions to events
- A book (with many copies) can (or cant) be
borrowed.
If last copy then change state