Kurser i Domain-Driven Design - Våren 2012




Wednesday, June 06, 2007

Fulhack Annotation 1.0

Introducing Fulhack Annotation 1.0 for Java - finally you can come clean with your fulhacks!

Download the Fulhack Annotation jar and drop it on your classpath. You can now annotate your fulhacks like this:

@Fulhack(blameDeveloper = "patrik",
badExcuse =
"Didn't have time to make it nice",
hack =
"Perhaps use same solution as for Cat, it looks OK.")
public void setBrownColor() {
color =
"Brown";
}

Using the Annotation Processing Tool (apt) shipping with Java 5, you can then create reports of your fulhacks by running:

apt -cp fulhack-1.0.0.jar <path-to-source-code>/*.java

Fulhack is licensed under the Apache License, Version 2.0.

Enjoy!

Download fulhack-1.0.0.zip

Thursday, May 31, 2007

Laziness is not a virtue of a programmer

In the late 1980:s Larry Wall stated that one of the three virtues of a programmer is laziness (the other two being impatience and hubris). With that in mind he created Perl, or possibly the order of the two events were the other way around.

After about 10 years of doing software development commercially I would like to argue that laziness is not a virtue of a programmer. My intention here is not to dis Larry based on a line taken out of context. Larry is after all much of a hero to an entire generation of system administrators and programmers. Perl also came to drive many of the first attempts at e-commerce and interactive web application, making a large contribution to the development of the web as we know it today. So, with that in mind, it is apparent that laziness can help you go places. But being lazy can also get you into all sorts of trouble.

Laziness may not be a virtue, but it sure seems to be an integral part of human behavior. I have to fight my own laziness everyday. When you have a task to complete it is often very tempting to do a fulhack* here, add an extra if-statement there, and hardcode some piece of information over in that end, i.e. do things that you know are wrong, but are very appealing for some reason. The right thing to do in these situations is typically something along the lines of rewriting a few more lines of code, extract a method, move a scattered responsibility to the class where it really belongs, etc.

The shortcuts are quick wins; you fix a problem momentarily and you can move on to other tasks. But as these quick wins starts to accumulate, it becomes even harder to stay away from them: "The code is ugly anyway, another one of these won't really matter now, will it?" This is the Broken window theory in action. And soon, your code is full of ugly hacks. Hacks that make the code hard to read, hard to understand and hard to maintain. Hacks that increase the entropy, or Technical Debt. All these things lead to a system that is more difficult and expensive to maintain. A system that is hard to change and extend with new functionality. A system that smells and no-one wants to work on.

So just stop being lazy. Pair-programming is a great tool to help you out here. It is much harder to write intentionally ugly code when someone is looking over you shoulder (or even stealing the keyboard).

Tim Ottinger has written an interesting piece on code as a liability.

Larry Wall on the virtues of community: Diligence, Patience, and Humility

*a 'fulhack' is a Swedish term for an ugly piece of code that you know is bad. But despite this you write it and leave it in the system you are working on, usually because you're too lazy to do it the nice way. A fulhack is typically annotated with some sort of code comment where the author clearly states that it is a fulhack, admits guilt and that way tries to escape responsibility. Which of course doesn't work...

Monday, April 02, 2007

Till Hell Freezes Over

I actually didn't think we would see this one this soon. It is, of course, the logical step to take but I really did think that the record industry would rather go bankrupt proudly singing the DRM tune before something like this happened. But today Apple and EMI announced "Higher Quality DRM-Free Music" on iTunes.

No, seriously. It appears to be true.

I will stop myself from ranting along about the true evils of DRM, the anti-customer business model of big conservative record companies, how they deserve a punishment and how they have completely frozen in a business model so dated that it isn't even funny. I don't mind paying for music, but the attitude the recording industry shows their paying customers makes me sick.

Sure, I would like to have seen a truly lossless encoding and a price decrease. But I guess you can't have it all.

Anyway, interesting move, now let's see what happens.

Saturday, March 17, 2007

Quality Money Can’t Buy

We needed a user forum for the sventon project, so we went looking for suitable software to implement this. We found phpBB that looked like a nice fit for the environment our hosting service is offering. I decided to try it out and downloaded the distribution. I discovered a beautiful piece of software, at least on the outside. I have not looked at the code, but my experience tells me that the outside and the inside tend to go together (at least when it comes to software, I’m not sure the same can be said about humans). The installation was a breeze: Upload the files to the server, point your browser to the installation page, enter a few configuration parameters and you’re pretty much done. No messing around with database schemas and SQL create scripts, no searching for configuration files in weird places and trying to figure out what needs to be changed, no nothing. For security reason the application won’t even start until you have deleted the configuration and installation directories, everything to minimize the possible ways to mess up.

This is ease of use money can’t buy. Have you ever tried to install an Oracle product you know what I mean: After wading through oceans of OLAF wizard screens, only to get harshly interrupted by a Java stack trace, you end up with an half baked install, and Java 1.1.8 as the system default runtime. Yuck.

My guess is that phpBB grew so popular that the ease of use had to be top-notch for the developers not to drown in support requests (but then again, I have never used phpBB before, the installation procedure may have been this good since day one, and that is the reason for its popularity). Oracle and their colleagues in the closed source arena, on the other hand, really don’t mind taking support calls from frustrated users; on the contrary, it’s a core part of their business.

I know, this hypothesis doesn’t really scale well. Many, perhaps most, open-source projects are a pain to install (trying to install Linux on an AST laptop in 1997 was an experience I’d rather not go through again), but the really successful ones are easy to use, easy to install and well documented, including frameworks such as Hibernate and Spring as well as Linux of year 2007. And of course, there are commercial offerings that are great as well, Orion server comes to mind; unzip the download and the install is completed. Nice.

Regarding the sventon user forum, we finally settled on something even easier: Google Groups.

Conclusion: I don’t know. Whatever. Go code something.

Friday, January 19, 2007

More Domain-Driven Design

Eric Evans returns to Citerus spring 2007 for more open enrollment classes in Domain-Driven Design.

Last time Eric was here in the fall he gave the class "Putting the Domain Model to Work, 3-Day Immersion Workshop". The workshop was very well received by the participants and sold out weeks in advance. I got many questions on whether we would run the class again, and I am now happy to announce that Eric will come back to Citerus in March. Eric and I will host not only the workshop we did last time but also a new two-day workshop on "Strategic Design" targeted at architects and development managers.

Seats are limited, reserve yours by registering today!

Thursday, January 11, 2007

Simple and Powerful

I have the greatest admiration for designs that truly succeed in combining ease of use with power. This is extremely hard, and very few organizations and designers have succeeded. Some products and services start out good but fail to keep stuff simple as the feature set grows, but most just suck from the start.

If you are old enough you may remember the AltaVista search engine. It was launched by Digital (later Compaq, now HP) as a project much to prove the superiority of the Alpha processors. It indexed more web pages than anyone before, it returned search result faster than anyone before, and it had a pretty good, simple design: A one-row search field, and a Submit button. Sound familiar? It didn't even have a domain name of its own at the time since altavista.com was already taken, but in spite of this AltaVista became the de facto standard for searching the web. Results ranking and speed could be improved, as we would later learn, but at the time it was pretty much the best search engine on the Internet.

But one day the age of the Internet portals arrived. Everything had to be a portal. Including AltaVista. Unfortunately the search functionality drowned in a sea of portal junk. This portal move really is ironic; with a really good search engine, why would you need a portal page with edited content?. The previously clean first page became so cluttered that you almost had to search the page to find the search functionality. Good thing Google came along to help you with that. AltaVista lost, both due to inferior interface design and inferior technology.

An other example. The iPod. Not particularly original as an example, I know, but this is for a reason. Apple designed the iPod as a music player, nothing else. They provided it with a simple to use piece of software to rip, organize and play music, as well as to transfer it to the iPod. They also gave it a very attractive design, being small, stylish and easy to use. The iPod really only did one thing, it played music. But did it really well. Every time a gadget blog or an online magazine writes about a new iPod model there inevitably has to be someone complaining loudly in the comments section of the article that the iPod sucks; it doesn't have a radio, the only supported way of transferring music to it is using iTunes, the battery performance is poor, it has no recording function, etc. But for the absolute majority, including myself, these things do not matter. We prefer the ease of use, the great sound quality, the small form factor. We rather not sacrifice the user experience the iPod provides for more features, as a matter of fact we are even prepared to pay a little extra for not having them. In this case less really is more. Sales figure speak on their own. There really isn't much of a competition. Yeah, sure, clever marketing didn't hurt either.

When a new iPod generation is released, the battery life is typically barely improved, instead the product is made smaller. Someone made a conscious design decision here: Battery life is good enough, size, however, is more important. Slowly new features are making it into the product line, first photos, later movies and games. But perhaps this isn't good enough in the long run. Perhaps the iPod users really want to consolidate their gadget collection, giving them less stuff to carry around? I sure do. This is nothing that escaped Apple, hence the iPhone. One would think that Apple is out on deep waters here, when they now enter a new market. Fortunately for Apple, there isn't much of a competition.

The Sony Ericsson p990i is the latest flag ship smartphone from Sony Ericsson. It is everything the iPod isn't. Sony Ericsson's design team has crammed pretty much every technology they could find into the p990i. It has support for GSM, WCDMA, WLAN, Bluetooth, an FM radio, USB, two cameras, and MemoryStick. It has a pen-based user interface and features software out of the box to make phone calls, send and receive SMS, MMS, and e-mails, synch with Exchange servers, read and write Office documents, read PDF files, play music and movies, surf the web, read RSS-feeds, a business card scanner(!), an alarm clock, and of course organizer tools such as calendars, contacts management, and tasks. And the list goes on. Looks good on paper huh? Too bad it sucks. It is badly designed, badly built and the software wasn't even half baked when the phone was released. The support documents even instructs you to reboot the phone (which takes 90 seconds by the way!) every now and then as a maintenance routine. And would you forget, the phone will do it automatically for you. When you least want it. We have suddenly moved more than 10 years back in time to the era of Windows 95 and pre OS X! Seriously, it is so bad it isn't even funny.

To add to it all, the arrogance shown by Sony Ericsson towards their customers that paid a premium price for this product is just sad. It shows every sign of a company that is immature in its customer relations and that has failed to embrace new CRM ideas and technologies that have emerged during the last few years. Things such as blogging and direct end user interaction. But that could be a good topic for a later post.

If the iPhone is even half as good as it looks, and if there is any justice in the world, Sony Ericsson will be in deep trouble over their smartphone product line.

Well designed products must be simple yet powerful for the novice user, but it must also prove effective with the experienced user. That's why the Wizard style of user interface programming doesn't work that great for everyday tasks. Consider the Google GUI as a wizard:

Step 1: Select what you are searching for 'a', a web page, 'b' an image 'c', a PDF document. [Next->]
Step 2: Enter a search string, then select 'Submit'. [Next->]
Step 3: The search string is presented to you, if it is correct, select 'Continue'. [Next->]
Step 4: Chose 'a' if you would like to show the first ten results for this search string, or 'b' to immediately go to the highest ranked item based on your search result. [Search]
Step 5: Show result.

This is not something that would be used that often... Come to think about it, it is not far from this: Award for the Silliest User Interface: Windows Search.

The AltaVista example shows us a design that started out good, but, as features were added, started to fall apart. So how do you expand the feature set without ruining ease of use and the user experience? Very carefully. This is what Apple has done with the iPod, this is what Google has done with its search engine.

Google has done a decent job with the search engine. Adding a few tabs for images etc is OK, the search is still the centerpiece, easy to use and extremely fast. Adding the 'Personalized Home' feature made me a bit worried, but it is still OK since you have the default option of not using it. Although, it did also add a bit of unnecessary clutter to the page. AltaVista, on the other hand, failed completely and eventually reverted their design to what it is today.

Carefully consider if a feature is worth adding, and how it fits with what is already there. Perhaps skipping a new feature is the best choice. I believe these are often the really hard choices to make.

I am not a designer. I believe I am pretty good at telling when a user experience works, unfortunately that doesn't mean I can design one from scratch. But it doesn't mean I wont try either. Read about how we try to apply these ideas when we develop sventon in part II.

"Perfection is achieved, not when there is nothing left to add, but when there is nothing left to remove."
-- Antoine de Saint-Exupéry

Saturday, January 06, 2007

The Year of 2006 in Music

When a year ends and a new one begins we're swamped with summaries and retrospectives of the old year. So, adding to that, these are a few albums that were released 2006 and I think deserves mentioning.

This really doesn't have anything directly to do with developing software, so it is a good candidate for trying out the label functionality of the new Blogger platform. I have really no idea how this work, but I'll label the post 'music', and we'll see what (if anything) happens. Oh, exciting!

Really good stuff (buy now):
Anna Ternheim - Separation Road
The Knife - Silent Shout
Peter Bjorn and John - Writer's Block

Good albums that didn't quite reach the level of previous releases (buy as soon as you have bought all the albums above):
KOOP - Koop Islands, good, but not as good as Waltz for Koop
Dub Sweden - Done With Loveless Days, good, but not as good as Welcome to Our World

2006 turned out to be a good year for Swedish music!

This year I look forward to new music from Timbuktu when OberoendeFramkallande is released February 21.