Sunday, December 16, 2007

Bad Code

It happens so , that besides my primary job, I currently have other projects on a side.
One is WTL/C++ , couple more with C#.NET and today I also had to fix some legacy code written with ASP/VBscript that I inherited (very poorly written code).
Yes, that's right VBScript. It would take much longer for my clients to contact the original developers of that code, than me fixing the bug.

After seeing such "masterpieces" from time to time I think I might start to collect them and publish on my blog.


Here is what I found today:
todaysDate = Now()
resultDate = Right(Left(todaysDate,(InStr(1, todaysDate, "/"))-1),3)+1 & "/1/20" & Right(Left(todaysDate,(InStr(1, todaysDate, " "))-1),2)

Isn't that beautiful ?
Try to see what happens with today's date 12/16/2007 ......
.....
bingo 13/1/2007 .... and there is no 13th month.

Whoever wrote the code was relying on particular format of the date, parsing it's string representation, in such a way that makes sane developers cry.


One of the ways to fix it and to get to the same result in this case, would be to do something like:
tempDate = DateAdd("m",1,Date())
resultDate = Month(tempDate) & "/1/" & Year(tempDate)

... and think twice before shopping for cheapest software engineers :)

Monday, November 26, 2007

ASP.NET API incosistency

HtmlAnchor has HRef property, while HtmlLink has Href.

My guess is that some architect at MS left the review board in the middle of the project. Let me know if you have other opinions.
Now MS would have to support this API the way it is.

Wednesday, November 21, 2007

How to remove blogspot's top frame ?

Don't know how long this solution would work.

If you look at HTML source of the page it has the following style that is getting inserted into the web page:
#navbar-iframe { display:block }

So, all you have to do is to add into your blog's template something like this:
#navbar-iframe{
height:0px;
visibility:hidden;
display: none !important;
}
Good Luck!

Tuesday, November 20, 2007

back to blogspot

I'm moving my blogging activities back to blogspot.
It's been more than 2 years since my last post here and I was surprised that my "blogger" account still exists.
The silentcoder.com domain is currently forwarded to this blog and the cached version of the silentcoder.com blog is still avaible through google search.

Will see how it goes from now on.