Monday, April 2, 2012

Bridge Design Pattern in java

Decouple implentation from interface and hiding implementation details from client is the essense of bridge design pattern Abstraction – core of the bridge design pattern and defines the crux. Contains a reference to the implementer. Refined Abstraction – Extends the abstraction takes the finer detail one level below. Hides the finer elements from implemetors. Implementer - This interface is the higer level than abstraction. Just defines the basic operations. Concrete Implementation – Implements the above implementer by providing concrete implementation

Friday, March 23, 2012

How the data moves through the struts2 framework

Two most important places this occurs are on the incoming form and the outgoing result page. In the case of the incoming request, the form field name attribute is interpreted as an OGNL expression. The expression is used to target a property on the ValueStack.In this case, the name property from our action. The value from the form field is automatically moved onto that property by the framework. On the other end,the result JSP pulls data off the name property by likewise using an OGNL expression, inside a tag, to reference a property on the ValueStack.

Wednesday, March 21, 2012

JSP Data Caching

For static data generation, this means using the _jspInit() method to generate the content only once, and then calling it back up using _jspService(), rather than using out.print() every time the page is requested. Data generated with _jspInit() will last for the full lifetime of the servlet. You can cache dynamic data using one of the 5 state persistence mechanisms available in JSP - Tomcat's native session persistence mechanism, cookies, URL rewriting, hidden fields, or a JDBC-based session persistence mechanism of your own design. Of these, Tomcat's native session support is easily the highest performer (although it has trouble scaling), followed by hidden fields. A good solution to balance the load between client and server for scalable, secure caching is to use Tomcat's session persistence support to store secure data, and handle everything else with hidden fields.

Saturday, February 11, 2012

Surveying the domain

Six Primary Task A Web Application do While processing requests.These are

■ Binding request parameters to Java types
■ Validating data
■ Making calls to business logic
■ Making calls to the data layer
■ Rendering presentation layer (HTML, and so on)
■ Providing internationalization and localization

Sunday, November 14, 2010

Unit Test in Java


http://www.vogella.de/articles/JUnit/article.html 

Developers write unit tests to check their own code.Unit testing differs from integration testing, which confirms that components work well together and acceptance testing, which confirms that an application does what the customer expects it to do. Unit tests are so named because they test a single unit of code.

In the case of Java, a unit usually equates to a single class.
Testing is meant to improve the quality of your code, not decrease it.
Having said that, sometimes designing your system in a way that makes testing easier is still necessary. If you need to add a design element to support testing, ensure that it also increases the general quality of the system as a whole.
Say you have a class that can be instantiated only through a factory method . You may need to test an object of this class, but for some reason you can't call the factory. It may require resources passed as parameters that you don't have in your testing environment. Should you make the default constructor public just so your tests can instantiate the object and run the tests? No, of course not. That would reduce the quality of the system's design, allowing anyone to access a constructor that should be private. In this scenario, the tester needs to work harder to provide the needed resources and instantiate the object through the factory (perhaps through the use of MockObjects).