November 2005 - Posts

Slice the Work Vertically, Not Horizontally .. IoC/DI Frameworks

I have been debating with a client about how to 'slice up' the implementation of a piece of software development/ refactoring. Some folks on the client team were advocating what I consider to be a fairly deadly approach to developing software. They were basically advocaing a waterfall-ish approach to developing the software... Build the backmost layer 1st, then the next, the next, you get to the UI in the end, etc.

I stumbled across this http://codebetter.com/blogs/jeremy.miller/archive/2005/11/26/135098.aspx blog entry from Jeremy miller. He is on my feed list these days.... And I quote....

Slice the Work Vertically, Not Horizontally

The metaphor of software development as construction is common, but horribly wrong.  Approaching software development as constructing a structure on top of a foundation, then adding the finishing trim can be a slow, painful path to project failure.

Time and time again I’ve learned or observed that projects go much smoother when you build vertically instead of horizontally.  What I mean by this is that you build a new system by creating a feature at a time with the entire stack of UI, business logic, and database work to make the feature fully functional.  As you build new features you religiously eliminate duplication to avoid creating a Stovepipe anti-pattern and harvest reusable code.

 

One of the more disappointing project failures I’ve observed was the very first .Net pilot project in a VB6 shop.  I wasn’t involved with the project, but I had a stake in the project as it was going to prove the viability of .Net for application development and also be a pilot for doing iterative development.*  Unfortunately they blundered by crafting an iteration plan that called for them to write the entire data access layer first, the business layer second, then finally put together the user interface.  It failed miserably.  When the project was cancelled midway they didn’t have the slightest bit of deployable code because they had focused solely on the backend database.  One of the other things they found out was that the data access they coded wasn’t exactly what the business and UI layers needed.  In other words, they had wasted effort by speculatively creating code that turned out to be unnecessary. 

He hit the nail on the head. YOU NEED TO HAVE DEPLOYABLE CODE ALL THE TIME. The risk of waterfalling is all or nothing. Either you finish the building, or you do not. I was just happy to see someone else using my terms exactly "Slice the Work Vertically, Not Horizontally" to describe how to do development work!!! The whole article is actually great - I suggest the full read.

He also references in this blog entry one of my favorite papers http://www.objectmentor.com/resources/articles/Principles_and_Patterns.PDF . Read it if you have not :)

He also references using IoC/DI frameworks. Please - dev community - get behind IoC/DI frameworks and ideas. Seperation of implementation and abstraction is KEY and these IoC/DI tools REALLY help make this stuff a help you!

All in all - he touched on a few near and dear to my heart items. I just had to give my 10 penny commentary :)

-CD

Model/ Domain Objects vs DataSets

Well - here it is - Objects vs DataSets - Especially in a situation where you are not accessing a database directly, I do not get why you would use datasets at all. In a situation where your service tier is sending you back 'objects' - I also do not understand why you would use datasets. It seems like a mismatch to me. That being said - I believe if you are directly connecting to the DB, then it makes sense to use datasets. That is the end of the story as far as I am concerned. Furthermore - in 'higher performance' applications - you must use the datareader - whereby rendering the dataset unusable. In the past I led deams building the 30th and 60th busiest sites on the web. In these types of situations - datasets are a dog compared to the readers. So - we went with 'custom objects' and collections. All of this being said - since I tend to be an object modeler 1st, and I have worked mostly on larger apps - I have not used the dataset too much. In essence, this DOES put me on one side of the argument - so I am looking hard and trying to understand why using datasets is so great. Any feedback from anyone would help. So - below is reference to many of the folks that have raged this debate in the past.

I again must say that even though I am looking to 'get' the dataset argument - I am still not sold :) Someone educate me - I just do not get it.

Other references to people waging this war:

Objects vs. DataSets - Is it Really About the Technical Aspects?
excerpt:
I find that that the most interesting reasons for choosing Objects vs. DataSets are less technical, but more about the project, the developer's methodology, and the developer's preference.  The technical reasons for choosing one over the other are pretty weak and can be resolved pretty easily.

My 2 Cents :
I guess I can acept this. I do believe that in a quick and dirty situation - datasets win. Maybe some would argue that the level of developer would favor the dataset solution - the custom object solution REALLY seems simpler to me - I guess I am just biased.


Displaying aggregates: DataSet vs. Domain object performance
excerpt:
.... I work with someone who coded a bunch of stuff using a dataset. unfortunatly, due to the complexity of the project we have to scrap all that code. Custom classes will make everything we needed done so much easier and cleaner.

My 2 Cents :
I MUST say that I totally agree with this comment. In essence I believe that classes are more natural, cleaner and in the long run - you can just embed more knowledge in them. Data sets are containers - classes are the model. I also believe that the class approach - you continually refactor and the solution is flexible - not rigid... Again - I am just biased - someone compel me for datasets....


DataSets vs. Collections
excerpt:
Both DataSets and custom classes don't limit what you can do in any way, and both can be used to accomplish the same aims. That said, DataSets are fantastic tools for prototyping applications and represent excellent solutions for building systems in a kind of emergency—a limited budget, an approaching deadline, or a short application lifetime. For relatively simple applications, custom entities add a perhaps unnecessary level of complexity. In this case, I suggest that you seriously consider using DataSets.

In the economy of a large, durable, complex enterprise system that takes several months to complete, the cost of architecting and implementing a bunch of collections classes is relatively minimal and is incurred only once. The advantages in terms of performance, expressivity, readability, and ease of maintenance largely repay the investment. You are not bound to a tabular rendering of data. Business rules and custom business entities can't always be adapted to look like a collection of tables. In general, you should avoid adapting data to the data container—quite the reverse, I'd say. Finally, using custom classes makes for easier unit testing because classes and logic are more strictly related than with DataSets.


My 2 Cents :
Dino is the man 1st off - 2nd - I REALLY agree with this statement as just about the best summary of all. This is what I truly believe. Dino also mentions generics in 2.0 and how much stronger the argment for classes/ collections becomes under the 2.0 framework.....


On the Way to Mastering ASP.NET: Introducing Custom Entity Classes
excerpt:
There are a number of situations for which DataSets are particularly well suited, such as prototyping, small systems, and support utilities. However, using them in enterprise systems, where ease of maintenance is more important than time to market, may not be the best solution.

My 2 Cents :
Man - I could excerpt this entire article. Read it - it really sums up my viewpoint as well.


DataSets Are Not Evil
excerpt:
Ok that's it, everybody stop talking smack about the DataSet. As self-elected chairman of the inexistent "DataSet Preservation Fund", I feel urged to respond to years of incorrect positioning, biased thinking and over-simplified black-and-white views. I won't allow the "enterprise community" to make the DataSet the Clippy of .NET, so to speak.

My 2 Cents :
THis guy basically takes the other side of the "On the Way to Mastering ASP.NET: Introducing Custom Entity Classes" article - he does a weak job if arguing frankly.... Someone show me the dataset side of the argument please.. Still dont see it.


Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World
excerpt:
DataSets are bowls, not fruit. Do you really want to return bowls?

A DataSet is an object, right? But it's not a Domain Object, it's not an "Apple" or "Orange" - it's an object of type "DataSet." A DataSet is a bowl (one that knows about the backing Data Store). A DataSet is an object that knows how to HOLD Rows and Columns. It's an object that knows a LOT about the Database. But I don't want to return bowls. I want to return Domain Objects, like "Apples."

My 2 Cents :
Yes yes yes.... Yes yes yes...


Datasets vs. Custom Entities
excerpt:
  • They are very bindable. (I will give the dataset folks this - the tools do provide this. There are ways around it however - 2.0 has the ObjectDataSource and Infragistics has the excellent - WinDataSource that is useful to make 'objects' bind to grids easy as pie.)
  • Easy persistence. (IF you are directly connecting to the DB....)
  • They are sortable.(yes)
  • They are filterable.(yes)
  • Strongly Typed Datasets defined by XSD's.(yes... better but 99% the rest is the same to me.)
  • Excellent XML integration.(eh, I guess so.. still not 'nice' XML. It is generic XML - not XML for your nice object.)
  • Computed Columns (OK - objects do this all the same - just as well - or better depending.)
  • Relations (OK - objects do this all the same - more explicitly I would say)
  • Data Validation (OK - objects do this all the same - mostly better)
  • AutoIncrementing values (OK - objects do this all the same - this is trivial)
My 2 Cents :
OK - this guy has the BEST set of arguments for the dataset way. I do hear the arguments to some faint degree - but - not very strong still.

Microsoft Lauds 'Scrum' Method for Software Projects

Microsoft Lauds 'Scrum' Method for Software Projects.

I have been scrumming for some time now - the folks at Finetix (my most excellent employer) are proud Scrum folks as well - with quite a few certified ScrumMasters

See Slashdot.org post
at EWeek

Why coding standards??????


From: sun
        Why have code conventions? Code conventions are important to programmers for a number of reasons:

  • 80% of the lifetime cost of a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
From: My fav
  • Avoidance of errors/bugs, especially the hard-to-find ones.
  • Maintainability, by promoting some proven design principles.
  • Maintainability, by requiring or recommending a certain unity of style.
  • Performance, by dissuading wasteful practices.
  • Rules and recommendations are given that promote reliability and maintainability.

From: ambysoft
Why Coding Standards are Important
Coding standards for Java are important because they lead to greater consistency within your code and the
code of your teammates. Greater consistency leads to code that is easier to understand, which in turn
means it is easier to develop and to maintain. This reduces the overall cost of the applications that you
create.
You have to remember that your Java code will exist for a long time, long after you have moved on to other
projects. An important goal during development is to ensure that you can transition your work to another
developer, or to another team of developers, so that they can continue to maintain and enhance your work
without having to invest an unreasonable effort to understand your code. Code that is difficult to
understand runs the risk of being scrapped and rewritten – I wouldn’t be proud of the fact that my code
needed to be rewritten, would you? If everyone is doing their own thing then it makes it very difficult to
share code between developers, raising the cost of development and maintenance.
Inexperienced developers, and cowboys who do not know any better, will often fight having to follow
standards. They claim they can code faster if they do it their own way. Pure hogwash. They MIGHT be
able to get code out the door faster, but I doubt it. Cowboy programmers get hung up during testing when
several difficult-to-find bugs crop up, and when their code needs to be enhanced it often leads to a major
rewrite by them because they’re the only ones who understand their code. Is this the way that you want to
operate? I certainly do not.

From: macadamian
At Macadamian we've always believed the path to enlightenment starts with a solid set of Coding Conventions.

From: chris-lott
When a project tries to adhere to common standards a few good things happen:
  • programmers can go into any code and figure out what's going on
  • new people can get up to speed quickly
  • people new to C++ are spared the need to develop a personal style and defend it to the death
  • people new to C++ are spared making the same mistakes over and over again
  • people make fewer mistakes in consistent environments
  • programmers have a common enemy :-)
From: extremeprogramming.org
Code must be formatted to agreed coding standards. Coding standards keep the code consistent and easy for the entire team to read and refactor.
 
 
PS - this is an extreme admonition - PROJECTS NEED CODING STANDARDS!!!!!

Code standards, casting and other bags o' worms

I was doing some pair programming with a dev from my current client's UK office the other day. I had an immediate set of reactions when coding for the 1st time with a person I have never programmed with before. We had a quickie debate on casting style - c style vs 'as' style casting. I am generally an 'as-ist'.

Coding style is something to talk about for sure. In the past - I have been able to just basically mandate standards. On my new project - I have the intersting challenge of convincing people that 'my' coding standards are useful. There are a few things that have come under debate lately.

1st - the common and dreaded _ vs no _ for class member variables. I am in the no _ camp, the folks on my current project have been pro _ .

  class Foo
{
private int _aThingId = 0;
// vs.
private int aThingId = 0;
...
...
}


2nd - I was arguing for the performance of casting. I could not recall an article to support my viewpoint that using 'as' style casts was prefereable for speed and also in order to remove those nasty 'ice's (invalid cast exceptions). 'as' is especially more performant when comparing vs 'is' compare THEN c style cast. Anyhow an article supporting the speed of 'as' vs c style casting is right here

  class Foo
{
private void DoSomething( object foo )
{
Foo f = foo as Foo; //(null check later for invalid cast - no exception)
// vs. (potential invalid cast exception)
Foo f = (Foo)foo;
// or
Foo f;
if( f is Foo )
f = (Foo)foo;
}
...
...
}


3rd - using 'this' all over the place as an alternative to _ or simply in addition to _ in a class. I claim 'never use this' except in the ctor. 

  class Foo
{
private int val = int.MinValue;

/// this is OK by me and all others
public Foo( int val )
{
this.val = val;
}

/// this is NOT OK by me and many others
public void DoSomething()
{
if( int.MinValue == this.val )
{
//Do something useful
}
}
...
...
}
From my favorite C# Coding Standards Spec. :

"3.2.32. Rule 3@505: Only use the this. construction to avoid a name clash
Do not use the this. construction to dereference members. The use of this is only allowed as a reference to
the current class instance or to prevent name clashing between method parameters and class fields."

I am sure there will be many more coding standards debates. I am sure that I will win some and lose some. I tend to be code anal. I hope that I can lighten up enough to play nice :) Either way - I am sure that we will be turning out lots of higher quality code for the project.....

More to come...
-CD

I Got the Clearcase/UCM Blues too

Oh how I echo my colleague's thoughts!!!

Marc

We are surely suffering!!! - Oh how I long for my friend Perforce!!!