Sunday, August 9, 2009

Iterative Software Development Cont.....

My last post gave an introduction to what iterative development is all about and what kind productivity and value addition it brings to the table. In this post i want to address the questions unanswered in my last post. Cant keep the readers in suspense now can i ;) ... But hey everybody likes a little thriller every now and them right? :) .... So what were the questioned that were unanswered in my last post? Ok ok if your bored to go back to it and check it out let me list it down here again :D....

  • How to approach iterative development
  • How to project your iteration size
  • How to incorporate new customer changes half way through an iteration
Taking first thing first, the way you should ideally approach an iterative development process is by first analysing the initial customer requirements you gather and breaking down those features with respect to the application scope. Then what you should do is to weight every feature according to the priority level (High/Low) as perceived by the Customer and estimate the number of development days each feature will take to complete.

This process includes the asnwere to our second question which is how to project your iteration size. So you can see them both as interelated questions. Iteration size normally is recommended to be best kept at 20 working days(i.e one calendar month). But ofcourse this is definitely a varying factor depending on the complexity and the size of the project.

What you do after you decide on your iteration size is to try to calculate what features can be included in the first iteration which keeps in track with the iteration size you specify. But also you should keep in mind to put in most of the high priority tasks to each iteration as possible. Sometimes there maybe some low priority features that need to be provided before you can continue with a high prioratized feature in which case it is acceptable to include low priority features into an iteration.

Going on to my last question which is what you do if the customer comes up with a new set of features while you are in the middle of one of your iteration. Again you should go in the normal flow as explained before and weight new features accordingly and then try to see how it best fits the current iteration. If it is possible you could always push back some of the planned features of the current iteration to the next iteration and incoporate the new features whilst keeping the iteration size intact. Then you could ask the question what if its the last iteration and the customer comes up with a new set of features. Well in this instance you have to come into an agreement with the customer as to what is realisticaly possible to achieve for the given deadline and either try to move the dead line or add more developers or ask the current team to work long hours to make the current deadline. But in my perpective i do not believe adding more developers or making the existing ones work long hours will do the project any good as overworking burns out developers which in turn will lessen their productivity in the long run. And adding new developers in the last iteration is or for that matter in the middle of the project is a very decisive decision to make because according to what is stated in the book The Mythical Man Month by adding new developers you are adding n(n-1) / 2 communications channles within the project where "n" is the number of people in the development team.

Hence it is always best to try to negotiate with the customer on the current situation and try to shift the deadline to a latter date or to come to an agreement and compromise some features as deemed appropriate by the customer that can be included in later versions after the deadline.

Well thats about it for now about iterative development. Two pretty long posts on iterative development huh?... :) .. Guess you guys are now getting sick of reading about iterative development. So ill try to blend in something different in my future posts to come.

Until then its adios from my side and happy development (hopefully iteratively :D )

Iterative Software Development


Ive been wondering why sometimes we in our projects face tight dead lines and if there is any way we could overcome such situations. In my current project we are kind of facing a tight deadline situation as well and this led me to investigate on this topic of how the development process should be organised so that these kind of issues can be resolved before hand as much as possible.

My eyes caught up on a process known as iterative development. For some this definitely is not a new concept, if so please do ignore this post :) . Iterative development as i see it is not necessarily a process by itself but we can incorporate it to any of our current processes in order to maximise efficiency and throughput.

If we look at a project at a very basic level what needs to be done in order to complete it successfully is to develop a product/application which meets all/most of the user's needs within the time line given by the user and within the budget specified. How some people approach this kind of problem is by trying to figure out all of the customer requirements before even writing a single line of code or design document and spend a considerable amount of time in that process. But what they later find out is that customer requirements never stay static because of the fact that even the customer would not know what he wants as the project is initiated. What this kind of process results in is developing a product/applications which does not meet most of the user's needs because of the fact that we lose contact with the customer after the intial rigorous requirement gathering phace and only come into contact once we go through the full cycle of the the development process.

But what we need to do is to break up whole project into smaller iterations and thereby do repetitive requirement,design,development,testing cycles in each iteration. What this kind of approach gives is the ability to get customer feed back after each iteration where the user can say if we are on track according to his/her needs or not and we can then refine our next iteration incorporating these changes. By following an iterative development process we surely are able to stay on track in most cases and meet the project deadlines without out burning the development team.

More on how to approach iterative development and how to incorporate new customer changes half way through an iteration and how to project your iteration size can be seen in the coming articles... So stay tuned ;)

Thursday, August 6, 2009

JavaScript instance methods vs Class methods

Javascript instance methods are those that start with the "this" keyword where as class methods start with the prototype keyword. The difference between the two is that given an object instance methods are created per object whereas class methods are only one per class and not per instance so you will avoid creating duplicate object methods. Examples of the two are as follows;
 
1. Instance method example
 
    this.getName = function(){return this.name;}
 
2. Class method example
    //ObjName is the name of your object
    ObjName.prototype.getName = function(){return this.name;}
 
There is another method which is a class only method. The only difference with that is that it cannot access instance variables like the class method above but can only access class only variable. Example is as follows;
 
//this is a class only variable
ObjName.prototype.name = 'test';
/*Note that to get the class variable you have to drill down to the prototype object and you cannot access instance variables in class only methods. Only difference between this and the previous method as you can see is that it does not include prototype keyword.*/
 
ObjName.getName = function(){return ObjName.protype.name;}
 
But one thing to keep in mind is that the fact that the prototype keyword is not sometimes supported by older browsers.

Wednesday, August 5, 2009

Java Script Date Object

Java script consist of a Date object which is kind of similar to the Java Date object where as it uses the time since the epoch but some utility method available in the Java language are not available in the JS Date object version. Some of the utility method which i cared to share are as follows;

getDate() - Get the day of month e.g 1-31
getMonth() - Gets the month of the year. Note that it starts with 0-11 So Jan is basically 0.
getFullYear() - Gets the current year as a four digit character

Also we can pass the date as a string literal to the date object as new Date("08/09/2007") which it will convert to the intended date time. It also consists of a toString method which is a bit too cryptic and should not be used when showing specific date objects. The above in-built methods should be used instead to show the user a properly formatted date.

How do you get teh number of days between two days;

This can be done as follows;

//Assuming that date 2 is after date 1
function(date1,date2){

return Math.round( (date2-date1)/(1000*60*60*24));

}

Java Script Array Sorting


Java scripts have intrigued me!!!As so far as me going to the book store and selecting java script books to learn it the old fashioned "Off the shelf" way ;) ... So some of my posts from here onwards will contain a mix and match of java scirpt/java so any anti javascript ppl please dnt take it personally :D.... I never knew java script had array sorting like whats available for us java developers. Two ways this can be accomplished..

Method 1:

//Sorts values in descending order
function compare(val1,val2){
return val2-val1;
}

var myarray = new Array([1,3,7,10,32,45]);
myarray.sort(compare);

Thats about it to do sorting using arrays. Of course you could have just used myarray.sort() which would have used the default sorting mechanism and sorted the array in ascending order. You could debate here saying why do we need to define a new method just to get the sorting done. Bit too much code to do a single sorting function. Well look no further method 2 below shows how to do the same thing as above with just one line of code using the function literal capability of Javascript.

Behold Method 2!!!!!!! (Drum roll please)
Method 2:
myarray.sort(function(val1,val2){val2-val1});


Thats about it for now. But more to come very soon guys. So stay on the look out for all those Java script newbies like myself :).

Cheers

Sunday, August 2, 2009

String concatenation and String builder confusions resolved


There was a very hot debate going on about String vs String builder and doing string concatenation within the append method of the String builder. I then researched this topic on the net because i had to prove a point in my work area ;) ... Then i stumbled upon this great blog post which i thought i should share with all of you which clearly explains when and how to use these String concatenation methodologies. And thankfully i was right in my assumptions :D.... The blog post can be found at http://www.znetdevelopment.com/blogs/2009/04/06/java-string-concatenation/

Friday, July 31, 2009

@BatchSize() Annotation in hibernate

While searching on the net on how to gain perfomance in JPA/Hibernate i stumbled upon an article written on hibernate annotation batchsize and it intrigued me on how it really works. After reading on and going through the algorythm defined by Hibernated on how it works i understood that this adds a sufficient perfomance gain in the event of you having large collections within your entities.

 --------Updated on 07/30/2012 according to the clarification given by Jeremy---------

For example lets consider an Airport parent containing a collection of airlines as such;

    @OneToMany()
    List<Airlines> airlines = new ArrayList<Airlines>();
Imagine you had such a statement in one of your entities. Assume there can be 100 Airport objects at any given time.Without the BatchSize annotation, Hibernate will first retrieve the Airports separately and for each airport it will retrieve the airlines separately. Now consider the following code snippet;
    @OneToMany
    @BatchSize(size=16)
   List<Airlines> airlines = new ArrayList<Airlines>();
When you use the batch size annotation what hibernate does is it divides the number of elements that would come in the resulting query by the batch size defined. In this case its 100 / 16 so you get 6 and remainder 4. What this implies is hibernate will go to the database 6 times to fetch 16 Airport objects' with their Airlines collection initialized and then go again another time to retrieve the remaining 4 Airports again with their Airlines collection initialized. So what the @BatchSize does is decide how many collections should be initialized.