Powered by Blogger.

AbstractFactory Design Pattern with an Example program

>> Tuesday, May 31, 2011

Creational Patterns - Abstract Factory Pattern

Definition:
  • Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  • A hierarchy that encapsulates: many possible “platforms”, and the construction of a suite of “products”.
  •  The new operator considered harmful.
Where to use & benefits
  1. Creates families of related or dependent objects like Kit.
  2. Provides a class library of products, exposing interface not implementation.
  3. Needs to isolate concrete classes from their super classes.
  4. A system needs independent of how its products are created, composed, and represented.
  5. Try to enforce a constraint.
  6. An alternative to Facade to hide platform-specific classe.
  7. Easily extensible to a system or a family.
  8. Related patterns include.

Read more..

Decorator Design Pattern with an Example

>> Monday, May 30, 2011

Definition:
               Attach additional responsibilities or functions to an object dynamically or statically. Also known as Wrapper.
Where to use & benefits:
  1. Provide an alternative to subclassing.
  2. Add new function to an object without affecting other objects.
  3. Make a responsibility easily added and removed dynamically.
  4. More flexibility than static inheritance.
  5. Transparent to the object.
  6. Related patterns include  
Decorative Design Pattern with Example_JavabynataraJ
  •  Adapter pattern, which provides a different interface to the object it adapts, whereas a decorator changes an object's responsibilities,

Read more..

Factory Design Pattern with a real time Example

>> Friday, May 27, 2011

The Factory design pattern comes under Creational design pattern.

Definition

Provides an abstraction or an interface and lets subclass or implementing classes decide which class or method should be instantiated or called, based on the conditions or parameters given.

Where to use & benefits
  1. Connect parallel class hierarchies.
  2. A class wants its subclasses to specify the object.
  3. A class cannot anticipate its subclasses, which must be created.
  4. A family of objects needs to be separated by using shared interface.
  5. The code needs to deal with interface, not implemented classes.
  6. Hide concrete classes from the client.
  7. Factory methods can be parameterized.
  8. The returned object may be either abstract or concrete object.
  9. Providing hooks for subclasses is more flexible than creating objects directly.
  10. Follow naming conventions to help other developers to recognize the code structure.

Read more..

Can I have more than one struts-config.xml file for a single Struts application?

>> Thursday, May 26, 2011

Yes! One can have more than one struts-config.xml file for a single Struts application.
You can define different struts-conifg.xml file for different modules in a single web application. It is useful when you are developing a distributed application. But you must enter those struts-config.xml files details in deployment descripter (i.e., web.xml) file.

If you are working with multiple modules in your project, then you can have one configuration file for each modules. Let's say the project has two modules admin and reports. You access the admin screens using the URI admin/admin-module1 and reports using the URI report/report-1. Here the admin and report are two different modules.

Read more..

Simple Hibernate Example on Inserting Employee details using MySql

>> Wednesday, May 25, 2011

Hibernate is a solution for object relational mapping and a persistence management solution or persistent layer. This is probably not understandable for anybody learning Hibernate.

What you can imagine is probably that you have your application with some functions (business logic) and you want to save data in a database. When you use Java all the business logic normally works with objects of different class types. Your database tables are not at all objects.

Hibernate provides a solution to map database tables to a class. It copies the database data to a class. In the other direction it supports to save objects to the database. In this process the object is transformed to one or more tables.

Read more..

Difference between ServletContext and ServletConfig

>> Thursday, May 19, 2011

What is the difference between ServletConfig and ServletContext?
ServletContext and ServletConfig both are interfaces.ServletContext is one per application and within the application serveral Servlets will be defined. Each Servlet will be having a ServletConfig object. Even for jsp page.You can understand easily by the image given below.

Difference between ServletConfig and ServletContext_JavabynataraJ


Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.