Misra’s blog

Design patterns interview questions

Posted by mtwinkle on May 18, 2006

http://java.sun.com/blueprints/corej2eepatterns/Patterns/
Q1. Problems of the multi-tier J2ee architecture?
Ans1.
In a multitiered Java 2 Platform, Enterprise Edition (J2EE) application environment, the following problems arise:
a. Tight coupling, which leads to direct dependence between clients and business objects;
b. Too many method invocations between client and server, leading to network performance problems;
c. Lack of a uniform client access strategy, exposing business objects to misuse.

Q1. Session facade
Ans1.
The Session Facade manages the interactions between the business data and business service objects that participate in the workflow, and it encapsulates the business logic associated with the requirements. The session bean also manages the life cycle of these participants by creating, locating (looking up), modifying, and deleting them as required by the workflow.

For example, for a banking application, you may group the interactions related to managing an account into a single facade. The use cases Create New Account, Change Account Information, View Account information, and so on all deal with the coarse-grained entity object Account. Creating a session bean facade for each use case is not recommended. Thus, the functions required to support these related use cases could be grouped into a single Session Facade called AccountSessionFacade.

Stateless Session Facade Strategy
Business process that needs only one method call to complete the service .
Stateful Session Facade Strategy
business process that needs multiple method calls to complete the service
Q3. Business Delegate
Ans3.
If the presentation-tier components interact directly with business services, so , when the implementation of the business services change, the exposed implementation code in the presentation tier must change too.

Business Delegate reduces coupling between presentation-tier clients and business services. It hides the underlying implementation details of the business service, such as lookup and access details of the EJB architecture. The Business Delegate may also transparently perform any retry or recovery operations necessary in the event of a service failure without exposing the client to the problem until it is determined that the problem is not resolvable. Another benefit is that the delegate may cache results and references to remote business services.

The client requests the BusinessDelegate to provide access to the underlying business service. The BusinessDelegate uses a LookupService to locate the required BusinessService component.

Delegate Adapter Strategy
The Business Delegate proves to be a nice fit in a B2B environment when communicating with (J2EE) based services. Disparate systems may use an XML as the integration language. Integrating one system to another typically requires an Adapter to meld the two disparate systems.
invoke with XML
B2Bclient –> B2BAdapter –> Business delegate –> Business service
Q4. Service Locator
Use a Service Locator object to abstract all JNDI usage and to hide the complexities of initial context creation, EJB home object lookup, and EJB object re-creation. Multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.

The client is an object that typically requires access to business objects such as a Business Delegate
The InitialContext object is the start point in the lookup and creation process
The ServiceFactory object represents an object that provides life cycle management for the BusinessService objects. The ServiceFactory object for enterprise beans is an EJBHome object. The ServiceFactory for JMS components can be a JMS ConnectionFactory object, such as a TopicConnectionFactory (for publish/subscribe messaging model) or a QueueConnectionFactory (for point-to-point messaging model).

EJB Service Locator Strategy
The Service Locator for enterprise bean components uses EJBHome object. Once the EJBHome object is obtained, it can be cached in the ServiceLocator for future use to avoid another JNDI lookup when the client needs the home object again. Depending on the implementation, the home object can be returned to the client, which can then use it to look up, create, and remove enterprise beans.

Q5. Data Access Object (DAO)
Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
BusinessObject: It is the object that requires access to the data source to obtain and store data
DataAccessObject: abstracts the underlying data access implementation for the BusinessObject to enable transparent access to the data source
DataSource: represents a data source implementation
TransferObject: This represents a Transfer Object used as a data carrier. The DataAccessObject may use a Transfer Object to return data to the client. The DataAccessObject may also receive the data from the client in a Transfer Object to update the data in the data source.

5 Responses to “Design patterns interview questions”

  1. Extremely man or woman speeches require to seat giving observe into couples. Brand new sound system just before unnecessary individuals ought to always be mindful of usually senior general rule from public speaking, which is to be the mini. greatest man speaches 892828

  2. They call it the self-censor, merely because youre too self-conscious of your writing, too judgmental. 678247

  3. website said

    Wow Da weiss man, wo es hingehen muss Viele Grsse Mirta 562396

  4. wohh precisely what I was seeking for, thankyou for putting up. 38176

  5. You produced some decent points there. I looked on the internet for that concern and located most individuals will go together with with the internet site. 730730

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: