http:www.cs.bgu.ac.iloosd042 - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

http:www.cs.bgu.ac.iloosd042

Description:

Module A depends on module B if a change in B may cause a change in A. ... Start marker is a black blob. State Diagram (cont) Adding actions (as a result of messages) ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 34
Provided by: NEW94
Category:
Tags: bgu | blob | http | iloosd042 | www

less

Transcript and Presenter's Notes

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.

5
Object Oriented Concepts
  • Refresh Course

6
Evaluating 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

7
Evaluating 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.

8
Evaluating Systems (cont)
  • Encapsulation low coupling
  • Interface
  • encapsulate knowledge about the module.
  • Syntactic aspects of dependency
  • Semantic dependency
  • The module specification what clients can assume.

9
Evaluating 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)

10
Components
  • A unit of reuse and replacement.
  • Pluggable.

11
Objects
  • Our view of objects

12
What 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)

13
The 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.

14
Classes?!
  • 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).

15
Inheritance
  • 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.

16
Polymorphism 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.

17
UML
  • Unified Modeling Language

18
An Object
  • First we need to identify the objects in the
    system.
  • Object has a name, attributes and operations.

19
Object 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.

20
Object 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
21
Object 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.

22
Aggregation 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
23
Example (of associations)
24
Example 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
25
Use 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

26
Example Use Case in A Library
27
Sequence 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.

28
Example Borrow a Book
29
Message Sending Options
30
State 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
31
State Diagram (cont)
  • States as boxes
  • Transitions as arrows
  • Events are shown as messages on the arrows
  • Start marker is a black blob

32
State 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.

33
State Diagram (cont)
  • Guards - adding conditions to events
  • A book (with many copies) can (or cant) be
    borrowed.

If last copy then change state
Write a Comment
User Comments (0)
About PowerShow.com