June 2003 - Posts

Case-sensitive websites

I've never understood why you would want a case-sensitive webserver. ScotG's blog recently mentioned his purchase of an iSight. Since I don't follow Apple hardware (nor Apple in general) I clicked on his link to the iSight, http://www.apple.com/iSight. I got to an Apple page about it being an invalid link. So I went to Apple's product pages and saw a link to the iSight. I clicked on the linked and when it popped up in my browser, the URL looked like the same one ScotG had in his blog. I went back and double-checked his blog entry: iSight vs. isight.

I'm no marketing guy, but if I were Apple and I was selling a product called an "iSight", I would want http://www.apple.com/iSight to bring me to the page for the iSight...

Posted by PSteele | 5 comment(s)

On Code Generators.

AngryCoder: "...the myth of the code generator."

.Avery Blog: "What he misses is that there are code generation tools out there like CodeSmith which make it very easy to generate select parts of your application."

Frans Bouma: "...the article misses the advantages of code generation and how it can benefit you in your daily life. I'd say: the article is totally wrong."

The last company I worked for (back in 1999-2000) produced a code generator. We took a UML model from Rational Rose and generated DB schema (complete with foreign key RI, auto-generated primary keys, etc...), stored procedures and VB business objects. We also had a rudimentary DHTML form designer which could look at one of our business objects and generate a basic UI with query/add/update/delete business logic. We could go to a prospect, create a couple of UML classes, generate all three tiers and demo a working app in about 10 minutes. Sure the UI was pretty ugly, but it was the time savings that our clients liked.

The Angry Coder dismissed the time saving idea because "You've got to pore through the code and figure out what the heck the tool just produced. That takes time." As much time as it takes to start from scratch? I don't think so. And what about templates? He never even addressed that issue and that's one of the things that can negate the "what did the tool just produce" issue. Tools like CodeSmith use ASPX style templates. Our generator integrated with the VBScript engine to do the generation. And you could create your own scripts to tailor the code generation to your liking. That's value.

Is code generation for everybody? Definitely not. I'm not going to try and sell a code generator to a Sam Gentile or an Ingo Rammer. Where we had success was internal IT shops that had to crank out utility apps for departments all the time. Simple DB add/update/delete/query code was 80% of their work. You give them a tool that reduces that time and frees them up to do other things and you've helped them out.

I think code generators are an extension of frameworks. With a framework (like .NET, Java, etc...) you've got a bunch of functionality pre-built for you -- this saves you time. With a code generator, you've got the ability to customize pre-built functionality. And you do it in a lot less time and with less debugging required. That's value.

Posted by PSteele | 4 comment(s)

Unit Testing with JUnit

No -- that's not a typo: "JUnit" (not NUnit). At my current job (which is usually VB6/SQL/Oracle development) I've had to do some Java coding. For someone familiar with .NET, it's not too bad.

I've recently become a big fan of NUnit, the free unit testing framework for .NET. It's a port of JUnit, designed for Java. Since I used NUnit first and have recently been doing some test cases with JUnit, I've come to appreciate even more the power that .NET brings to developers. The attribute based approach in NUnit 2.0 is simply cleaner. For example:
  • ExpectedException attribute. With NUnit, simply decorate your test case with this attribute to specifiy an exception you expect to receive. In JUnit, you need to wrap your code in a try/catch block and simply ignore the expected exception (don't re-raise it). With no exception, the JUnit test case will pass. Messy...
  • Ignore Attribute: A handy attribute that allows you to skip an NUnit test case. If using the GUI test runner, these test cases get flagged with yellow. For JUnit, there is no such thing -- it's pass or fail. However, I did a Google search and this is something that's been talked about, but it would be a special runner -- not part of the base JUnit code.
  • Test and TestFixture attributes: These attributes mark your test cases. In JUnit you have to prefix the method name with "test". Nuff said.
The good part is that I've now got a good set of test cases for my Java code -- it just took me a bit longer than I wanted... :)
Posted by PSteele | 2 comment(s)

More on multiple attributes

Mattew Reynolds adds another tidbit on Attributes:

Apparently, attributes should be declared as "sealed". There is a significant performance degredation when using non-sealed attributes (although to me .NET reflection is so fast, I've personally never seen this particular problem).
Posted by PSteele | with no comments

Applying an attribute multiple times

I had designed a custom attribute for fields and wanted to be able to apply it multiple times. For example:

<ExtItem("A1", "Text"), ExtItem("A2", "Color")> _
Private label1 As System.Windows.Forms.Label

This produced an error: Attribute 'ExtItem' cannot be applied multiple times. A quick check of the documentation says "multiple instances of an attribute can be applied to the same target element". So what was I doing wrong?

Fellow MVP Mattias Sjogren pointed me to the AttributesUsage attribute:
<AttributeUsage(..., AllowMultiple:=True)> _
Public Class ExtItemAttribute
    ...

Thanks Mattias!

Posted by PSteele | 1 comment(s)

Martin Fowler on Typed Collections

From Martin Fowler:

When people are starting to work with objects, particularly in a strongly typed language, a common question is whether they should have specific collection classes for different domain types. So if you have a company class which stores a collection of employees, should you use a regular collection class from your libraries, or should you create a specific EmployeeList class - a typed collection?
Via Sam Gentile's Blog
Posted by PSteele | 3 comment(s)

Windows Forms Controls chat

Just saw this post in the Microsoft supports newsgroups:

Join members of the Visual Basic .NET team to discuss how to create new Windows Forms Controls and extend existing controls.

Date:
June 24, 2003

Time:
1:00 - 2:00 P.M. Pacific time
Posted by PSteele | 1 comment(s)

Let go of my assembly!

As noted earlier, I'm using FxCop for the first time today. So I've got FxCop up with it's results, I'm doing ALT-TAB back and forth to clean up some of the easier things. Now I want to re-build and re-analyze but FxCop has my assembly locked. No biggie, I'll start up a new FxCop project and re-build. Still locked. I had to shut down FxCop before I could rebuild.

I've gotten spoiled by using the nUnit GUI so much recently. It doesn't lock my test fixture assemblies and allows me to rebuild them without shutting down the GUI.

Posted by PSteele | 2 comment(s)
More Posts Next page »