Thursday, June 16, 2011

This blog has a new home, and a new post!

It's been a while since my last post.  Every blogger has a post that starts like this, it's about time I join the club.  One of the reasons I haven't posted since September, aside from the obvious "I've been busy!", is that I've been meaning to move this blog to a wordpress site on my own server.  It took me a while because I was working on my own theme until I decided that it was holding up the move.  So, I picked an existing one and here we are...


I'll explain my reasons for moving to wordpress on a new post that I'll post there.

So, please, update your RSS feed and follow me over.

Wednesday, September 8, 2010

Selling Software Design

There's a new software project starting up and you are assigned as the architect or technical lead on the team. Your first task is to plan and design the overall architecture to best address the requirements and the risks. To do this you rely on best practices, design patterns and past experience. After bouncing a few ideas off of some peers, you come out with an architecture that you are proud of.

Your second task is to present it to the rest of the team.

Depending on how your office operates, this part can sometimes be harder than the first especially if you have team members that you haven't worked with before. The success of any up front design depends largely on team buy-in. If they don't believe in the design, then it will come out half baked and fall apart in no time.

Ideally, you would engage your teammates early on in the design process. You obviously shouldn't go design in a dark corner and come out swinging diagrams and specifications at everyone in a command and conquer fashion. You are part of a team after all. But, on the flip side, you don't want to have ten people arguing about minor details endlessly. In software, very few things are black and white and in the end you still need someone to stop and make a decision.

At first, when someone shows some resistance to your design, they might come off as being lazy or cowboy coders. This is not necessarily true. You spent hours thinking of different ways to bring all the pieces together and formed an extremely detailed picture in your head. It's often difficult to step back and remember that others do not automatically get that big picture handed over verbatim. I bet most of the time the resistance comes from failing to properly communicate that big picture. In those cases, resistance is your friend. Encourage it. Get your team talking and challenging your design. Their questions and criticism will result in one of two things:
  1. they found a flaw in your design and it can now be addressed before a single line of code is written
  2. they misunderstood or missed something and you have the opportunity to clarify
Expect these conversations from the start and come prepared. Some of the design decisions that you'll make will appear to mean "more work". Whether it's more boilerplate code, or figuring out how to preserve context across decoupled layers, or just doing things in a way that is not obvious; implementing these decisions takes time and diligence. If it came for free, it wouldn't be a design decision, it would just be how you do things. So, if you are going to ask that of your teammates, you need to make it clear how these short-term pains will pay them back in the long run. After all, that is why those decisions were made, right? If you can't come up with a better reason than "The GoF said so", then you are over engineering.

Be prepared, but be flexible. You are not perfect. You work with smart people who have their own experience and creativity to contribute. Use it. Mix it in with yours and everyone else's and see what kind of soup you end up with. Not only will you improve the design but you'll make it a product of the entire team. Your teammates will be more likely to appreciate and respect the design if its their baby too.

Test drive your design. This is especially important if you're the only one on the team during the initial design phase. Boot strap the project and write some code. Pick a depth-first feature as opposed to breadth-first. What I mean is write a component that will drill deep into the layers of the architecture. A good candidate for this is usually something like the login/authentication component since it requires code to that goes from the GUI to the backend effectively traversing a good chunk of your design. Try implementing this in a TDD fashion using unit tests with stubs and mock data. Not only will you be validating your design, but you'll be setting a pattern. When the rest of the team jumps in, they'll have something to work from. They'll have working examples of how to create their model classes, make services calls and even how to capitalize their variable names.

Getting those doubts and concerns articulated right from the start will help get the project started on the right foot. It will set the mood for the remainder of the project and help implement the design so that it can be maintained in the long run. Of course it doesn't mean that it will maintain itself, but I'll leave that topic for another blog post.

Thursday, August 12, 2010

This Website is Best Experienced Everywhere

If you were one of the early smartphone users and were subjected to Internet Explorer on Windows Mobile, then you're probably also one of Today's smartphone users who appreciate their modern mobile web experience the most. IE mobile is actually a good representation of how Microsoft approached the mobile operating system all wrong. They didn't really change anything, they just took a desktop OS, made it fit on a small screen and expected the devices to ship with a stylus. Mobile IE had scrollbars and the first few versions didn't scale the pages down. Later versions may have done a better job, but I gave up on it somewhere after WM6 started shipping.

Microsoft is now trying to catch up with Windows Phone 7. That's great (really!). The competition is healthy for everyone except the competing companies. I really do hope that WP7 does well and can become a relevant competitor against Apple, RIM and Google. What I hope for even more is that they learned a lesson or two from their previous experience with mobile computing.

Windows Phone 7 will ship with a mobile version of Internet Explorer, as anyone would have guessed. Recent evaluations appear to be failing at getting anyone excited. So competition is good, right? But do we really need another rendering engine? Politics aside, why not adopt WebKit like everyone else? When it comes to browsers, users just want the websites to look and behave exactly how the author intended and have some browser features that enrich the user experience. Please compete on the latter, but stay away from the former. Competing (read: different) rendering engines only make web development painful and inevitably frustrates users when websites break in the particular browser that they are using. Instead, why not build on an existing and popular framework and then contribute to it to make it even better instead of working in silos to reinvent the wheel?

Inconsistent page rendering is not the only thing making me uneasy about the re-emergence of mobile Internet Explorer. Early reports are stating that it will not support HTML5. Instead, Microsoft is working closely with Adobe to try to get the Flash player to run on WP7 devices. The duo is more or less bringing the Flash vs. HTML5 debate to the mobile world. Now, again, competition is good, right?  Is it?  I would say yes if, as a consumer, you had the choice between the two which is independent of the device that you like. For web developers, the worst part of all of this is that it's like writing JavaScript in 1997 all over again.  Do you double your effort to support both platforms, or give up and put a notice on your site stating "This website is best experienced with Netscape Navigator"?

I can't find a single web developer who is happy about having Internet Explorer 6 with us almost a whole decade later and even less that it will be around for a few more years. No one can even guess at the type of economical impact this browser has had over the web industry throughout those years. With all of this baggage, why bring that over to the mobile web?

Wednesday, August 11, 2010

Wait, There's More...

I received some good feedback from the few people that read my blog while I was at OSCON and so I decided to continue posting beyond my original mandate.

I make a living from software development and so I'll keep posting about things that hover around that topic.  I work for Macadamian, a software consultancy company based in Canada, and one of my favourite things about my job there is all the opportunities to work on new technology (new to me, in the least).  So as that continues to happen, I'll publish the interesting parts here.

My posts will not be as frequent as they were in July, but I already have a few of them drafted that will be published soon.  Also, please don't be shy to leave comments to voice your opinion.  It reminds me that people are actually reading this.

    Saturday, July 24, 2010

    OSCON 2010 - Closing Thoughts

    It was a very hard landing that made everyone in the plane leave finger nail marks in their arm rests, but I am now back home in Ottawa. Portland is a great city and overall OSCON surpassed my expectations.

    I met some great people and witnessed a lot of cool things but I think the key take away that I got out of this convention is that open source matters. Not that I didn't believe it before, but this really drove it home. Some people believe that open source is dangerous and full of broken promises. I strongly disagree. Sure there are bad projects out there, but that's not exclusive to the open source community. You still need to do your home work before adopting any technology. 

    Think about the web and try to picture where it would be Today without open source. Would it even exist? I can build a list of game changers without even trying:
    • W3C
    • Apache
    • WebKit
    • MySQL, Postgres, etc.
    • PHP
    • jQuery
    • memcache
    • ... and on and on ...
    As much as people love to hate PHP, its contributions to the web cannot be ignored.  There are also the technologies that are not directly tied to the web:
    • Linux
    • Perl
    • Python
    • Subversion, git, Mercurial, Bazaar ...
    • ... and on and on ...
    It's really not hard at all to expand these lists. Take the time to stop and think about this for a minute. How many other industries can you think of that has this kind of community effort. But better yet, how much did the efforts put into those projects help accelerate the evolution of new technologies? 

    Out of the few tech conventions that I've gone to, one thing that makes OSCON stick out from the rest is that the discussions here were not about products. They were not about making money. It was a gathering of people that are passionate about their craft and that want to make a difference with their skills. I'm not trying to be dramatic, just watch to Tim O'Reilly's keynote, he'll sell it to you better than I could. One of the things he said was:
    "[...] work on stuff that matters, not just to build cool tech that's going to make you rich or make people have a good time."
    He then went on to talk about how open source technologies were used to literally save lives in Haiti. Sure, this is the extreme end of the spectrum and obviously not every open source project results in saved or improved lives, but they are in the least enabling. If you ever find yourself with that career angst where you want to stop writing yet another form that dumps data into a database just because it pays your mortgage, then you might profit considerably from contributing to an open source project that you find interesting. Better yet, before you complain about an open source project that did not live up to its promise, think about how you can help and then create a patch and submit it.

    The world of computer science and software engineering is still very young when you compare it to traditional forms of engineering. We still have a long way to go but there is absolutely no denying that open source is not helping us get there faster.

      Thursday, July 22, 2010

      True cross-compilation for Android and iPhone?

      I went to another presentation on mobile development, this time it was for the xmlvm project presented by Arno Puder. Most of the frameworks that I've seen so far that attempted to ease cross platform development in the mobile space seemed to tackle the problem in similar ways. They introduce some kind of soft layer between your code and the underlying OS and hardware. 

      This is where xmlvm sets itself apart from the rest. It does not rely on a runtime or interpreter to abstract the code from the underlying layers. The development cycle looks a bit like this:
      1. Write an android app in Java, with eclipse and the android plugin.
      2. Build your UI and other components using the xmlvm library
      3. Build and execute within their own emulator
      4. Repeat
      5. When you want the real thing, run their compilation tool which compiles native binary code for either Android or iPhone.
      I hope I got that right, it's what I remember from the talk. The most interesting and unique part is step number 5. How do they do this? Java and Objective-C are such drastically different languages, this can't possibly be reliable.... right? The trick is that it doesn't work at the language level. The cross compilation uses the java byte code as the source, parses and morphs the logic into an XML document (hence the name) and from that XML, it can generate several types of output applications. This is brilliant.

      Wait, did he say "their own emulator"!?
      Yes I did. They have their own iPhone emulator so that you can test your code without having to go through the process of cross compiling (yet). From the demo that was shown, it works great. It might even be better than Apple's emulator since there are controls for tweaking the accelerometers. Arno even showed a demo app on his iPod which connected remotely to his emulator running on his laptop. He was then controlling the emulator's accelerometer by moving around his iPod. All of this, of course, is developed using xmlvm.

      So far, I'm quite impressed, but there are differences between Android and iPhone that are more complex than just syntax. A question that I had was how the memory model is managed between the two outputs. Java uses Garbage Collection while Objective-C uses the retain/release model and that impacts how you write your code. I didn't grasp exactly the answer that Arno gave me, but in essence he said they use reference counting and so circular references would cause memory leaks. This part would need to be understood clearly by any developer that would adopt this technology to make sure they really understand how their memory is being managed on the device that they are targeting. 

      Xmlvm most likely violates the Apple's terms of service and they are aware of this. However, I consider it to be in the same gray zone as Titanium and PhoneGap. An important distinction is that xmlvm generates a true native binary and is probably much harder for the Apple app review process to prove that an app was actually built using a cross-compiler than the other frameworks that rely on interpreters.

      The presenter made it clear that this library is not perfect and still has a way to go, but if this technology really does as much as what was presented, then I am definitely interested. I'll have to fiddle with it when I have a chance, now that I have my brand new and free nexus one. Oops! Did I just say that!?

      Wednesday, July 21, 2010

      /me loves javascript

      I attended a session on jQuery yesterday. This presentation was put on by Mike Hostetler and Jonathan Sharp.... these guys. Yes! Anyway, it was interesting to have them walk us through developing with jQuery. I waited a bit to report on this talk mostly because I was already somewhat familiar with the library, but also because I needed some time to understand what I got out of it.

      There were some neat tricks that I wasn't aware of and they did a great job of explaining how the library traverses the DOM and how you should structure your code to do it more efficiently. However, there were quite a few people in the room that had a hard time following the syntax during the live coding examples. There was even a question asked whether the appendTo team would consider developing ways to make the syntax easier to write. I was thrown off by this. jQuery (in my opinion anyway) offers such an elegant way of expressing your intent. The chained method support makes it really easy and quick to drill down to the data that you want to work with. Also, the context stack lets you drill down and back up within the same chain with a syntax that can be indented and left easy to read and follow. For example:

      $('tr')
        .filter(':odd')
        .addClass('odd') 
        .end()
        .find('td.company')
        .addClass('companyName'); 

      This is what I really love about JavaScript. This is also what I think new JavaScript developers have the hardest time getting used to. You really need to understand what the language is doing when you start attempting things like nesting closures. But once you have that primer tucked under your belt, you can really start appreciating the advantages that the JavaScript syntax has to offer.  If you want to learn more about the good parts of JavaScript, I recommend Javascript: The Good Parts by Douglas Crockford. It's a quick read and extremely informative.

      For those who are curious, Jonathan Sharp's response to the question about easier syntax was perfect: (paraphrasing from memory) "No. We would rather spend that time improving our documentation and tutorials to help developers learn the syntax".