Friday, January 12, 2007

When will that feature in your system will be finished?

That seems like a very simple question: "When will feature "X" be finished?", specially if do not have a lot of experience being the manager of a software development team... but the problem... is that the task of developing a feature has, as many things in software development different faces... its one more example of The Blind Men and the Elephant.

In this case.. when is the feature "finished"?:

  • After the Developer says it is finished?
  • After the Architect says the code is maintainable and extensible?
  • After the Tester says that the feature is bug free?
  • After the User says that the feature meets his expectations?
  • All of the above?
  • None of the above? Then... when: ?

It is easy to see that I believe it is not a question easy to answer... why do believe that?

Well in my opinion the main difficulty to answer it is that that software development is not a linear activity, with a beginning and an end, but an iterative activity, if the Architect doesn't believe the the code is maintainable and extensible, then the code will have to be modified (either by him or by the Developer) and after that, if the Tester finds bugs, the code will have to be modified again to fix the bugs... but those modifications might introduce more bugs to the code, so the code will have to be tested again... its a cyclical process, it has to be done many times before reaching the end, in other words, it is not an "if" answer, but a "while not" answer.

Therefore: effort in trying to reach the end can be registered... but it is impossible to tell how far from the end we are... maybe one, maybe ten, maybe a hundred iterations away.

Friday, January 05, 2007

Is Linq really such a good idea? Are SQL Strings inside C# really such a bad idea?

Today, a friend at work asked me a question "how to sort in a stored procedure?" Of course there is a simple answer:

CREATE PROCEDURE [dbo].[Sorter]()

AS

SELECT * FROM Table ORDER BY Field

 

But... what if you want to order by any field of the table? That is a "dynamic order by"... well then:

CREATE PROCEDURE [dbo].[Sorter](@SortOrder tinyint = NULL

AS

SELECT Field1, Field2, Field3 FROM Customers ORDER BY CASE WHEN @SortOrder = 1 THEN Field1 WHEN @SortOrder = 2 THEN Field2 ELSE Field3 END

Great!... well not that much, because it only works as expected if all 3 fields are of the same type (of course we could convert them all to string... I mean "nchar")

My friend has all this problems because he is trying to avoid the dynamic slq approach (either creating his own dynamic sql generator, or using any of the available ORMs)

But this post is about LINQ... with LINQ, we will have relational extensions right there inside C#... that means no more language mixing (SQL inside strings inside C#)... but that also means... no more dynamic manipulation of SQL (AFAIK C# can not manipulate C# as a string, they way it does with SQL)... So... will LINQ really simplify development of data manipulation applications? or will it complicate it more by preventing us from easly and dinamically manipulate queries ? or is this just an SQL limitation (maybe SQL should allow as to have parametrized sorting?)?

I guess I'll have to do more research...

Wednesday, January 03, 2007

Handling Relative & Absolute URLs with System.Web.VirtualPathUtility

Until today, I translated between relative & absolute paths in ASP.NET "by hand". Example:

 

private string ToAbsolute(string url)
{
if (url.StartsWith("~"))

return (HttpContext.Current.Request.ApplicationPath +
url.Substring(1)).Replace("//", "/");
return url;
}

 

But now, it turns out the with ASP.NET 2.0... I can achieve this effect... by simply calling VirtualPathUtility:

 

VirtualPathUtility.ToAbsolute(url)

 

Much simpler... don't you think?