Archive

Posts Tagged ‘UML’

J2EE Design Patterns

November 24th, 2009 1 comment

1. Intercepting Filter:

Problem : Preprocessing and post-processing of a client Web request and response are required.When a request enters a Web application, it often must pass several entrance tests prior to the main processing stage. For example,

Has the client been authenticated?

Does the client have a valid session?

Is the client’s IP address from a trusted network?

Does the request path violate any constraints?

What encoding does the client use to send the data?

Do we support the browser type of the client?  Read more…

Relationships in UML explained

November 24th, 2009 No comments

The following table shows the kinds of UML relationships between classes, their notation, and what they mean

Association : When two classes are connected to each other in any way, an association relation is established. For example A “student studies in a college” association can be shown as:

association Relationhsip

association Relationhsip

Read more…

Categories: Programming / tutorials Tags: ,

UML Cheat Sheet

November 22nd, 2009 No comments

Some UML  reference notes

  1. What is UML? UML is Unified Modeling Language. It is a graphical language for visualizing specifying constructing and documenting the artifacts of the system. It allows you to create a blue print of all the aspects of the system, before actually physically implementing the system.

  2. What is modeling? What are the advantages of creating a model? Modeling is a proven and well-accepted engineering technique which helps build a model. Model is a simplification of reality; it is a blueprint of the actual system that needs to be built. Model helps to visualize the system. Model helps to specify the structural and behavior of the system. Model helps make templates for constructing the system. Model helps document the system. Read more…

Categories: Programming / tutorials Tags:

Difference between Factory and Abstract Factory

September 14th, 2009 No comments

Abstract Factory: This is a Creational pattern.
It provides an interface for creating families of related or dependent objects (products) without specifying their concrete classes.
J2EE technology uses this pattern for the EJB Home interface, which creates new EJB objects.
It isolates concrete classes.
It makes exchanging product families easy.
It promotes consistency among products.
Supporting new kinds of products is difficult

Factory Method : This pattern defines an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
J2EE technology uses this pattern for the EJB Home interface, which creates new EJB objects.
Eliminates the need to bind application-specific classes into your code.
Gives subclasses a hook for providing an extended version of an object being constructed.

Difference between Factory and Abstract Factory
The Factory Method pattern is for creating a single object type. It provides a generic interface for client objects, and defers instantiation to subclasses that implement the generic interface.

The Abstract Factory pattern is for creating multiple, related objects, and defers instantiation to subclasses that implement the generic interface of the factory object

Categories: Programming / tutorials Tags: ,

Difference between Aggregation and Composition

August 26th, 2009 11 comments

When studying UML , one of the most important questions which comes to mid of a programmer is , What is the difference between Aggregation and Composition ?

Composition and Aggregation are types of associations. They are very closely related and in terms of programming there does not appear much difference.  I will try to explain the difference between these two by java code examples

Aggregation: the object exists outside the other, is created outside, so it is passed as an argument (for example) to the construtor. Ex: People – car. The car is create in a different context and than becomes a person property.

Composition: the object only exists, or only makes sense inside the other, as a part of the other. Ex: People – heart. You don’t create a heart and than passes it to a person.

Code example for aggregation:

// WebServer is aggregated of a HttpListener and a RequestProcessor

public class WebServer {
private HttpListener listener;
private RequestProcessor processor;
public WebServer(HttpListener listener, RequestProcessor processor) {
this.listener = listener;
this.processor = processor;
}
}

Code example for composition

// WebServer is an composition of HttpListener and RequestProcessor and controls their lifecycle

public class WebServer {
private HttpListener listener;
private RequestProcessor processor;
public WebServer() {
this.listener = new HttpListener(80);
this.processor = new RequestProcessor('/www/root');
}
}

In composition, whole has responsibility of preventing garbage collection of part.

Categories: Programming / tutorials Tags: , , ,