Saturday, January 3, 2009

Hello World Revisited

So, you have to write a new software application. It's called Hello World. When it runs, it prints out "hello world". What do you do?

As previously discussed in my article "How to move beyond requirements", it is essential as a Software Architect that you constantly follow my mantra of "Think crazy, act sanely". However, what can you practically do to keep your software nimble?

As any software developer first starting out, you probably have written one or more "hello world" programs in your time. I use it as a glorified example of a simple initial requirement that later grows. Imagine that the customer wants other texts to be written, maybe wants the text to be dynamic, and possible wants it printed on a printer instead of a screen.

Here are your options for making "hello world" future proof:

  1. Put the text "hello world" in a global definition. If it ever changes, you only need to change it one place.
  2. Have your program read "hello world" from the command line. Now anyone can change the text without even recompiling.
  3. When reading from the command line, write the text to a file, so next time the program runs it can check the previous text and print it again if no new text is offered.
  4. Add an input parameter that default to "screen" so the user can specify where to print the text to, like "printer".
  5. Add another input parameter that could specify the color to print.
  6. Prompt the user to enter all these questions on the very first run, then store them to a file, and use them for subsequent runs
  7. Prompt the user only if a special command line parameter is added.
  8. etc. ad nauseum.
It quickly becomes obvious that you can add a LOT of things to just this simple little program in anticipation of future changes. Some of you might be asking why? Why add all this when the user haven't asked for it?

The purpose of adding these features is that it is faster to do from the beginning. You can architect the changes into the program from the start. It may take 5% longer for development to think about them, and 10% longer to implement and test. But re-writing the program 6 times as new requirements trickle in will take 100% longer. At least !

As a Software Architect, you must weigh the immediate cost of spending some up-front quality time thinking, versus spending a lot more time later re-architecting.

Now, let's consider a real-life example.

In 1996, I was tasked with writing the "Menu Server" for Nokia's Series 40 phones. This server was to handle anything in the menu system for all S40 products. At the time, the S40 User Interface (UI) was text-based with only lists of menus. You are probably thinking this sounds fairly easy, so let me give you a little list of considerations that I had to take into account, a list of features the Menu Server had to support at the time I was writing it.
  • Support for hundreds of languages, including Arabic and Chinese.
  • Support for sub-menus
  • Menu-indicator showing the location in the menu to the user (like 3-1-4)
  • Help, after 15 seconds help is shown.
  • 4-5 different layout of the menu, like single items, items with a sub-text (like phone book), etc.
  • Menu can be activated from various places, to it must support 'jumping' to a menu item
  • Sometimes, pressing 'back' goes two levels back instead of one.
  • Support for variable keys. Each S40 phone can have different ways of navigating the menu.
  • Scrollbar
  • Header showing highlighted menu
  • Wrap-around scrolling on some menu's, but not on others
  • Some menu items has extra functionality, in which case a text would be shown on a special function key
  • Etc.
As my first task developing the Menu Server, I decided to write a requirements documents with all of these. There were literally hundred of little things it had to do. The document helped me focus, and group the requirements into logical groupings.

After this was done, I did a brainstorm. I literally came up with more requirements, thinking about how phones might develop in the future. For example, I considered:
  • Different fonts and colors
  • Graphics would come (at the time only text phones was available for S40).
  • Different Screen sizes would bring new layouts
  • Timeouts would change
  • Help texts would change
  • Navigation options would change
  • We may get touch-screens eventually
Based on these very broad concepts of the market and technology, I came up with a list of features that I needed to build into the Menu Server, although none of these were initially required:
  • Support for Icons
  • Support for dynamic layouts
  • 4-way scrolling
  • Dynamic event handling (would handle eventually touch-screens)
  • Support for colors
  • Configurable timeouts
  • etc.
I had a bunch more, but they were so far out I had to let them go.

As you can imagine, developing the Menu Server suddenly became a very different effort than originally envisioned. I had to make everything dynamic. For the Nokia OS, this meant that the entire menu system became configurable. Every menu, and all of its behaviour became configurable, which meant that the extra functionality really was a matter of configuration, rather than coding.

When I was done, the menu supported almost all of these extra features. I couldn't test them all the way, because I didn't have the hardware to, but 3 years later, when Nokia introduced 4-way scrolling in the main menu, using icons, I got an e-mail from the center in UK. They had flipped the switch, and turned it on, and it worked. I probably spent a month extra thinking of all this, and writing the extra code. But three years later, another person had taken over, and he would have had to re-architect the entire Menu Server has I not done it.

With very little 'relatively speaking' effort on my part, I was able to save time in long run. Lots of time, for by now most of these features are in use.

Was there any drawbacks? Yes. The Menu configuration became rather big an complicated. Partly as a consequence of the Nokia S40 UI Architecture, which did not allow for anything more fancy than tables. Was it worth it? Definitely.

So remember... Think Crazy, Act Sanely.

A little more effort up front, will save you a lot of effort later.

Friday, January 2, 2009

How to move beyond requirements.

Software developers create code based on requirements, which usually are a subset of features. This is great for getting work done, but if we look at it in a broader sense, it can also be very limiting.

Consider this example:

A client has hired your company to write a new application for them. The application is really snazzy, and by simply running it, it will print "Hello World" for all to see. As a developer, it is your responsibility to code this application. What do you do?
I know, silly example, but you can replace the actual requirement for any that makes sense to you. Most developers at this point, would sit down and crank out an application that when run would write "Hello World" in perhaps a window or a command-prompt. For arguments sake, say it would take them half an hour.

As the developer is almost done, the client returns, now asking for a change. The application should write "Goodbye world" (The financial crisis hit them hard). Again, for arguments sake, the developer spends 15 minutes changing the application to write "Goodbye World".

Quickly upon delivery, the client returns again. He wants it shown in red. Again, the developer spends 15 minutes updating the application. After 10 minutes another change... The application should be able to print anything. Another 30 minutes of work.

After much back and forth, the developer and your company has spent 2 hours, and the client is finally happy.

Now, consider this: How long would it have taken to write the final application, had you know all these requirements up front? While this varies from product to product, it is safe to say it would have been a LOT faster had we known all the final requirements from the start. Maybe half the time.

It's time to put on our Software Architecture hat:
  1. We didn't know all the requirements up front you may say?
    Yes, but we also never asked. As a software architect, it is your responsibility to ask, ask, ask until as much as you can is learned and uncovered. Understand you must, why the requirements are what they are.
  2. Ah, but even if we asked, the client may not have known what they wanted you say?
    True, and often this is the case. However, that is not a reason not to think. That's right, I said think. With a minimum of effort, you can probably predict the next 75% of features a customer will ask for. Color the text, make it variable, etc.
  3. No way, how can I possibly know what my client want next?
    Because you are smart. You know the system, you know the technical subject area, you know the market. Guess. Brainstorm. Talk to your colleagues. Get together and think !
I call this "Think Crazy, act sanely".

When you have to implement a requirement, think about what is next. How can you make it flexible, extensible, modular and configurable. How can you prepare the code to get additions later? How can you enable the software to be easily expandable?

Well, stay tuned, more on this in later postings...

Happy new year, and remember to think !

Wednesday, December 31, 2008

Architecting with Requirements - A story from my past.

I love Software Architecture.

The essence of Software Architecture is to distill the requirements to the system. Often a developer think that a requirement is absolute: "Our software must do this. To the letter." However, when you dig a little deeper, most requirements are quite flexible. Remember that a requirement comes from a customer, and very often ends up being written by the customer based on his interpretation of your system.

Vivo, a Brazilian operator, had a set of requirements for Nokia that specified how the UI of their mobile phone should look and behave when in idle. For Nokia, these requirements were very hard to implement as written, years or man-hours work. The requirements were sent to Nokia in form of a large document. The document was interpreted by a Customer Representative that 'understood' Vivo's requirements. He entered them into a database where various teams could comment and respond to them. Eventually, they reached a Project Manager that decided to implement them, after which point they went to a Software Lead, who made sure his team got them and coded them.

By the time a developer got these requirements, it was too late. Un-winding the history was impossible, and frequently Nokia spent insane amounts of time not only managing this, but trying to figure out what Vivo really meant in the first place.

As one of my tasks while working as the Chief Software Architect for Nokia (CDMA products), I was sent to Vivo to discuss these requirements. The development teams were stuck, the work was overwhelming, the product would be delayed.

I met with Vivo's lead UI/Marketing person, Raquel, who was responsible for writing the original requirements. As we started discussing, I began asking questions along the lines of "So why do you want this? What is your purpose of asking for that?" Each time Raquel would answer honestly, describing what Vivo was hopnig to ultimately achieve with the feature (Drive revenue, make it easier for users to find and buy content, etc). When we came to the requirements that were hard for us to do, I suggested alternative ways of doing them. Often just a little tweak, but enough that Nokia could easily implement it, instead of making major changes. And Raquel accepted. She was thrilled that we could do it all of a sudden. The phone could be done on time.

In this scenario, what were the essential issues?

  1. The requirements were written with pre-conceived knowledge of our UI
  2. The requirements lost their original context when processed through Nokia's DB
  3. The core reason for each requirement was 'lost in translation'.

My point is... As a Software Architect, sometimes your main purpose is to understand WHY requirements are what they are. Use that to suggest alternative solutions that still fullfill the need, and always... always ask for purpose!

Monday, June 9, 2008

Surveys

Finally we're getting some help in the S&M Department (No, it's Sales and Marketing). A very experienced friend of a friend, Bob, has agreed to help us start understanding our customers, and tap into their view of LiveProject.

This has also prompted me to due some major e-mail list shuffles, which I must admit is tough when you have had 85,000+ people sign up. E-mails just don't fit so well in Excel anymore.

So after much ado about nothing, I finally had to give in and write a bit of a 'tool' for MailChimp. Their new API guy, Jesse, has been helping me with their .NET Beta library, which has saved me oodles of time.

Now, we are surveying all our customers, and learning a heck of a lot. Should any one of you read this (highly unlikely given my 3 hits per day on this blog or so), then THANKS !

Tuesday, March 25, 2008

Getting to Page 1 on Google

"Content is King" they say. So, in the spirit of content, I decided to add our entire help-page system (Which is already made up of *.htm pages) to our website.

We would increase our relevant content quite significantly, and allow customer to browser our help pages online. A win-win proposition.

In reality though, this proved to be more work than what I initially estimated. Our help pages are built using the HTML Help Workshop, and my first task was to clean each individual page of all header and body tags. Each page would simply have to start with a h1 tag.

  • This format still works in the HELP file, which is great !
  • This allows us to embed the help files directly into ASPX pages with a simple wrapper and include statement:
Now, any change to a help file can be updated on our web page by just adding the file directly to our web directory.

Now, the problem was that IIS was configured to open *.htm as web pages. So, a quick reconfigure later, and the include works (and we have no other htm pages anyway).

My last problem is that each *.htm file includes links to other *.htm files. But each htm file is embedded in an ASPX page, so the links don't work.

Using a URL rewriter, I simply setup a rule to re-direct any requests for *.htm files to the corresponding *.aspx page. Nice!! I love URL re-writing!!

Google even managed to index the pages, which is great, BUT google fails miserably when reading the title tag. For some reason each title becomes an "unknown page", most likely due to the redirect.

While finding the ultimate destination correctly, google seems to 'use' the 'missing page' it get's from the URL redirect header (Or something to that effect), so now I have to find and resolve that issue.