Archive for November, 2010

What Do You Think Of This Hack?

14 commentsWritten on November 16th, 2010 by
Categories: C#, Code Quality

I have a class which exposes a fluent interface to build something. Instances of this class contain some state based on the methods of the fluent interface you called and the arguments you passed to those methods. Now, that state is currently private but it's not private in the "oh my god we need to encapsulate this so nobody can read it!11!!!1" sense. In fact, i actually want to access that state from another class. The only 'problem' is that i don't want to add methods or properties to the class to expose this state, because it sort-of pollutes the fluent interface. I know, that's not really a huge issue but still, it'd be nice to keep the fluent interface clean and focused.

One way to expose this state without polluting the fluent interface is to create a separate interface which defines the methods/properties and then have the class implement that interface explicitly. That way you could only access those methods/properties when you cast the instance to the interface type. While there's nothing really wrong with doing that, i kinda have a bad feeling about that because it introduces an interface which is only there to support this little exercise in Intellectual Masturbation.

Instead, i tried this:

    public class MyClassWhichUsesAFluentInterface
    {
        private List<string> someState = new List<string>();

        public MyClassWhichUsesAFluentInterface SomethingFluent(string blah)
        {
            someState.Add(blah);
            return this;
        }

        // ...

        public static List<string> GetState(MyClassWhichUsesAFluentInterface constructedThingie)
        {
            return constructedThingie.someState;
        }
    }

Is it fancy? nope. Is it cool? nope. Does it work? yup. Is it simple? yup.

Good enough for me.

Favor Value Over Quality

14 commentsWritten on November 11th, 2010 by
Categories: Opinions, Software Development

A mistake that many developers often make is that of putting too much effort into making their code and their designs as good as they can be. Don't get me wrong, good code and good design is obviously important. But what is even more important is that in most cases, someone is paying you to write and/or maintain that code and that person deserves a good return on his/her investment in you. Your job is to create value. Whatever it is that you're working on needs to add value in some way or another.

The most obvious way in which you can create value is when you write code that results in noticeable improvement when it is being executed. It could be a new feature. It could be an improvement to an already existing feature. It could be a performance optimization somewhere. It could be a bugfix. All of these make the software better in an externally observable manner which, like it or not, is all that really matters to the people who are funding your development activities.

Obviously, we all know that good code and good design make software better as well. It just improves the quality of the software in a more internal manner. It's not directly externally observable. It is however quite reasonable to claim that good code and good design lead to sustained productivity while working on the software. It enables the continuous creation of value without making it increasingly expensive.

So focusing on the quality of your code and design is a good thing, right? Of course it is, as long as it doesn't prevent you from actually delivering your software to the people who are supposed to use it in a timely fashion. At some point, you are going to have to accept that you can't spend all that extra time and money to make it perfect. The software you're working on is most likely supposed to reduce costs for its users, or generate money for its owners. As long as it's not being used, it's nothing more than a cost. A big one even.

Focus on creating value. Make sure you keep your code and your design clean enough to achieve that. It's not about how great you think you are. It's not about your ego. It's not about how you can tell people that you've used approach X or pattern Y or library Z in a project that users might not be happy with. It's about delivering the value that you were requested to deliver. Plain and simple.

Check Out PragPub, An Excellent Free Magazine

3 commentsWritten on November 11th, 2010 by
Categories: Software Development

In case you've missed it, as i have for the first 15 issues, the Pragmatic Programmers have an excellent free magazine called PragPub. There's a new issue every month which you can either read online, or download in a couple of formats (pdf, epub, mobi) so you can read it on pretty much every device you want. It's about software development in general, with no particular focus on a certain technology. Just great content with great variety. And it's free. So do yourself a favor, and check it out if you haven't already :)

Never Underestimate The Power Of A Message

13 commentsWritten on November 7th, 2010 by
Categories: Opinions

Yesterday, i was having dinner with some people, none of whom are in the software development business or even IT in general. At one point, the topic of discussion was the popularity of Apple and Google products, and how it seems that Microsoft is having problems catching up. I wasn't the one who started talking about it. I prefer not to talk about geek stuff with regular people. But hey, they're increasingly making use of Apple and Google products in their normal lives so they talk about this stuff from time to time. When Microsoft's apparent irrelevance was being discussed, one of the people suddenly says "so i heard they killed this Silverlight thing last week". My reply to that was "they might as well have".

I'm sure some of you are thinking "wait, no... didn't you read BobMu's and ScottGu's posts about it? it's alive!". I read them, but i don't find them particularly convincing. Let's break down the original message, and the way they've dealt with this fiasco. It all started when Mary-Jo Foley reported the following on October 29th about a conversation she had with Bob Muglia:

“Silverlight is our development platform for Windows Phone,” he said. Silverlight also has some “sweet spots” in media and line-of-business applications, he said.But when it comes to touting Silverlight as Microsoft’s vehicle for delivering a cross-platform runtime, “our strategy has shifted,” Muglia told me.Silverlight will continue to be a cross-platform solution, working on a variety of operating system/browser platforms, going forward, he said. “But HTML is the only true cross platform solution for everything, including (Apple’s) iOS platform,” Muglia said.

Obviously, many Silverlight developers/authors/groupies were shocked to hear this, especially considering how much Silverlight had been touted by Microsoft in the past 3 years. But the message started spreading. Even mainstream media started reporting that Microsoft was changing its strategy with regards to Silverlight. Worse yet, it was the kind of message that sticks with people. People hear the words "Microsoft", "strategy", "shifted", "Silverlight" and the story practically writes itself, regardless of whether or not it's actually true. People write the story in these cases and that story will be remembered. Obviously, it was time for some serious damage-control.

On November 1st, both Bob Muglia and Steve Ballmer released statements to clear the air and to get rid of the confusion. Let's start with Bob's post which you can read here. The most important part of his post is buried at the end. If you can make it to the end of the post without nodding off, you'll see this:

The purpose of Silverlight has never been to replace HTML, but rather to do the things that HTML (and other technologies) can’t, and to do so in a way that’s easy for developers to use. Silverlight enables great client app and media experiences. It’s now installed on two-thirds of the world’s computers, and more than 600,000 developers currently build software using it. Make no mistake; we’ll continue to invest in Silverlight and enable developers to build great apps and experiences with it in the future.

First of all, if this is the strong message you're hoping to put out to clear the air, don't bury it at the bottom! If you want to spread an effective message, you really ought to know about the Inverted Pyramid. You have to put the most important parts of your message at the beginning, not the bottom. Leaving the poor placement of this paragraph aside for a moment, what is he actually saying? The strongest statement in that paragraph is that they will continue to invest in Silverlight, but we sort of knew that already since Silverlight will be the primary development platform for Windows Phone. Of course they're going to invest in that. But when it comes to the future of Silverlight in LOB applications, a market in which it was becoming increasingly popular, there is no strong commitment and only vague statements which can't be used against them in the future.

Next up, Steve Ballmer's statement. It's worth going over each of his Silverlight mentions. Here's the first one:

In addition to more than 30,000 developers at 250 PDC events worldwide, another 100,000 developers viewed the event online using Silverlight, with 10% of the online audience taking advantage of simultaneous translation into Japanese, Spanish, French and Chinese.

The second one:

We will also enable browser scenarios that provide additional capabilities, including Silverlight. Silverlight provides the richest media streaming capabilities on the web, and we will continue to deliver that on both Windows and Mac.

The third one:

We’ve sold more than 240 million copies of Windows 7 in the last 12 months - an absolutely phenomenal number. Developers can build great applications for it using Win32, .NET, Silverlight and HTML5.

And the final one:

Developers can build Windows Phone applications using Silverlight and XNA, and we are excited about the application development momentum we have seen in the first two weeks of the Windows Phone 7 release.

What does that tell you about the future of Silverlight in the eyes of Steve Ballmer? He seems to be focusing primarily on its media streaming capabilities and of course, that you can build applications for Windows Phone with it. LOB applications aren't even mentioned. He just says that you can build applications with it for Windows 7. If even a part of this statement was meant to dispel the concerns about Silverlight's future, it was an utter failure.

Next up, Scott Guthrie who posted about this on November 4th. Scott lists 3 areas which are the core areas that they're focusing on and one of them is client apps with "a particular emphasis on enterprise business applications". And then he says this:

The “strategy shift” comment he made in the interview was intended to be about us increasing our focus on the above three areas as key scenarios where we think we can really differentiate and add a ton of value with Silverlight.

Now that is entirely different from the original "some sweet-spots" comment, no? The difference is so big, that i can't help but question the truthfulness of this statement. I mean come on, it's almost the opposite of what was originally said.

For me, it doesn't really matter whether or not Silverlight survives. But i do find this whole story simply fascinating. Bob Muglia started this mess with a comment that he may have let out at an unguarded moment. Whatever the reason for his original comment, it caused confusion that they later tried to rectify. Now, can you imagine this happening with any company when it comes to a technology or a product that truly matters for that company? Can you imagine this happening to Microsoft when talking about Azure? No, because they all know fully well what the goal is. Can you imagine this happening to Microsoft when talking about HTML5? No, because they're very clear in what their goal with HTML5 is. Did this ever happen when they talked about .NET? Windows? Office? Windows Phone? No, they've never had this happen with a technology that was truly important to them. The very fact that it happened gives me the impression that there is something funny going on within Microsoft. And i'm sure some of you have heard the rumors of the internal power struggles as well, so this might actually just be a result of that. Whatever it is, it's gonna be very interesting to see how this turns out in the long run.

For now though, the most important part about all this is that the original message is the one that stuck. The follow-ups have been too weak to really get rid of the first one. Regular people that know about Silverlight will think that it's on the way out. A lot of your customers will have heard about this too. Many of them will question you when you suggest Silverlight. Some of them will have heard the clarifications and with a bit of luck, they'll believe them. Others will be unwilling to put their money in building a product in a technology that is supposedly on the way out. This is a wound, and it's entirely self-inflicted by Microsoft.

Now, i'm no communications-expert but if they really wanted to squash this ASAP, they should've just put the following in Ballmer's statement:

Yes, we're committed to building the best HTML5 implementation available. And we're going to make our Silverlight platform even better.

And that would've been the end of it. That's a message that would've spread in the good way. That's a message that would've instilled confidence. That's a message that would've taken away all the doubts about their commitment. That's a message that people would expect from Microsoft when it comes to something that's important to them. But that's not the message they put out. For whatever reason.