Khangharoth

October 16, 2011

TDD Red-Green-Refactor – Missing Refactor step

Filed under: Software Design — khangharoth @ 3:24 pm

The code base of our project does not  look any bit like Uncle Bob’s  clean code examples – Why ?

This question was in my mind for long –

In spite of doing TDD where everyone writes tests first then why our code base is still sub standard ? Why we have lots of disjointed test cases and code base which is not cohesive ?

Initially the answers I was getting from myself were :

a) May be what works for  a simple one class problems don’t scale for big projects.

b) But then their are parts of our System which are beautifully written(done by a individual ) – So this process is working for  some and not for others .

What if those guys would anyway write better code than rest of us – be TDD or not ?

With all these questions in mind – I took  a SVN update to start on a Jira (bug) . When I looked at the relevant class  – It took me around 10-15 mins to understand what it was doing and the fact that it had test cases made no difference in my ease of understanding that piece of code.

How can we invariably ends up with something like this – Even though we are doing everything right ? – I went through svn check-in history something  struck to me – We Are Missing The All important step of Refactoring !

When we learn about TDD – its being taught as Three Simple Steps

RED – Green -Refactor

But when we started using it , we reduce it to just two step !

Red-Green  , Red-Green , Red-Green – The important step which binds everything together and which gives shoulder to the Simpleton Advice (do the simplest thing to make the test pass) to stand on , Refactoring, is actually being forgotten .

If you and your team is new to TDD process – Make sure that you are also not missing the integral step of Refactoring !

Advertisements

October 31, 2007

High Performance Web Sites

Filed under: Software Design — khangharoth @ 1:24 pm

This is the name of Book written by Steve Souders, Chief Performance Yahoo.

Well it does give another view to the problem , what is seems as most of the time we only for known culprits like Database queries etc whenever we are on any Performance drive. And invariably the responsibility is of back-end developer to increase the performance.

Most of the Stuff was  new to me , as how diverse the problems can be .

Haven’t got the Book Copy : Need to find out ,Its tough to get these kind of books in India!

But to get  Gist , you can go through  this review : http://www.theserverside.com/news/thread.tss?thread_id=47378

Also this http://developer.yahoo.net/blog/archives/2007/03/high_performanc.html 

Now i am curious as what sort of Architecture these Top sites have : Also Do Java has any role into it ?

October 18, 2007

Software : Time and budget estimation.

Filed under: Architecture,Software Design — khangharoth @ 3:30 am

In continuation of my previous blog about “Failure of Software Project” .

This one topic has really amazed me as people are able to estimates such huge building with such good accuracy.How many times you have heard in News that this Stadium will be ready by this date with these functionalities and they do deliver.Also in these situation maximum worst that happen is delay,but vary rarely whole thing gets scrapped,but this happens in Software Industry all the time!

Is it to do with Team-Work as this industry very much reward individualism  and so you will see lot’s of Talented guys who can single handedly deliver a small to Mid Size project.But a team of 5-6 of them fails to deliver some what bigger application.So is this why Failure rate of Software is directly proportional to its size.

And if this is one of the reason why people in other industry can work so well in Teams?                                                             One of the answer i have in mind is  as this Industry pays a lot and this could be a simulator for  Huge Ego and individualism.

Well these are all guesses and it may be that  inherent process of Software development is difficult and hence  this gap’s in estimation’s.

So why estimation of Software is so hard,well the point is “Software is Hard”.In Maths we know that in any equation as we have more and more variables,prediction is less and less accurate from couple of variable values in hand.

To read more on this subject , i regularly search internet and  today stumbles upon this.I think its quite a bold statement and also very close to reality.

It is impossible, by examining any significant piece of completed code, to determine within a factor of two how many man-hours it took to produce that code.

And the corollary:

If you can’t tell how long a piece of code would take when you have the finished product available, what chance do you think you have before the first line of code is written?

My first response to this : am reading the above line’s again and again,Isn’t it true?

May 6, 2007

Failure Of a Software Project

Filed under: Software Design — khangharoth @ 5:40 pm

Last night i was having a chat with one of my former college and he was telling me about his project being scraped and how this has resulted in undue pressure on them and effecting moral of the entire team.

What really amaze me is that how often i hear these stories,and is their any other industry with failure rate as high as Software.

I did some googling to come up with some solid numbers and was totally aback to see overall software failure rate is around 63%.Here the guideline is that any software which has not covered its investment cost will be considered as failure.What is more astonishing is around 46% of software are never completed or delivered to client.

Now what makes Software field so different from other processes like Manufacturing or say Construction.These disciplines have really shown a commendable success with even very complex set of problems.Here i would like to quote from one of my favorite blog Coding Horror.
I don’t think bridge building has anything in common with software development.* It’s a specious comparison.
Software development is only like bridge building if you’re building a bridge on the planet Jupiter,
out of newly invented materials, using construction equipment that didn’t exist five years ago.

I can understand the frustration of any Software developer when our process is compared with other Industries and people start uttering words like assembly-line,automation,Six-Sigma etc.I really like assembly-line comparison because its really funny.Let me explain you:

           The argument is that Industries like automobile have perfected the art of making automobiles to such an extent that a new Car is roll out in less than 3 minutes from a assembly line.

                                                       Now my response is the time we are talking about here is time taken to make a duplicate copy.In automobile industry also to churn a new model still takes more than a year.Now if apply this logic than how much time we take in making a copy of a developed software.It took Microsoft around 5 years to comes with Vista but how much time will they take to come up with say 1 billion copies of Vista,sorry folks this is not the way you can compare things.

But still question ,why Software projects fails so much is very important,as their is lot of money involved with it.You can read some research finding here to get some feel about this question Failure Rate.I’ll just highlight some important findings:

  • An IT project is more likely to fail than succeed.
  • 20% projects can be termed as successful.
  • The larger the project the more likely is the Failure.

And i would like to add my favorite “The More MBA’s are in a project,the more likely is the failure” ,that’s why companies like Google don’t hire MBA’s but promote internal technical people to manage Projects.

My list of reason’s about this:

  • Lack of Career path for technical people.At some point of time they have to move to managerial level to advance their careers.Companies like Google and Microsoft are noticeable exception to this.
  • Specially in Indian Context:A person with 5 years of experience rarely codes.So coding is always done by freshers ,who are learning about How To Code.No matter how good is the design if the people who are actually writing the code are not experienced than we know what to expect from code!
  • Mad rush for Cost Saving and buzz word like Out-Sourcing and off-shoring.A software projects has two type of costs ,Real or upfront cost and hidden or maintenance cost.One should include both the costs and not just see that in location X we can hire developer for pennies.
  • Unrealistic Time lines:Every Software when developed is happening for the first time so add uncertainty factor in your time lines.The more same kind of projects you will take ,the less will be the uncertainty factor.

What i think about how to improve this situation:

  • Stringent hiring process.Don’t recruit in masses.One common argument is that we are not able to find good people.If their aren’t good people available than its not the place to be in.
  • Very high emphasis on learning and constant improvement.In-fact the ideal work to learning ratio can be 75:25.This means out of office time ,employees spend 75% of time on active work and around 25% time in improving their skill set.
  • If you have Out-Sourced your project to a vendor than each quarter randomly select some developers from vendor’s developer  list and taking technical test .This will keep your vendor on toes.
  • In software resource planning 1+1 !=2 ,its simply not equal you have to add communication cost and hence bigger the team more is the communication cost in terms of time.
  • 3 average programmers are not better than 1 good programmer .Programming is not a physical task so why compare in physical terms.

what you think?What could be more reason’s and remedies for this problem.I am as much interested to know as you are!

May 2, 2007

Enterprise System Architecture

Filed under: Software Design — khangharoth @ 2:09 pm

Their is very important debate doing rounds on net as what actually an Java Architect (Enterprise Systems) do ?Isn’t Architecture is broader term and should be used independent of Language and so term Java Architect is misleading.

Well what i think is its very difficult to find a person who has no bias of platform and language and this bias comes not because of personnel linking but the person will have more knowledge or have worked on a particular platform more and hence in new coming projects he is likely to choose already tried and used technology .And this loop ends up labeling a person as Java Architect or .net one.

One more interesting point is made at blog Architecture? One size fits all

In this author had boldly proposed a single solution to cater around 99% of Enterprise systems.I am enclosing his diagram and on first look it looks like most of the Systems have same Architecture.

In this also from 10,000 ft everything looks same but real challenge is figuring out technology from plethora of choices .Problem of plenty is valid especially in Java.What was supposed to be strength of Java has becomes its Achilles heel.

Its time when big guns like Sun,IBM,BEA ,Google sit together and standardize common choices.

But than it is the completion and open-source which will determine shell-life of any new technology.

April 6, 2007

Comment your Code

Filed under: Software Design — khangharoth @ 1:21 pm

After three years of Software experience now i am finally able to understand the importance of commenting the code.

And its not for other guys ,its for you also.That more complex is the piece of code in terms of businesses requirements harder it will be for you to understand after say 6 months.

Also while commenting emphasis should not be much on technical details as but more on business requirement.While coding initially you thought some common solution will solve this problem but after getting all the requirements you realized that this is a special case and hence need some weird logic.Document it ,because chances are the everybody else and you also (after 4 months ) will again think why can’t this be done in a simpler way.

I sometime back read somewhere on net

Good programmers comment their code.

Great programmers comment on why they choose a particular implementation.

Master programmers comment on why they didn’t choose other implementations.

This can be a good philosophy for commenting your good.

December 16, 2006

A Thing called UML.

Filed under: Software Design — khangharoth @ 8:30 am

UML

What is UML?

a) Was released in 1997.

b) A method to diagram software design.

c) Designed by a consortium of the best minds in object oriented analysis and

          design.

So in all The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive system.”

Goals of UML

a) Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models.

b) Provide extensibility and specialization mechanisms to extend the core concepts.

c) Be independent of particular programming languages and development processes.

d) Provide a formal basis for understanding the modeling language.

e) Encourage the growth of the OO tools market.

f) Support higher-level development concepts such as collaborations, frameworks, patterns and components.


Benefits of UML

a) Your software system is professionally designed and documented before it is coded. You will know exactly what you are getting, in advance.

b) Since system design comes first, reusable code is easily spotted and coded with the highest efficiency. You will have lower development costs

c) Logic ‘holes’ can be spotted in the design drawings. Your software will behave as you expect it to. There are fewer surprises.

d) The overall system design will dictate the way the software is developed. The right decisions are made before you are married to poorly written code. Again, your overall costs will be less.

e) UML lets us see the big picture. We can develop more memory and processor efficient systems.

f) When we come back to make modifications to your system, it is much easier to work on a system that has UML documentation. Much less ‘relearning’ takes place. Your system maintenance costs will be lower.

g) If you should find the need to work with another developer, the UML diagrams will allow them to get up to speed quickly in your custom system. Think of it as a schematic to a radio. How could a tech fix it without it?

h) If we need to communicate with outside contractors or even your own programmers, it is much more efficient.


UML defines the notation and semantics for the following domains:

a) The User Interaction or Use Case Model – describes the boundary and interaction between the system and users. Corresponds in some respects to a requirements model.

b) The Interaction or Communication Model – describes how objects in the system will interact with each other to get work done.

c) The State or Dynamic Model – State charts describe the states or conditions that classes assume over time. Activity graphs describe the workflows the system will implement.

d) The Logical or Class Model – describes the classes and objects that will make up the system.

e) The Physical Component Model – describes the software (and sometimes hardware components) that make up the system.

f) The Physical Deployment Model – describes the physical architecture and the deployment of components on that hardware architecture.

December 13, 2006

Quote On Software design

Filed under: Software Design — khangharoth @ 1:30 pm
  • God and Software Design ,both are beyond the capabilities of human mind.And still both have followers who claim that they knew it all.

As i am sitting in office late at night pondering about the architecture of my current Desktop Application. Its a CAD application with Graphics , 3D-Maths, Dynamic User interaction ,Multi-Threadng : i mean we have all that to make anyone’s mind spin but i am still tryng to make my way through this.

Suddenly a thought came to mind : Had i envisaged the project well , am i sufficiently Zoomed into the Design part ? And how will i be sure that i know my Software well so that their are no nasty surprises in store.

November 25, 2006

Dilemma of Software Design

Filed under: Software Design — khangharoth @ 2:23 am

What is Good Software Design and what are the measuring guidelines
for this ?

In fact how can one be sure that the system is well designed and always ready for that dreaded word CHANGE , and what is the limit of being paranoid and Overkill.

After all like any other task it also consumes resources like Time and Human labor (for sophistication we can use term Man Hours , but personally i hate this term as if Software programming is Seventh standard Work -Time problem)
anyway we come back to our current discussion Design.

So what separates Good from Bad and how to measure the impact on overall system when we choose one over the Other. There are Masters out their who have tried to tame this beast .
So in their language Good Design has

  1. Good design is innovative.
  2. Good design enhances the usefulness of a product.
  3. Good design is aesthetic.
  4. Good design displays the logical structure of a product; its form follows its function.
  5. Good design is unobtrusive.
  6. Good design is honest.
  7. Good design is enduring.
  8. Good design is consistent right to the details.
  9. Good design is ecologically conscious.
  10. Good design is minimal design.

 

Everything is fine although not fine but for time being lets concentrate on number 10
” Good design is minimal design” ,well with this one statement we are back to
square one! I hope you can appreciate the whole irony and it’s not funny either.

I would like to share my views about Design and as i am not Master so keep your mind
open, I can err!

1. Designing is not a Task that had to be done in beginning or end of Software Lifecycle
but it is Rhythm of development and so it needs attention everyday.

2. Whenever their is choice between mind-Blowing and Simple Algo ,
For God sake choose Simple one.

3. Software is like a beast and it will try its level best to not to be tamed.
So always keep hunter and keep refactoring of your code.

4. Size does matter! It sucks; keep your classes’ and methods small.

5. Classes should have only one reason to change and that reason
should be chalked out as early as possible.

6. Allocate extra time in Project Plan for Nomenclature of your classes ,
methods ,variables etc.It may sound funny but if not followed
we end up laughing on ourselves.

7) Algo optimization is million time better than code optimization.

8) Whenever in doubt scream Fire-Fire so that others can come for rescue.

9) While Designing Look Top-Down rather than Bottom-Up ,many of you may
not agree on this but this is what i feel .You got to know “What problem we are solving “,
then “What are the components in action” and ” How these components interact among
themselves” and than “Design Individual components”.

10) Have faith in God and keep praying, it seriously helps!

I have absolutely no idea how much it will help you as i am still as confused as I was in beginning of all this.

April 7, 2006

Tutorial On Observer Pattern

Filed under: Java,Software Design — khangharoth @ 12:18 am

Well to start off …Observer pattern is used when An object needs to notify other object(s) if it changes. .
So observer pattern has

1) Subject or Source : on which any action will happen.

2) One or more Observers : Whom Source needs to notify if any change has taken place .

Algorith Used In Observer Pattern :

1) Source have some properties say private String name, private float price;
2) Source has a collection List say ArralList or Vector .This contains refrences of all the Observers who had registerd with source to get Notified.
3) Source has a addObserver(Observer o) method so all objects which implements Observer interface can get registerd to listen the Notification.
4)Now if any changes will be done on price ,name Source will call notifyObservers() and from the collection list Source knows which all objects needs to be notified.

A sample code will be like

package observer;

import java.util.Observable;

/**
* A subject to observe!
*
*/

public class ConcreteSubject extends Observable {
 private String name;

 private float price;

 public ConcreteSubject(String name, float price) {
  this.name = name;
  this.price = price;
  System.out.println("ConcreteSubject created: " + name + " at + price");
 }

 public String getName() {
  return name;
 }

 public float getPrice() {
  return price;
 }

 public void setName(String name) {
  this.name = name;
  setChanged();
  notifyObservers(name);
 }

 public void setPrice(float price) {
  this.price = price;
  setChanged();
  notifyObservers(new Float(price));
 }
}

———————————————————–

package observer;

import java.util.Observable;
import java.util.Observer;

public class NameObserver implements Observer {
 private String name;

 public NameObserver() {
  name = null;
  System.out.println("NameObserver created: Name is " + name);
 }

 public void update(Observable obj, Object arg) {
  if (arg instanceof String) {
   name = (String) arg;
   System.out.println("NameObserver: Name changed to " + name);
  } else {
   System.out.println("NameObserver: Some other change to subject!");
  }
 }
}

————————————————————————

package observer;

import java.util.Observable;
import java.util.Observer;
/**
*
*
*
*/
public class PriceObserver implements Observer {
 private float price;

 public PriceObserver() {
  price = 0;
  System.out.println("PriceObserver created: Price is " + price);
 }

 public void update(Observable obj, Object arg) {
  if (arg instanceof Float) {
   price = ((Float) arg).floatValue();
   System.out.println("PriceObserver: Price changed to " + price);
  } else {
   System.out.println("PriceObserver: Some other change to subject!");
  }
 }
}

————————————————————————————-

package observer;
/**
*
*/
public class TestObservers {
 public static void main(String args[]) {

  // Create the Subject and Observers.
  ConcreteSubject s = new ConcreteSubject("Corn Pops", 1.29f);
  NameObserver nameObs = new NameObserver();
  PriceObserver priceObs = new PriceObserver();

  // Add those Observers!
  s.addObserver(nameObs);
  s.addObserver(priceObs);

  // Make changes to the Subject.
  s.setName("Frosted Flakes");
  s.setPrice(4.57f);
  s.setPrice(9.22f);
  s.setName("Sugar Crispies");
 }
}

Hope this will give you some insight of Observer pattern……if you need any more help……just mail me

Blog at WordPress.com.