Saturday, 6 October 2007

Microsoft Releases .NET Base Class Library Source Code

According to an email from Scott Guthrie and announced Wednesday AM - http://weblogs.asp.net/scottgu, the .NET framework 2.0 source code has been released under a limited license.

According to Scott:

"As part of our first source release we'll be including the source for the BCL (base class libraries), ASP.NET, Windows Forms, WPF, and ADO.NET. We'll then be enabling more libraries next year. All source will be released under a reference license (which means the source is for reference use only - not for modification, rebuilding, rebranding, copying, etc)."

So it is nice to now have the source code in an easily accessible fashion (Java has had source code opened up for years). However, we could already use .NET Reflector (one of my favourite .NET tools) to see the source code. So what does it mean to have access to the source code?

  1. The big plus is for use in debugging when you need to step through and see what a framework is class is doing. An awesome feature in the final release of 2008 will be the option to download the framework source code while you are debugging! - http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx
  2. It is good to learn how things are written so you can write better code in a consistent manner,such as the Provider model when Microsoft opened that up for users to create their own.

Friday, 5 October 2007

"No Battle Plan ever survives contact with the enemy"

"No Battle Plan ever survives contact with the enemy" - Helmuth von Moltke the Elder
Recently, I was asked a question about my estimate for fixing and rewriting a property valuation system in Melbourne. I created the estimates after a 5 day specification review of their 26 applications (some of the apps had 300+ aspx pages and 200 user controls) and 20 SQL 2000 databases.

The client was concerned that one of the releases in the project was going to go 30% over the original baseline figure (of we warned the client before this happened - that is why he raised his concerns). He reasoned to me: surely after 5 days of doing the original spec review, I should have been able to give them an accurate estimate for the 6 month project.

This project has highlited some of the hazards that go with estimation - in particular - projects that deal with code written by other developers. The truth of the matter is that it is MUCH more difficult than for estimating a new application. In particular, every line of code can potentially be a shock or a nightmare.

This brings me to offer the quote "No Battle Plan ever survives contact with the enemy". In my case, this skirmish was against buggy code from a stream of developers that had "contributed" their expertise (or lack thereof) to the group of applications. Project Managers be warned! For normal projects, you take the your/the developer's estimate and double it. When you are dealing with other peoples code, I would say it is safer to triple it.

Another point that was also raised that "builders and construction companies give accurate estimates. If they can give a fixed cost for this project, then why can't SSW?"

I believe there is a fallacy amongst the general population (especially within the IT industry) that somehow builders and construction workers give accurate estimates. Nothing could be further from the truth. My boss was given an estimate by a builder for home renovations - that it would take $20K to complete the work on his house at Coogee. $200K later, they were about half way there. All the construction work I have had done (e.g. bathroom renovations) has had "unforeseen problems" and has costed more than what I expected. In fact, there a people paid in the construction industry purely to say whether work is "additional" and will cost extra or not. This is a testament to the fact that the scoping of building projects is innacurate - and often deceptively so. I wouldn't be surprised if a construction company found out a way to make a roof an additional item for a building!

The best thing that a Project Manager can do (in IT, construction or otherwise) in giving estimates is to be transparent and truthful with the client and to break down the project into as many finely grained tasks as possible. Price each component individually. This forces the estimator to examine the project with a fine-tooth comb before one line of code is written. If estimates are broken down an substantiated, then they can be more accurately analysed so we can learn from our triumphs and mistakes (aka underestimates).

Microsoft AJAX Toolkit - using the AutoCompleteExtender without a web service

The AJAX Control Toolkit sample site instructions (http://www.asp.net/ajax/ajaxcontroltoolkit/samples/) do not make it clear that you can use the AutoCompleteExtender without a web service. This is possible without any additional coding. Here's the trick:
  1. Remove the ServicePath from the extender attributes altogether.
  2. Specify the name of your method in the ServiceMethod attribute,
  3. Add your method call to the script of the page itself. It will not work with a codebehind directly. For example:

Put this code in the page markup:
<script runat="server">

[System.Web.Services.WebMethod]

[System.Web.Script.Services.ScriptMethod]

public static string[] GetCompletionList(string prefixText, int count)

{

return "this is sample text".Split()

}

</script>

Also make sure you set the service method to the function name and omit the ServicePath :

<cc1:autocompleteextender id="AutoCompleteExtender1" runat="server" behaviorid="AutoCompleteEx" targetcontrolid="txtOrderNumber" ServiceMethod="GetCompletionList" CompletionInterval="500" EnableCaching="true" CompletionSetCount="20" DelimiterCharacters=";, :">

Saturday, 8 September 2007

Move over Flash...Silverlight 1.0 Released!

Silverlight, Microsoft's latest rendering technology for HD video, interactive applications (and much more) has finally reached release version 1.0. I see it as a move by MS to overthrow Flash as the streaming video and 'widget' provider of choice. See http://silverlight.net/ for more details. The best part is that it has C# support on the client side! The Silverlight 1.0 Runtime can be downloaded from http://www.microsoft.com/silverlight/downloads.aspx. Expect to see a stack of video content and online games coming out with this technology.

Cool new image resizing technology - Seam Carving Rocks!

This amazing new image resizing technology allows you to resize a picture without decreasing the size of the contents. It does this by adding or removing "unimportant' slices running across a picture (e.g. portions of sky). There is a whitepaper on the technology here http://www.seamcarving.com/. There is an interactive flash demo that has to be seen to be believed! - http://swieskowski.net/carve/. In particular, try the horizontal carving. It looks natural and still has all the proportionally correct primary elements of the picture. More links can be found here: http://drawk.wordpress.com/2007/09/04/as3-content-aware-resizing-or-image-seam-carving/

Dedicated hosting on the Cheap

I am currently with http://www.ixwebhosting.com/ for my simple site www.ddkonline.com - who offer some very good value plans (e.g 300GB of storage, 1500 GB bandwidth for about $10 AUD per month). However, they have been promising to move to ASP.NET 2.0 for months with no result. With a mind to moving to a dedicated server, I happened upon http://tips4hosting.blogspot.com/2007/04/cheapest-dedicated-servers.html with some of the cheapest (unmanaged) dedicated servers around. However, the price increase (approx 15x) for a similar spec is a bit to steep to justify the benefits of a dedicated box. Looks like I'll just have to move providers - or encourage the current provider to move into the 20th century!

Wednesday, 5 September 2007

Dynamic SQL WHERE Clauses without sp_executesql

I was asked again today about doing dynamic where clauses without using sp_executesql. See below for my previous answer (19/10/2005). The only thing I would suggest now is to improve my suggestion below is to make the statements even more readable with the ISNULL() statment:

e.g. AND USERNAME >= isnull(@FromUser , uSERNAME). See below for more details.

---ORIGINAL RESPONSE---

I used this a few years ago at Kanes Hire, but I found it quite useful again at Multibase:

If you have a search screen, but want to show ALL records if a parameter is NULL, you can use the following (without IF…THEN conditional logic):

(The trick is that the case statements always resolve to true when the parameter is NULL) – so the criteria is effectively ignored, just like an “ALL”. Seems to perform well on the small queries I used here.

SQL:
AND UserName >= CASE WHEN @FromUser IS NULL THEN UserName ELSE @FromUser END


CREATE PROCEDURE up_StampingReport
@FromDate datetime,
@ToDate datetime,
@FromUser varchar(255),
@ToUser varchar(255),
@IsOutsideSLA varchar(255),
@Rework_Count int,
@TransactionType_ID int,
@IsMatterWithClient char(1),
@IsMatterWithPerpetual char(1)

AS

SELECT *
FROM VW_STAMPREPORT
WHERE
(Expected_datetime >= @FromDate AND Expected_datetime <= @ToDate) AND UserName >= CASE WHEN @FromUser IS NULL THEN UserName ELSE @FromUser END
AND UserName <= CASE WHEN @ToUser IS NULL THEN UserName ELSE @ToUser END AND IsOutsideSLA = CASE WHEN @IsOutsideSLA IS NULL THEN IsOutsideSLA ELSE @IsOutsideSLA END AND Rework_Count = CASE WHEN @Rework_Count IS NULL THEN Rework_Count ELSE @Rework_Count END AND TransactionType_Id = CASE WHEN @TransactionType_ID IS NULL THEN TransactionType_Id ELSE @TransactionType_ID END AND IsMatterWithClient = CASE WHEN @IsMatterWithClient IS NULL THEN IsMatterWithClient ELSE @IsMatterWithClient END AND IsMatterWithPerpetual = CASE WHEN @IsMatterWithPerpetual IS NULL THEN IsMatterWithPerpetual ELSE @IsMatterWithPerpetual END GO

Wednesday, 29 August 2007

Sharepoint 2007 Content Type Templates Suck

One big issue I found out today RE: MOSS 2007 is that there is only ONE template per content type. I think this is a serious limitation - and prevents us from moving word templates into Sharepoint. In particular, we really would like the content type of "Fax" to be able to have 3 different templates when you create a new document in Sharepoint. e.g. end user fax, business-to-business fax and legal fax templates. There would of course be a default template per content type so you don't have to choose every time if you don't want to.