Sunday, May 25, 2008

Agile Methodologies

I was recently reminded of an excellent whitepaper by Martin Fowler concerning agile methodologies. I read this whitepaper a few years ago but it's still highly relevant. A key point is that software can be self documenting and describes the design without extensive formal documentation. Iterative development and testing is obviously essential to enable feedback that helps adapt to changing requirements and scope. A formal process is not a substitute for a skilled developer.  It's a very worthwhile read... click here.

As an aside, Martin Fowler will be in Brisbane this week for the JAOO conference. It looks like a pretty cool event and I notice that Joel Pobar will be presenting on .NET language pragmatics. That's some pretty cool company.

Saturday, May 17, 2008

Deep Entity Framework

Visual Studio 2008 SP1 Beta was released in the last week, which is great news for users of ADO.NET since the service pack includes the much anticipated ADO.NET Entity Framework and ADO.NET Services (formerly Astoria). If you're interested in learning more about these technologies, I recommend you start out by visiting to the Data Programmability team blog and the Astoria team blog. Otherwise, Wikipedia has a thorough article on ADO.NET Entity Framework.

However, if you want to take a deep dive into the inner workings of Entity Framework, I highly recommend watching Sam Druker's channel9 screencast. Sam talks about the relationship between object oriented and relational data, and describes the need for inheritance, composition and associations.

Sam also takes the time to differentiate between object data and relational data. He uses the example of calendar data and notes that it is very difficult to use in a purely relational form. He goes on to talk about object databases as a means to work with hierarchical data.

However, Sam also points out that object databases suffer because you get bogged down with encoding and decoding pointers based on object identity. Object oriented databases actually miss the point of data modelling because, through encapsulation, you build walls around your ability to interpret the underlying data. You can't perform any set based operations on OO data so it's very difficult for external applications to interrogate your data in alternative ways.

A final point is that databases typically outlive applications because historical data is fundamental to warehousing and represents valuable intellectual property. Relational databases and set theory offer a means to abstract data from your applications in a way that is not possible with object databases.

Wednesday, May 14, 2008

Sleep & Hibernate Explained

I read an interesting technet article today about the difference between Sleep and Hibernate on Windows Vista computers. I'd never really given it much thought before but the article makes perfect sense. I've distilled the key points if you'd prefer to read on.

Sleep is a low power state that preserves whatever you were doing in memory. A sleeping computer can still wake up at specified times to download and install updates and perform other routine maintenance tasks. After these tasks have finished, the computer will go back to sleep automatically.

Hibernate is a power saving feature that writes your settings and memory content to disk before completely powering down the system. Waking from a state of hibernation takes longer than waking from sleep. This is because your computer needs to load your data and applications from the hard drive back into memory. Hibernate is particularly useful on a laptop when you know you won't be using the computer for an extended period of time and you won't have an opportunity to charge the battery.

Screen savers are apparently antiquated and do not conserve energy. In fact, many of today's sophisticated screen savers use more energy than your computer would use under light conditions. Even when a display goes blank, many screen savers continue to run and consume energy. And some screen savers actually prevent your PC from going to sleep.

Thursday, May 8, 2008

My Thoughts on Armenian Food

After a long day of meetings in the office, some of the guys from work decided to go out for a steak and a beer before going home. Brisbane's a steak and potato kind of town and on a Thursday night, there's no better place than the Breakfast Creek Hotel. They serve a quality steak, though some think it's a little expensive and perhaps mass marketed. Still, the hotel is packed most nights and the quality is hard to deny.

"I've been looking forward to a steak all day", moaned Nick. "I'm so hungry. Still, a good steak is worth the wait and I hear the hotel buys all it's steak from Redmond. They have one of the best beef industries in the world over there."

Most of the guys nodded in agreement. They'd all been eating steaks for years and it's difficult to deny the appeal of an old favourite. What's more, they'd recently sampled some of the new cuts from Redmond and were pretty impressed with the flavour.

Once they arrived at the restaurant, the aroma of juicy steak was almost unbearable. "Dinner time!" they chorused. The hotel was packed and all around they could see the hotel's customers devouring juicy steaks and looking satiated. They found a table, sat down and moments later an enthusiastic waiter appeared with a specials board.

"Good evening gentlemen. Tonight for you we have the special. It's a rare Armenian delicacy, which some consider to be the most delectable food ever conceived. I encourage you all to try it."

"Really, I thought this was a steak restaurant. I've heard of Armenian food before" remarked Geoff, "but know very little about it."

The waiter continued confidently: "Armenian food has a delicate blend of aromas that remind some people of a cedar forest. It's low in fat, has very few calories and no cholesterol. It's also low GI so you won't feel bloated after the meal. It's like nothing you've ever eaten before and I promise that once you've tried it, you won't desire another steak."

"But what's in it?" encouraged John, anxious for some details.

"What ever you like. The remarkable thing about Armenian food is that you get to prepare it yourselves, with the assistance of our head chef. It is very inexpensive though."

"But how do you eat it?" I asked quizzically.

"Ah! You must become ONE with the food! It can only be enjoyed when you eat with your bare hands," replied the waiter.

"Well I'm not too fond of eating with my hands, they'll get dirty. Can't I just use a fork?" asked Geoff.

"Or some chopsticks?" I chimed. "I've just been to Japan, don't you know. I could make a fair meal out of it with chopsticks!"

"No, no, you have it all wrong! Fingers are best," the waiter paused. "I suppose you could use a knife and fork, if you must. We've actually designed a special knife and fork for the likes of you."

"Well, what's wrong with our steak knives and forks? Won't they do?" I asked to no one in particular. "They make short work out of steak," and the diners nodded knowingly.

Now impatient: "You can use anything you like, but you'll be here all night. Our custom implements will get you through the meal much faster. It's really very simple."

By this stage, the diners were starting to look despondent. They all had their hearts set on a steak, but it wasn't forthcoming. The waiter was not service oriented and it was becoming apparent that they would all go hungry.

Then John had an idea: "Perhaps you could let us try a sample."

"I tell you what" replied the waiter, "I'll try a sample for you and tell you how it is."

Suddenly the Armenian chef appeared. "Alright, have you made a decision. If you're having Armenian tonight we better get cracking and place some orders. I don't want to rush you, you're my only customers, but I need to put some plans in place. It's time for action."

With those words it was time for our Boss to get involved: "I don't want to make a rash decision. The guys have already done a lot of thinking about the kind of sauce they'd like with their steak and this new option has given us pause. Perhaps you can give us a few minutes to decide?"

With the waiter and chef out of the picture, the diners were free to talk openly.

"I don't know anything about Armenian food, let alone how to prepare it," I remarked openly. I looked around the restaurant and then said, "Everyone around us is eating steak and they look like they're enjoying it. I hear the steaks come with a quality guarantee. Then there's all the sauces and you can choose your side. Those beer battered fries are my favourite!"

The diners had reached a stalemate. "We're out of time and most of us need to get home. Anyone for some Maccas drive-through?" and with that the Boss led them out of the hotel.

Tuesday, May 6, 2008

Organise C# Usings

Visual Studio 2008 has a neat little feature that organises your C# using directives.  You can remove unused using directives and even sort them! The sorting algorithm even knows to put System namespaces first and follow with custom namespaces.

You can access this function in two different ways: popup the context menu in the code editor and select Organise Usings, or open the main Edit menu and go to the IntelliSense submenu. The only thing missing is option to apply to all files in the solution.

OrganiseUsing

Technorati Tags: ,

Thursday, May 1, 2008

C# 3.0 Language Features

I downloaded the C# Version 3.0 Specification early last year and remember being very impressed with the latest round of language features. Implicit local variable types, extension methods, lambda expressions, object and collection initializers! I couldn't wait to sprinkle that syntactic sugar all over my C# code. However, reality had something different in store and it's only been the last few months that I've used C# 3.0 in anger.

If you're just starting out with C# 3.0, I highly recommend paying a visit to Charlie Calvert's blog and watching the videos of Luca Bolognese and Luke Hoban. Luke's webcast is particularly helpful if you're already familiar with the language features in C# 2.0.

I'm not going to delve far into the C# 3.0 language features in this post. However, I have to draw your attention to the introduction of lambda expressions. I've used anonymous delegates with C# 2.0 for a long time and find them invaluable when using generic collections. However, the anonymous delegate syntax is unreasonably verbose and hampers code readability. Lambda expressions offer a very clean syntax for expressing anonymous delegates in C# 3.0. Here's a quick example:

LambdaExpression 

So I guess I'm a little slow on the uptake of lambda expressions but I'm really happy with the way my code is looking now. I know the Visual Studio IDE helps you out a lot with code completion but why type more than you have to.