February 2005 - Posts
Have you ever used a content management system or commerce engine (product catalog) that just felt right? What was it that made the system work so well? What is the most important thing that you expect from a CMS or Commerce Engine? What products are the leaders in your mind for usability and overall user experience?
I've enabled comments for a bit to receive some feedback. Hopefully the spam won't get too bad 
It's amazing to me how many bad content management systems have been developed over the years. It seems that everyone has taken the time to "do it right" by rolling their own CMS only to end up with a product that doesn't quite work the way users expect. I came across a couple interesting articles over on the Adaptive Path website that may be useful to anyone taking a dive into developing a CMS:
A colleague at work recently sent along a link to Sync2It (
http://www.sync2it.com/). It automatically sync's up your bookmarks between IE and Firefox, as well as syncing the bookmarks on multiple machines. It also provides a web based interface for retrieving your bookmarks from any computers that you happen to use that aren't "your's".
I have a bunch of projects in the works that I’d love to use Visual Studio 2005 / .NET 2.0 on. The sooner I can get a go live the sooner I can start using it. Latest I’ve heard is that Beta 2 is expected at the end of March. Anyone know who we can bribe to get it sooner? :-)
I promise to start posting some real blog entries sometime soon. Just having a bit of a dip in things I want to write about.
Company.MyProject.Core.Tests.ComponentTest.CanUpdateDate : Updated date is incorrect.
expected:<2/14/2005 10:15:04 AM>
but was:<2/14/2005 10:15:04 AM>
Huh?!?!
Update: I got a couple emails saying that the likely culprit was the miliseconds on the date time. Sure enough that was it. Most of my dates I don't care about the miliseconds so I created a little AssertUtility class to provide my date check with the option of including the miliseconds in the check. Much thanks to all those that responded!
public static void AreDatesEqual(DateTime date1, DateTime date2, string message) {
AreDatesEqual(date1, date2, false, message);
}
public static void AreDatesEqual(DateTime date1, DateTime date2, bool checkMiliseconds, string message) {
Assert.AreEqual(date1.Month, date2.Month, message + ": Months not equal");
Assert.AreEqual(date1.Day, date2.Day, message + ": Day not equal");
Assert.AreEqual(date1.Year, date2.Year, message + ": Year not equal");
Assert.AreEqual(date1.Hour, date2.Hour, message + ": Hour not equal");
Assert.AreEqual(date1.Minute, date2.Minute, message + ": Minute not equal");
Assert.AreEqual(date1.Second, date2.Second, message + ": Second not equal");
if(checkMiliseconds) {
Assert.AreEqual(date1.Millisecond, date2.Millisecond, message + ": miliseconds not equal");
}
}
I came across the below method for renaming SQL Server databases today.
EXEC sp_dboption 'OldDbName', 'Single User', 'TRUE'
EXEC sp_renamedb 'OldDbName', 'NewDbName'
EXEC sp_dboption 'NewDbName', 'Single User', 'FALSE'
Source: http://www.elementkjournals.com/premier/showArticle.asp?aid=11048
Eric Sinks' recent "Business of Software" column entitled "Tenets of Transparency" is a must read for any ISV. Eric offers excellent advice and backs up his advice by having a company, SourceGear, that does very well on all his points.
A while ago when I first purchased Vault I had some troubles entering my license key. I intentionally left out the company name because I didn't want my bad experience entering a license key preventing other developers from trying Vault, since its an excellent product. Eric quickly posted a comment [1] to my entry saying that he realized that entering the license needed to be fixed and SourceGear was on it. By responding to my original post Eric gained my trust. Although I had a couple stints with other version control software (Subversion), I'm back using Vault. If Eric hadn't responded to that post he would not have gained my trust and may have lost me as a customer. Now with that said I use Vault as my version control software at home, where Eric doesn't make any money off me (other then the $49 I paid back when the single developer license wasn't free) since he offers a free license for a single developer. However, I'm sitting here writing about his product and his company which has to be worth something?
Anyway, if and when I start my own ISV I will definitely use Eric's advice within Tenets of Transparency to determine what the best mix is for my situation.
[1] which you can't see right now because I have comments turned off....hopefully they'll be back soon
As a TDD advocate I'm a big fan of TestDriven.NET. Although having a nice add-in for running unit tests is a big time saver I still find myself launching up the NUnit GUI to get my "green fix." Test Driven Development (TDD) without red and green just doesn't feel right.
Comments?
I received a comment on my previous post about using transactions for unit tests from an individual that noted he had run into problems using a similar approach on a "big project".
It's important to keep in mind that when writing unit tests a large number of your tests won't need to hit the database. If you look at the unit tests written for Enterprise Library you can get a good feel for this. 95+% of their tests don't touch the database at all, however, the components that are tightly tied to the database do hit the database.
Although a large number of tests within your unit tests won't need to hit the database their are often times when it is beneficial. The commenter on my previous post stated that:
"Any test that hits the database is NOT a unit test -- it's an integration test, testing the integration of your application code, the database drivers, the network and database server."
I agree that unit tests that hit a database are testing the integration between the application code and the database, but most importantly its also testing the stored procedure. It's difficult to test the stored procedure "unit" on it's own so I often rely on writing unit tests that incorporate a database as part of the "unit" it's testing.
The commenter (who if you haven't realized by now didn't leave his name) also made a very good point in that including transactions within your unit tests will make your tests run much slower. The longer it takes to run your unit tests the less likely they are to get run. I always try and reduce the amount of processing time for my unit tests and as mentioned by my infamous commenter I also try and separate these tests out into a "integration unit test suite" to help ensure a large chunk of my tests can run without the database.
So the morale of the story is:
Include the database in your unit tests only when required. The majority of your unit tests should run without hitting the database. For those tests that do require a database you may want to consider transactions in order to reduce the pain involved with rolling back your database to its "clean" state. If you start getting too many tests hitting the database and start to notice people aren't running the tests as often as they should be, immediately separate the longer running "integration tests" into a separate project that is run less frequently. Make sure these integration tests as well as your other "unit tests" are running automatically by using a continuous integration product such as Cruise Control .NET.
Comments?
If you're doing unit testing with a database I highly recommend using transactions to ensure all your data is getting rolled back. In the past I struggled to find the best method for cleaning up all the data that was inserted, deleted, and updated by my tests. Rather then continue the struggle I’ve updated my base test class to begin a transaction in the [Setup] and rollback the transaction in the [TearDown]. The result is much cleaner unit tests since all the cleanup doesn’t have to be done manually.
If you’re developing on Windows XP with SP 2 (or Windows 2003) you can use the below method for implementing transactions for your tests. Note that both the machine running the tests as well as the database server (if its not the same) need SP2 or Win2003.
[SetUp]
publicvoid GlobalSetup() {
ServiceConfig config = new ServiceConfig();
config.Transaction = TransactionOption.Required;
ServiceDomain.Enter(config);
}
[TearDown]
publicvoid GlobalTearDown() {
ContextUtil.SetAbort();
ServiceDomain.Leave();
}
If you’re environment doesn’t meet the requirements outlined above you’ll have to roll your own transaction support. My current project required me to add transaction support to our entity framework so I’m using our new transaction class within our test classes to ensure I didn’t right crappy transaction code. So far, so good.
Another very good option is Roy O’s XtUnit framework. He has a [CustomRollback] attribute that you can apply to the individual unit tests that need to have all operations on the database rolled back after they complete.
Comments?
Wener Vogels is
looking to fill some open positions in his group. I wish I was qualified, and for that matter had the brain power, to fill the positions. He's got to be doing things over at Amazon that would make your brain hurt day in and day out.
Jon Eaves has a very interesting post regarding introducing agile development practices into a team. He points out that many “poor” developers resist agile practices because it means they need to be accountable, it means their deficiencies will be highlighted, and it makes their “lack of teamwork and slackness” from the past obvious.
All great reasons for introducing agile in my mind!
Over the years I've slowly but surely tried to ramp up on patterns. I'm at a point now where I can identify many of the common patterns, and more importantly I've come to understand how thinking of things in patterns can help improve the readability, extensibility, and most importantly the "slickness" of your code.
The folks over at Microsoft have put together a resource of patterns from some of my favorite "pattern books".
Check out patternshare.org, it's super snazzy!
Jimmy Nilsson has a very nice article over on FTPOnline titled "Simplify Your Efforts With DDD". Jimmy overviews many of the key concepts within DDD such as:
- Use repositories to "help factor our certain logic"
- Use Factories to create objects
- Use aggregates as "the processing unit"
It's a very nice 2 page writeup on the basics of DDD. After reading his review if you haven't already be sure to pick up Domain Driven Design to get all the gory details.
I often times want to delete a set of data from a table and get my identity column to start over at 0. If you don't have any foreign key constraints you can accomplish this using truncate table. To do it manually you can do:
DELETE FROM
MyTable
DBCC
CHECKIDENT (
'MyTable', RESEED ,
0)
One of the major benefits of writing automated unit tests for your application logic is that it can help ensure the quality of your application. I say "can", because having tests doesn't ensure quality. It is very easy to write tests that don't help ensure anything except that a test is in existence. It's up to the developer to ensure their tests are testing what they need to and validating the appropriate assumptions.
Besides validating the logic within your application is working as expected writing automated unit tests provide one other major benefit which I hadn't seen the value of until my current project. I have two other programmers working on the project who would be considered "Jr" level resources by most. By having a suite of unit tests within our application we've created a lot of documentation on how to use the classes within the core infrastructure. Rather then providing them an API document and having them go at it I can refer them to the tests classes to see how the objects can and should be used. This gives them a working example that they can use as a guide. Obviously it doesn't provide them everything they need but it's proven valuable several times in the last couple weeks which has led me to the writing of this blog.
In summary, unit testing is your friend. The more you use it the more value it provides.
PS - is there anyone left on this DNJ feed besides me? 