Showing posts with label jee. Show all posts
Showing posts with label jee. Show all posts

Saturday, January 23, 2010

Code Design Decision - Protecting Delegate Access?

Ran into this design desicion on one my engagements. Consider an abstract class implementation  that references a reference to another (delegate) object. Convenience methods are in the primary class class that are callled by concrete classes. This pattern can also exist in a concrete that delegates to another implementation.

public class AbstractClass{

private Delegate delegate;

void methodCallA() { delegate.methodCallA());
void methodCallB(String arg) { delegate.methodCallB());

}


This is a common idiom applied to the service/dao pattern, where a DAO delegate would never be exposed to consumers using a service instance. However, in my situation I was implementing a framework solution outside of data access, and was mulling over how far to go with hiding accesss to the delegate instance.

The idea is to provide access to the referenced object only from abstract class methods. However, as this design evolved, sometimes it seemed cumbersome to have to define an additional method in the abstract class, so I asked myself should I always hide delegate accessf from consumer, as shown below?

.....
public void concreteMethod() {
...
delegate.methodCallA();
...
}

I answered this question by asking myself there was a chance that the associated object implementation would ever have to be replaced, or some kind of pre or post conditioning may be required? If there's a chance, then protecting access to the delegate with access methods is worth the extra method definitions in the based class. However, this assumes only the delegate is only providing a few methods for the base class, if more than 7ish methods, then it would be cleaner to eliminate the base class access methods, and let concrete classes access the delegete directly.

If the conditions are met above, then allowing public access to the delegate can shorten the number method implementations, and new methods defined in a delegate are immediatly available for consumption.



Monday, November 3, 2008

Making JEE Software Development Agile

Agility is the verb that has been assigned as the solution for IT's slushiness in developing custom software. While, applying an agile process helps, if the software development mechanism is not agile, then it will be for not. Listed below are things that should be put into place in order to support an agile software construction environment.

Consistent Application Architecture
Consistency promotes predictability, scalability, and re-usability in software development. Impacts of applying new frameworks and patterns can be predicted. Consistent application structure and application of frameworks allows developers to functionally decompose there work efforts in a consistent manner for level of effort and resource planning. Additionally, consistency promotes reuse, as generalized components can rely upon an expected consuming application structure.

Convention over Configuration
Whenever possible, introduce generalized mechanisms that allow developers to start writing code out of the box. Eliminate having to set up or visit configuration files, hunting down libraries. The developer should always produce code that is verifiable and directly solving a problem space. As opposed to having perform setup or initialization activities.

Continuous Integration Environment
Establish an automated mechanism that "continuously" and frequently compiles/builds/deploys/tests code committed by the team to the repository. This environment helps ensures quality, and eliminates the inefficiencies developers can have when dealing with code resulting from merging activities. Less time is spent setting up demo and prototype environments for verification, allowing developers to keep there stream of consciousness in providing a solution.

Reference Application
Define and maintain a basic application that represents your application architecture. This can then be used a medium to describe how applications are constructed with your architecture, and communicate and prove new frameworks or technologies. Scaling agile development can also be enforced, by documenting steps required to build this application. New resources can then go through this exercise which will expedite there learning curve on there own, whithout taking away from existing resources.

Low Ceremony
Provide an envrionment in which the development team can easily install supporting software such as application servers or database instances. This of course, is limited to just the construction phase of the project, but by providing this "low ceremony" ability, agility is achieved by by passing the normal IT administration protocol during construction. Things can happen quicker, and after an agile spring/iteration verificaiton the team will have a better understanding of the "to be" production environment. At the same time quickly deliver early working deliverablse and versions of the software.

Knowledge Access
Take advantage of WIKI software, which will providce a way to communicate your application architecture and development environment. The WIKI brings agility to documentation, as it can be edited in-line allowing developers to collectivley contribute to it, thereby helping to keep documentation fresh and relevent.