Saturday, July 28, 2012

The thing called "DESIGN" !

I am greatly confused with this term called "Design".  Recently I had to develop a workflow engine in the quickest possible time. I have a team of 3 people and for 2 of them this is the first software project in their life. 


I started to write Java classes representing the flow model, nodes (tasks) in the flow, the attributes of the model and transition. Then I wrote methods to execute transitions. All in all under 10 classes with 3 to 4 methods excluding the setters and getters.


It took nearly 3 hours to explain them the code and I asked them to write the Hibernate mapping files, DAOs & Services for persisting the model data and for the execution API. Things fell in  place nice and smooth.


The whole thing got completed in 3 weeks.


How much time this could have taken in so called Process Oriented consulting companies?


I would have drawn UML (class diagram and sequence diagram) first as part of my design process. This could have easily taken 2 weeks. Then the developers need to have knowledge in UML to read and understand the diagrams. I could have asked the developers to first write code for the classes. That would have taken another 2 weeks easily. Then comes the persistence and service layer classes.


For me clearly the use of UML here would delay things. Consciously I have avoided this situation by not drawing the UML diagrams. Because I have never seen a case where some one need to draw UML diagrams first before coding.


So, what is that I have seen in consulting companies where there is time allocated as design phase to draw the UML diagrams?


People who stopped coding long ago (5+ years) come out with Class diagrams ( a.k.a High Level Design). People who stopped coding recently(3+ years) start drawing sequence diagrams using these classes. The design tools ( or at least Rational) have 2 types of class diagrams called logical class diagrams and design class diagrams. These sequence diagrams would use both of these interchangeably because none of the logical or design class diagrams would be complete and this happens because (Yes! you guessed it) the designer is not current in coding.


Now, the developers are left free to implement them in the way they want. Introducing instance variables for stateless classes and adding more methods etc.


After some time the design and code mean 2 different things!


But I was taken aback first when i heard the concept of Class diagrams representing HLD and sequence diagrams in LLD. This is completely absurd because sequence diagrams are the unit test cases for your class diagrams and I will not just take Class diagrams from "a" designer unless he draws a complete sequence diagram and prove that the classes have sufficient methods to solve the case. 


People need to clearly understand one thing people who don't know the classes, methods, constructors etc, would not understand a UML diagram and people who understand this don't need a UML diagram. They better can see the code. 


Another fact is that a designer who can clearly think of these can straight away write the code (or at least stubs or interfaces) and leave the rest to the developers. 


Customers wont understand this and developers can understand the code better. More over the developers will be constrained to write the code with in the boundaries set by the designer.


And finally you dont have 2 different work products.


Now, if you go closer and see what type of architecture translates into the design of various systems :

  • There will be classes that are called DTOs. These things have nothing but default constructor and public getters and setters
  • There will be DAOs for CRUD functionality and a service layer which acts like a proxy or some times transaction handler
  • The best improvisation that is done most of the times when the customer (who has a decent developer in their team) complains that the whole code is procedural and not OOP is making an empty base DTO and make all DTOs inheriting from that!

If these are the principles behind the architecture do we really need UML? If a developer works on 2 projects like this he can start writing the code straight away.


Developers and designers work on measurements on two orthogonal axis. Developers top - down or Y axis by length of code and designers left to right on X axis by the length of the sequence diagram.


Developers increase the lines of code by calling innumerable amount of setters. Designers lengthen the sequence diagram by another mile by inserting HTTP objects such as Request, session etc. By showing how the data is stored and retrieved with them.


It leads to every one wasting time on unwanted things and produce non maintainable artifacts. 


Avoid all these and understand that "Code is Design"! 





Thursday, July 19, 2012

I am back!

Again a long break! A hectic and frustrating period. Hectic because i had to find a seat for my son in an engineering college! And a frustrating period in my business!


So, let me talk about the business! In a software consulting and development business there are 2 entities. One (Sales) who gets the customers and tries to convince them that he can get the software built. The other (execution) who actually gets things done that is software built.  The second one should understand the customers business and knows to implement it in software. 


There are execution guys owning and running the company and the sales guys are employed. And there are people who have lot of contacts owning the companies but slightly weak in the are of  getting the software done. Later is the case in a couple of small companies i tried to partner with and bid for projects during this period.


That lead to a lot of slogging and sweat on my part because unfortunately i knew how to satisfy their customers. one was a fruitful and good experience which could lead to a long time association and other one was a complete disaster. And we dropped that opportunity because of lack of transparency on the partner side.


And one of my long cherished desire got fulfilled when I rolled out my own workflow server as part of the project. I have been thinking about doing this for the past 16 years! That was a win!


Now, I have some time to breath and more than this blog I want to continue contributing more towards my other blog (Java in Tamil). Should start blogging during this week end.


So, I have made the following resolutions

  • One new post per week on this blog
  • Two new posts per week on the Tamil blog
  • Be careful in choosing the partners! And be more transparent and upfront with them and also make them do the same to me
  • Find an answer for the problem : Contacts Vs Execution

Let us see how these things work out!