Thursday, September 18, 2008

Creational patterns

This design patterns is all about class instantiation. This pattern can be further divided into class-creation patterns and object-creational patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation effectively to get the job done.

Separates object construction from its representation

  • Factory Method
    Creates an instance of several derived classes
  • Object Pool
    Avoid expensive acquisition and release of resources by recycling objects that are no longer in use
  • Prototype
    A fully initialized instance to be copied or cloned
  • Singleton
    A class of which only a single instance can exist

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

Tuesday, July 22, 2008

COMMON ARCHITECTURES


Architecture
is a set of structuring principles that enables a system to be comprised of a set of simpler systems each with its own local context that is independent of but not inconsistent with the context of the larger system as a whole. [Sun Microsystems, Inc.]

Software Architecture
Software architecture is the structure of structures and take away the functions that implement business requirements and what remains is architecture.

Description of a structural framework to help the design of the application.
The description of a development environment and deployment configuration that supports the non-functional requirements of a software application.
A software architect is most active during the early stages of development but must participate during the entire development lifecycle of a product.
Architecture is developed and described somewhere between when a vision for the product is developed and before construction begins.
The software architecture must be baselined (agreed on by all stakeholders) before construction begins because a change in the architecture usually has vast consequences.
Architectural considerations: An architecture can be assessed using the following qualitative measures:
A non-functional requirement is one that is specified for a software system and does not pertain to a business function to be developed in the system.
Non-Functional requirements are usually quality attributes for the software system.
Also called service-level requirements or Quality of Service (QoS) requirements or Non-functional requirements
During the inception and elaboration phases, architect works with defining the quality of service measurement for these QoS reqs.
One has to make trade-offs between these requirements (For example, if the most important service-level requirement is the performance of the system, you might sacrifice the maintainability and extensibility of the system to ensure that you meet the performance quality of service)
1.Scalability
2.Maintainability
3.Reliability
4.Availability
5.Extensibility
6.Performance
7.Manageability
8.Security

Thursday, March 27, 2008

Design Principles

What are Software Design Principles?

Software design principles represent a set of guidelines that helps us to avoid having a bad design. The design principles are associated to Robert Martin who gathered them in "Agile Software Development: Principles, Patterns, and Practices". According to Robert Martin there are 3 important characteristics of a bad design that should be avoided:

  • Rigidity - It is hard to change because every change affects too many other parts of the system.
  • Fragility - When you make a change, unexpected parts of the system break.
  • Immobility - It is hard to reuse in another application because it cannot be disentangled from the current application.

Open Close Principle

  • Software entities like classes, modules and functions should be open for extension but closed for modifications.

OPC is a generic principle. You can consider it when writing your classes to make sure that when you need to extend their behavior you don’t have to change the class but to extend it. The same principle can be applied for modules, packages, libraries. If you have a library containing a set of classes there are many reasons for which you’ll prefer to extend it without changing the code that was already written (backward compatibility, regression testing, …). This is why we have to make sure our modules follow Open Closed Principle.

When referring to the classes Open Close Principle can be ensured by use of Abstract Classes and concrete classes for implementing their behavior. This will enforce having Concrete Classes extending Abstract Classes instead of changing them. Some particular cases of this are Template Pattern and Strategy Pattern.

Dependency Inversion Principle

  • High-level modules should not depend on low-level modules. Both should depend on abstractions.
  • Abstractions should not depend on details. Details should depend on abstractions.

Dependency Inversion Principle states that we should decouple high level modules from low level modules, introducing an abstraction layer between the high level classes and low level classes. Further more it inverts the dependency: instead of writing our abstractions based on details, the we should write the details based on abstractions.

Dependency Inversion or Inversion of Control are better know terms referring to the way in which the dependencies are realized. In the classical way when a software module(class, framework, …) need some other module, it initializes and holds a direct reference to it. This will make the 2 modules tight coupled. In order to decouple them the first module will provide a hook(a property, parameter, …) and an external module controlling the dependencies will inject the reference to the second one.

By applying the Dependency Inversion the modules can be easily changed by other modules just changing the dependency module. Factories and Abstract Factories can be used as dependency frameworks, but there are specialized frameworks for that, known as Inversion of Control Container.

Interface Segregation Principle

  • Clients should not be forced to depend upon interfaces that they don't use.

This principle teaches us to take care how we write our interfaces. When we write our interfaces we should take care to add only methods that should be there. If we add methods that should not be there the classes implementing the interface will have to implement those methods as well. For example if we create an interface called Worker and add a method lunch break, all the workers will have to implement it. What if the worker is a robot?

As a conclusion Interfaces containing methods that are not specific to it are called polluted or fat interfaces. We should avoid them.

Single Responsibility Principle

  • A class should have only one reason to change.

In this context a responsibility is considered to be one reason to change. This principle states that if we have 2 reasons to change for a class, we have to split the functionality in two classes. Each class will handle only one responsibility and on future if we need to make one change we are going to make it in the class which handle it. When we need to make a change in a class having more responsibilities the change might affect the other functionality of the classes.

Single Responsibility Principle was introduced Tom DeMarco in his book Structured Analysis and Systems Specification, 1979. Robert Martin reinterpreted the concept and defined the responsibility as a reason to change.

Liskov's Substitution Principle

  • Derived types must be completely substitutable for their base types.

This principle is just an extension of the Open Close Principle in terms of behavior meaning that we must make sure that new derived classes are extending the base classes without changing their behavior. The new derived classes should be able to replace the base classes without any change in the code.


Liskov's Substitution Principle was introduced by Barbara Liskov in a 1987 Conference on Object Oriented Programming Systems Languages and Applications, in Data abstraction and hierarchy


from http://www.oodesign.com/design-principles.html





Wednesday, February 6, 2008

SCEA 5 Released

http://www.sun.com/training/certification/java/scea.xml

SCEA 5 BEta Exam Resources List

Recommended Readings

UML Distilled
- by Martin Fowler

Java Design (Objects, UML, and Process) - by Kirk Knoernschild
Addison-Wesley (2002)
ISBN 0-201-75044-9
Web Services For SOA - sun article


SOA Using Java Web Services (Paperback) - by Mark D. Hansen

Developing Java Web Services:
Architecting and Developing Secure Web Services Using Java - by Ramesh Nagappan, Robert Skoczylas,

EnterpriseIntegrationPatterns

Enterprise Java Beans - by Richard Monson-Haefel

Java Enterprise in a Nutshell - by David Flanagan, Jim Farley, William Crawford, Kris Magnusson

EJB v3.0 spec

EJB v2.1 spec

Core Servlets and JavaServer Pages, Vol. 1 (2nd Edition) - by Marty Hall, Larry Brown

Core Servlets and JavaServer Pages, Vol. 2 (2nd Edition) - by Marty Hall, Larry Brown, and Yaakov Chaikin


Core JavaServer Faces (2nd Edition) - by David Geary, Cay S. Horstmann

Servlet v2.5 spec

JSP v1.2 spec

JSF v1.1 spec

Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition - by Nicholas Kassem, Enterprise

Java 2 Platform, Enterprise Edition: Platform and Component Specifications - by Bill Shannon, Mark Hapner, Vlada Matena, Eduardo Pelegri-Llopart, Larry Cable, James Davidson


Enterprise Blueprints: http://java.sun.com/blueprints/enterprise/

Java EE 5 Performance Management and Optimization (Pro) - by Steven Haines

Design Patterns and Contracts - by Jean-Marc Jezequel, by Michel Train and Christine mingins

Design Patterns - by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Grady Booch

Core J2EE Patterns: http://java.sun.com/blueprints/corej2eepatterns/, http://www.corej2eepatterns.com/

Core J2EE Patterns: Best Practices and Design Strategies (2nd Edition) - Deepak Alur, John Crupi and Dan Malks

J2EE Blueprints

Java 2 Network Security, by Marco Pistoia, Duane F. Reller, Deepak Gupta, Milind Nagnur, Ashok K. Ramani

Core Security Patterns: Best Practices and Strategies for J2EE, Web Services, and Identity Managemen

Thursday, January 31, 2008

Design Patterns Higer Level Diagram

Design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Thursday, January 24, 2008

GOF Patterns