Java OOAD

Page 1

1


2


3


4


5


6


7


8


â—? â—?

Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules. When designing a complex software system, it is essential to decompose it into smaller parts, each of which we may then refine independently

9


10


11


12


When the user object asks for the yearly income, the person represented as public interface is going to do all the computation by himself. The user object does not know that the person represented by public interface has considered SAVINGS, TAX, etc.

13


When the user object asks for the yearly income, the person represented as public interface is now asking the secretary about the income. The secretary is using accountancy package in computer to compute the income. The user object still gets the income report even if internal implementation has changed.

Illustrates : Understandable interface. Can be used without fear of "breaking" object

14


15


16


17


18


19


20


21


22


23


When you model a system, certain objects will be related to each other, and these relationships themselves need to be modeled for clarity An association is a linkage between two classes. Association can be uni-directional or bi-directional.

24


In bi-directional association both classes are aware of each other and their relationship. A bi-directional association is indicated by a solid line between the two classes. At either end of the line, you place a role name and a multiplicity value

25


?1 Department ?2 employees: Collection ?3 Employee ?4 department: Department ?5 0..* ?6 assignedDepartment ?7 employees ?8 0..1

26


27


28


29


An association with an aggregation relationship indicates that one class is a part of another class. In an aggregation relationship, the child class instance can outlive its parent class. draw an unfilled diamond shape on the parent class's association end In Composition association the child’s class instance lifecycle is dependent on the parent’s class instance lifecycle. draw an filled diamond shape on the parent class's association end

30


31


32


In Composition association the child’s class instance lifecycle is dependent on the parent’s class instance lifecycle. draw an filled diamond shape on the parent class's association end.

33


1) BookShelf and Books: a. Aggregation relation: BookShelf is a collection or container of other Books, but where the BookShelf does not have a strong life cycle dependency on the Book. 2) Components in a Television Set: a. Composition relation: If the television set is destroyed, normally every components that it contains is destroyed as well. 3) Orchestra is made up of Musicians : Aggregation 4) Building and Rooms: Composition

34


The generalization class (the super class) explicitly captures the common attributes and methods The specialization class (the subclass) extends the implementation with additional attributes and methods

35


We have different types of products which share common attributes like productNumber, description and price.

36


Move the common attributes and behavior up the tree.

37


Generalizing Rectangle and Circle: Declare a type Shape which contains common state applicable to both Rectangle and Circle. Specialize classes Rectangle will add additional attributes like width and breadth. Similarly Circle can specify radius. Generalizing Bitmap, Gif and JPEG: all these are images. So declare a generalized type Image and inherit Bitmap, GifImage and JPEG from Image.

38


39


For the same message “Now Speak”, duck “quack”, Cat says “Meow” and Dog says “Woof”.

40


41


42


In real world their cannot be any instance of Product. It has to be a Mobile, Washing Machine, Television, etc.

43


Interface from programmers perspective: contains only method signatures but no definitions. Refer: http://en.wikipedia.org/wiki/Interface_(computing)

44


45


Data Access Object (DAO) classes are meant to abstract and encapsulate all access to the persistent store in a separate layer. DAO interfaces will declare what CRUD ( CREATE, READ, UPDATE and DELETE) operations should be performed. DAO implementation classes contain the actual interaction with persistent layer, Each DAO implementation classes for different persistent store. E.g. for RDBMS, FILES, etc. Factory classes are used to decouple the client from the actual implementation class. Factory classes are going to instantiate and return the reference to the implementation, which client can access using interface. Since client uses interface to access implementation class, he can still do all the operations specified in the interface without knowing the implementation details.

Refer: http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm

46


This slide can be skipped and explained at latter stage

47


This slide can be skipped and explained at later stage

48


1."Is a special kind of" not "is a role played by a" Fail. A Manager is a role a Employee plays. So is an Programmer. 2.Never needs to transmute Fail. A Programmer can be a Manager and a Manager can also be a programmer.

3.Extends rather than overrides or nullifies Pass. 4.Does not extend a utility class Pass. So Inheritance fails here.

49


1) State , behavior 2) Fields 3) Methods 4) Encapsulation 5) Class 6) interface

50


51


52


53


54


55


56


57


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.