Archive

Archive for the ‘Beginner’ Category

Unit Testing Framework: EAMSteps

2 September, 2011 1 comment

EAMSteps is a framework that makes Unit Testing easier because of its following principles:
- External data store for test data like excel spreadsheet
- Automated assertions using co-related inputs and outputs
- Minimal lines of code to get started

It all started in 2009, when I decided that in long term I would need to have a framework in place that will help me meet my objectives and I started to look for any existing tools. When I did not find any framework that would help me, I decided that it was time to write one and here after 2 years I have something breathing.

You can read more about this here.

iFramework: Updates

Last week I have made released a framework iFramework with a coupe of features. Here is another release that adds a few more features to the it. You can find the details

Exception Handling

This simple yet powerful implementation provides some of the most desirable features in any Exception Handling framework:

  • Unchecked Exceptions for Business and System errors
  • Message Externalization
  • Message Localization
  • Configurable Message Data Sources

Message Readers

This package provides factory to fetch various types of Message Readers. The current implementation only supports Resource Bundle based message stores, but it can be easily extended to other data stores.

Concurrent Processing

This package provides base classes that allow you to run your functions in a producer and consumer fashion. By using this framework you have to worry about writing your business logic for a Producer and a Consumer and not about multi-threading and how these two entities interact. This framework currently has only one implementation of a Broker i.e AsyncQueueBroker but more will be added in coming months.

Related articles

A new OSS project: iFramework

24 August, 2011 2 comments

If you have been following me for a long time, you would know that I keep saying of releasing some of my work to the community; and today I finally am proud to announce that I am releasing my first projecthttp://scratchpad101.com/2011/08/24/i-framework/. Today this project is just a set of two/thre utility classes, but over next few months I plan to add a lot more to it.

Current Features:

  • Improved Loggers
  • Database Setup Utilities

So, please go visit the project and have a look on what I have. Also, please let me know if you are looking for something special.

History of programming

I came across this very interesting article and the author’s views where programming started way back. Read here – http://java.sys-con.com/node/1879986

Categories: Beginner, Design Tags: , ,

Noah: Development Environment

Some time back I posted about various development tools that I would like to have in my

Development Environment ~ Eclipse

Development Environment ~ Eclipse

development environment. Well back then, I was unable to get that list in place; but here I have started doing it for Noah. To kick it off, I have attached the tools that I am going to use in the development environment. This is not an exhaustive list, and I may add more things to it as I go about development.

The document detailing the Development Environment can be located here: TS_Development_Environment

Pet Project is christned: Noah

Well – I though a lot about it, and came up with the name Noah for two reasons primarily:

  1. I like the name :)
  2. Noah did something very useful – built an ARK that saved the world

What I intent out of this project is not to save the world, but to build a sandbox that can be used by myself and any other developer to try out bigger things like Performance, Analysis, Design, Testing, POCs on new technologies.

Hence, I feel the name is appropriate – This project will provide others an opportunity to do something big.

 

Categories: Beginner, Noah

Pet Project

It has been almost 3 years, when I first had this idea – a pet project. And, I needed one so that I can try out various things in technology like – try new UI frameworks like Flex, GWT, DOJO etc. Also, there have been times when I have wanted to try out new ideas like how to improve an application I never had a substantial test bed to try out those and generate results.

I have been running around many things, but I have realized that this time has now come for me to start something; something that I can be proud of. I am no Bill Gates or Einstein and I need to pick up things that I can do for the community. I have all those ideas where I want to do something.

So I start here, I start now a pet project. I have the following ideas:

 

Accounting Solution
- I need something similar to Tally – but that already exists
+ Looks simple one to make
- You need to use it – you can find a bigger use of it
- If you ever want to use it else where it wont be possible
- Can be built as a part of application #2 and #3

Broker Management
- Need specialized details
+ Dad can help
- Is going to be a long running project
- Will need a lot of time and attention on my own time
+ It is a complex system and will present challenges to work on

Clinical Management
- Need Specialized details – WIll have to Work with Atul
+ Is of medium complexity
- Will need a lot of attention on my own time
- There is a commercial viability, just in case

 

And the decision is Accounting Software – why?

1. It is simple to get started with; so that I can actually work on all layers. I do not want to pick something so big that is never ending

2. Other applications will need accounting in them, so I am actually building all three together

3. It provides me with an opportunity to build a API/Framework that can be used in other applications. This is going to be tricky and challenging

 

Well, to make it clear, this is not something that I am doing for my organization or during any duration when I am working. This is a pet project that I am going to work on in my free time and it is going to take time. I am thinking that I should share the development with you all – artifacts etc.

So be it – I will share how this is going and will be sharing all artifacts with the world.

With me luck.

Eclipse takes a leap with Marketplace

11 March, 2011 1 comment

This is something not new to world, but is to me. Last night, when I started to upgrade my development environment to use Eclipse Helios, the very first thing I needed was a plugin to get met maven based projects working – m2clispe. Like in the past I started to search the net for a URL that I can dump the “Install Software” screen and navigate through the various options and then find any missing dependencies to get that going.

But, I was in for a surprise – Eclipse Marketplace. I read about Eclipse launching a marketplace a while back, but because I was not actively developing back then, it did not register. However, a tutorial reminded me the Marketplace.

The experience from there on was simply wonderful, something that I am not familiar in the Java world of development. Kudos to the Eclipse team to get this one going.

Nest step if to install many more plugins in my new Helios before I get back to development.

 

Who the hell needs Quality?

10 March, 2011 2 comments

I Do; you do; our customers do; Period

Well we all know the answer, but is it really what we believe in? The more important question is how do we choose to deliver quality when we can not measure it?

A few months back, I was sitting in a meeting where the conversation went something like

Business Person: So we need 24000 hours to deliver the scope of the release?

IT Person: Yes. But this does not include the hours needed to fix defects that we will have in the application at the end of development lifecycle.

Business Person: So how many defects we had in last release – I assume about 700?

IT Person: Yeah.

Business Person: So I can expect 2000 in this release? How much time do you need to fix one defect?

IT Person: About 16 hours per defect

I will let you do the math, but what made me fell out of my chair was the fact that everyone in the room was accepting the fact that even before we were developing the application we would have 66% of the time spent in fixing defects. Not even once did anyone asked, how can we ensure that we do not have so many defects in the application. Now even once did anyone asked if we already have Unit testing how come we still have these many number of defects.

Well, this is not the first time I heard this conversation and I am sure not the last time. But, I wonder how do people reach Architects, Project Managers, Program Managers and Directors IT if they have these discussions.

I did not say anything in the meeting, because I was supposed to sit there and listen which is another sad story. I could not even say anything to my IT team once the meeting was over; I was just not supposed to. Maybe, if someone who was in that meeting reads this and can co-relate I would be in a big shit of trouble; but I am going to risk it – do not know why.

I am someone who can not start writing a piece of code without having a unit test before it (Test Driven Development). But, then the projects I have been working lately do not even automated unit testing let along TDD. Their unit testing is done because they have to compliant with the Quality Process and at times it is done with a set of people who never coded it. The unit testing team works like a QA team but is withing the realms of the development team itself. And then there are times when Unit testing happens in parallel to System Testing.

This is a rant, where I hope I can pass a message around importance of testing.

 

Dilbert - Quality

Dilbert - Quality

 

 

 

 

 

 

 

 

Related Articles

‘The Null’ Nuisance

3 February, 2009 1 comment

While working on enahncements on a project already in production, I had a very interesting conversation. Let me give a brief background – the core architecture is all in place and we need to build in new functionality. Of course, refactoring is being done along the road. In a specific scenario, I got into a conversation with a fellow architect on usage of “nulls” and “null checks”. The theme of the conversation was “Should a method return a null or an initialized instance of the class”. Let me take an example:

There is a service method that connects to a database loading records for all users in the system. In the DAO we are loading the recordset from the database and converting to an ArrayList of DTO (ValueObject). A sample code to map the a DTO generally is:

List<User> users = null;
for(int index = 0; index < recordSet.size(); index++)
{
    User user = new User();
    user.setFirstName(recordSet.getString(“firstName”);
    user.setMiddleName(recordSet.getString(“middleName”);
    user.setLastName(recordSet.getString(“lastName”);    user.add(user);
}

return users;


 

 

 

 

I had an objection to this style of coding. The simple reason being, on the front-end, I had to put a check for null which was un-necessary. Hence, the other classes that were consuming the results had to write the following code:

List<Users> users = loadAll();
if(users != null)
{
    /// do something
}
else
{
    if(users.get(index).getMidleName() != null)
    {
        // show the middle name
    }
    else
    {
        // do not show the middle name
    }
}

Now, consider a scenario with complex objects having lists all down the hierarchy. It means that before we access a property, we will have to provide a null check. Soon, this “do nothing” null check will become a headache. Someone has coded a null propogation somewhere and we can not trace it. We feel the easiest way is to put in a null check. In my given example, I would have my JSP strewen with null checks cluttering my code.

Unfortunately, this will not solve the real problem. A simple solution is to identify the code where a null reference can be introduced and handle it there. The rest will be happy about it.

More importantly, et us pause for a minute and ask ourselves – Is there something that the application can do, with an object refering to nothing? Let us go back to my example and see how is the application going to use the user list. We need the list of the users to display a report for the users listed. If no users are returned, the uer should see “No users exist”. The UI is no sure, what represents  users – a null object or an initialized object with 0 size or an exception. This will mean that the developer consuming the method will have to write these multple conditions for a simple check.

We can do oe of the following: 

 

 

 

 

1. Throwing a business exception that voilates a business logic can be an effective strategy. However, it largely depends on how do you use exceptions in applications. Remember, raising an exception is an expensive operation.

2. Alternatively, you can provide an Empty implementation of the object that can do something useful like logging an info or an error to the log system.

I am not a hugh fan of throwing an Exception, and also because it is expensive, I am exploring the second option. This changes my code to:

List<User> users = null;
for(int index = 0; index < recordSet.size(); index++)
{
    User user = new User();
    user.setFirstName(recordSet.getString(“firstName”));
    if(
recordSet.getString(“middleName”) == null)   // You can also use StringUtils from apache.lang
    {
        user.setMiddleName(“”);
    }
    else
    {

        user.setMiddleName(recordSet.getString(“middleName”));
    }
    user.setLastName(recordSet.getString(“lastName”));    user.add(user);
}

if(users == null)
{
    // throw new business exception
}

// else we return an initialized list.
return new ArrayList<User>();

This will change the UI code to:

 

 

 

 

 

List<Users> users = loadAll();
// code to show the middle name – if it does not exist, it will show up as blank.


The most evident benefits is – “No more if statements for null checks on the UI. Check is being pushed down in the call hierarchy. Hence, multiple methods calling the same method will not have to worry about nulls.”

The most important question is “Is this approach safe?” Nothing ever is. There is no reason for someone to code incorrectly. Of course, we can not on external libraries never to return null references, but when you write your own code, following this approach can lead to a less cluttered application and a better control over source code.

Remember: The approach is not always necessary, just ensure that the null reference should not be catastrophic.

Follow

Get every new post delivered to your Inbox.