Next level of Don’t Repeat Yourself(DRY) principle

We are building the software applications using various languages for several years. Over the time new frameworks, new tools, new methodologies have came up. Especially in Java platform, now we have plenty of choices in each area following various design patterns and principles like MVC, FrontController etc.

We have many development principles like KISS(Keep It Simple Stupid), DRY(Don’t Repeat Yourself) which encourages to write better code which is maintainable. Especially DRY principle is a very good one which every developer should understand and follow.

The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”

So the DRY principle is saying that if you need to write same piece of code at many places instead of copy-pasting make it as a separate method and use it wherever it is required. This is applying DRY at code level.

I really really appreciate the Jakartha-Commons Utils authors for practically implementing DRY principle. Whenever i need a utility like some String operation, Date calculation, Regular expressions, Properties loading etc etc I just open the Jakartha-Commons website and i am sure i can find there what i need.
Even though each application has its own set of business requirements there are many things which are common to web/enterprise applications. Especially infrastructure code might be similar to many applications.

Now I think it is time to take DRY priciple to the next level, I mean to apply at functional level.

Let us see where we can apply DRY at functional level. The following are some of the things where we can build reusable components/small projects which we can directly use with other projects.

1. An application multi-level menu bar:
I have seen many applications having a horizantal menu bar at the top of the page with single/multi level sub-menus. The menu bar can be build using Javascript or custom tags. What I am suggesting is if we can build a CustomTag to generate a Menu bar from an xml configuration and a style sheet that component can be used in any of hte projects.

For Ex:

we can create an xml structure for our menu as follows and create a customtag to parse that xml and render a menu bar with default stylesheet. If user is proved a custom stylesheet that custom tag will use that.


   


        1
        File
           
                1
                New
           
           
                2
                Save
           
            .....
            .....
   

   

        2
        Edit
           
                1
                Cut
           
           
                2
                Copy



2. Role-based authentication and authorization system:
I involved in many projects where the application users will have one or more roles and each role has one or more privileges. Each privilege is nothing but an action that a use will do in appliation. The whole application events will driven by role based authorization. And also there could be a requirement to create user groups and assign privileges to user groups instead of individual users.

I think this Role based Authorization System can also be built as a component which we can plug in to any project.

3. Job Scheduling:
For many enterprises there could be several batch jobs that should be run on perticular schedules. I think there a need to build a job scheduling web application with the following features:
    a) A web based UI to create and schedule new jobs
    b) Provision to track the status of the running jobs
    c) Provision to run jobs in adhoc manner
    d) Provision to reschedule, terminate a job
    e) Informing the concerned groups about the status of jobs through emails
    f) Automatic email notifications on job failures

we can build a web application with the above mentioned features and leaving business logic implementation in the jobs for the developers.

4. Sophisticated logging system:
While developing the application logging plays a vital role in debugging the problems. We can use AOP for logging in a better way with cleaner approach. Many times the developer needs to check what parameters are sending to methods and where it is throwing an exception.

For this we can write MethodParamsDumbperAspect using SpringAOP+AspectJ which will display the method parameter values using reflection/commons-beanutils. Only thing a developer need to configure is the base package name.

5. Configurable and customizable work-flow engine:
I have seen many intranet portals having HelpDesk applications with the following features.

1. A customer will raise a request.
2. The system will identify the workflow to process the request and the request will be routed to the concern person.
3. The requester can view the status of his request as each stpe is in progress.

Like this there are many WorkFlow based systems. We can build a generic workflow engine where in the administrator can setup the metadata like Request Types, Steps for each request, Request Status codes etc.

So here my point is all these days we followed DRY in writing code. Let us take it to the next level in building components/sub-projects. If an architect or developer got a requirement to build a reusable component, it would be great if he/she can publish his/her approach (and code if possible) so that the other developers across the java community can use the approach/code instead of reinventing the wheel.

I am planning to build a JobScheduling Server with the above mentioned features. If anyone is interested you can join me 🙂

Struts, Spring, Hibernate… What next?

I have started my career in 2006 as a Java Developer. Since then most of the times I was being involved in developing web applications using Servlets, JSP, Struts, IBatis and Hibernate. In late 2008 I started working with Spring and now I am a big fan of Spring.

I am pretty much interested in learning new technologies/frameworks. So i started playing with several things like Quartz, JMS, JSF,JasperReports, DWR, XStream API, JPA, JavaMail, DisplayTag, JUnit, Ant, ApachePOI, JExcel blah blah blah. I am very much bored of doing the same things over and over using Struts, Spring, Hibernate etc.

Apart from Job market perspective there could be many people(like me) learning new languages/frameworks/tools out of interest or for fun/timepass. I am a regular visitor for JavaLobby and I am seeing lot of new things coming in java technology everyday.

So I thought of learning something new and I listed down what are all the new things that are there in the java world.
1. RIA frameworks (EXTJS, DOJO, YUI, Flex)
2. PHP, RubyOnRails, Groovy/GRAILS
3. Social networking APIs like SpringSocial

RIA frameworks:
It seems to me that we have enough well established serverside technologies(Spring, EJB3 etc…) to develop middleware components.
Now majority of the new applications are being developed/enhanced to add AJAX flavour to have a rich look. And there are plenty of Ajax frameworks.
I choose EXTJS, DOJO, YUI frameworks based on their popularity. I have prior experience with ExtJS and ExtJS is unbeatable AJAX library for developing web applications with Rich UI widgets.

Especially the ExtJS grid is awesome. And you can find almost every kind of UI widget in ExtJS. But I dont know why majority of the people are using other Ajax libraries instead of ExtJS.

I recently take a look at Dojo and it is really good at some points. Especially Dojo’s validations embedded within markup looks great for people like who don’t like putting validations somewhere else in javascript file. But i didn’t find any information about Grid supprt with Pagination, Sorting, Filtering. For me(many of others also) a grid control with pagination, sorting and filtering a minimum expected widget to be in an Ajax library.

I am working currently using YUI in my project. The YUI features are good but look and feel wise its very poor compared to ExtJS and Dojo.

I had a chance to play with Flex sometime back in 2009 and its simply superb. But Flex should be used for flashy kinf applications, otherwise it will be a overusage if Flex is used for simple CRUD kind of applications.

Secondary Programming Language:
My primary programming is Java and I want to learn a new programming language now which should be cool, funny and suitable for rpid application development. Can somebody suggest what would be better to learn among PHP, ROR, GROOVY/Grails from the percpective of Job market and ease of use to develop small to medium sized web applications.

Social Networking:
Recently I am hearing that many websites are providing interfaces to interact with Social Networking sites like Twitter, Facebook, Linkedin etc.
SpringSocial might be a good one to learn this time.

After Struts, Spring, Hibernate era, I am feeling like the future would be Rich Applications development with Social Networking sites interactions.
What do you say?

JSF can be used for several purposes.

Recently I got a wonderful opportunity to work with JSF and I couldn’t stop myself sharing my feelings on JSF with everyone.
By god’s grace till last month i didn’t a chance to work on JSF in my career. But recently i have to work on a project developed in JSF 1.x.

After spending few days on JSF technology I realized that JSF is not only a web framework and we can use it for several purposes.

Below is just a small list:

1. To test the patience and mental strength of a developer.
2. If you are a team lead/manager and you want to take revenge on a team member you can allot him to work on a JSF project.
3. If your client is not satisfied with your company services and ending the relationship with the organization and you are working on the last project for that client. You can use JSF for that project and deliver a useless, unmaintainable junk and waste a lot of clients money in terms of billing.
4. If anybody wants to move out of java or entirely from IT and is postponing that decision then allot him to work on a JSF project. He will move to new career with in 1 week.
5. In future if we want to show how to write stateful component oriented junk we can keep some JSF projects and show them for reference.

I know there are some JSF fans across the world and they might scold me for this post.
If you want to shout at me please shout at me in Error 500: “{2}” Conversion Error setting value ”{0}” for ”{1}” format because this is what JSF barks for whatever wrong thing happens in this world.

GOD, Save the java community from JSF.