Software Design Simplified

I was remotely reviewing a new team member’s code:

It wasn’t that bad, but I wrote him a document suggesting some general design principles. I’m repeating some of them here, because they seemed to be the sort of thing that I would like to refer to often.

1. For the typical application, start with the 3 basic layers: Front-end (GUI), Back-end (Database) and Business Logic. Give them their own classes within separate projects in the solution.

  • Ensure there are no cyclic dependencies

2. Establish well-defined interfaces between the layers.

  • Internal implementation within a layer should be modifiable, with minimal (ideally zero) impact on other layers
  • Control should flow cleanly between layers, not back & forth

3. Don’t duplicate code (or data structures) amongst layers (DRY Principle)

4. At the highest level, each class should map to a real-world object that you intend to manipulate.

  • Then start breaking down the functionalities and add more classes at the lower levels
  • Try as much as possible to adhere to Object Oriented Principles, and at the very least to the one-class-one-responsibility principle (SOLID) (Annotation: I know it sounds obvious, but you’d be surprised what passes for “object oriented programming” these days)

5. Don’t try to cover all the possible use cases up-front, instead aim for a design that has a solid foundation, on top which features can be added iteratively (YAGNI Principle)

6. The earlier you put in place a flexible logging mechanism (whether your own or reused), the happier you’ll be. No application is too small to benefit from logs. Besides debug info, they can also serve a source of useful information that the user need not be burdened with under normal circumstances.

7. Prioritization: Normally I would proceed in the order:

  • Functionality, Reliability
  • Usability
  • Robustness, Security
  • Efficiency
  • Maintainability, Portability

8. Tools:

  • Mindmaps for capturing Requirements & Design (Reference)
  • Dia for flowcharts  (Annotation: Yeah, I’m old skool)
  • StarUML for UML Diagrams

UPDATE: Montreal Resources

Some more useful resources for visitors to Montreal:

QDOS (Quick & Dirty Onion Soup)

[Source: 127.0.0.1]

I was working late nights earlier this year & I would come back home (hotel) a little cold and a little hungry, but not hungry enough for a meal. At the same time, I wanted to avoid having an unhealthy late snack which would inevitably contain either too much sugar or too much salt. So I started making myself some onion soup, which I found had an exceptionally warm & satisfying effect, especially in combination with a good book in bed.

Serves: 1

Ingredients

  • 1/2 an onion
  • 1 cup water
  • 1/4 tsp Salt
  • Pepper to taste

 

Method

Chop the onion. It doesn’t have to be very fine.

Add chopped onion to the water & bring to a boil. Add salt & pepper. Cover and simmer for about 3-4 minutes.
Occasionally stir & mash the onions to get the juice out.

Strain into a cup & sprinkle [freshly ground] pepper on top.

2011 Summarized – In Books

(Yes, I know it’s kinda late to be summarizing 2011 :-) , but I still believe that if you have nothing important, intelligent or enriching to say, then it’s better not to say it. In other words, don’t blog just for the sake of blogging…)

Often what keeps me going through a tough day is looking forward to curling up in bed with a book at night. It is a fact (at least valid for the current state of human evolution) that we retain more of what we read in real, paper books, compared to e-books on a digital screen. Something to do with the tactile senses.

I read several interesting, thought provoking and highly influential books since last year (besides the usual classic Science Fiction). Some of the more noteworthy ones were:

  • 59 Seconds: Think a Little, Change a Lot” by Prof. Richard Wiseman — I came across this in a reference at Coding Horror, and although I’m not a fan of non-fiction (and certainly not the How To sub-genre of non-fiction), I just picked up on a whim, and boy, was I hooked. I have been evangelizing it ever since, and more than a year later, I’m still discovering ways in which reading this book helped me break my [evil] habits and turned me into a better person.
  • “IGNORE EVERYBODY and 39 Other Keys to Creativity” by Hugh MacLeod — A friend recommended this to me (in fact, so strongly that she gave me her copy to read), and although sometimes a little opinionated, I found the advice very relevant to the times we live in, especially The Sex & Cash Theory.
  • I very quickly read “It’s not How Good You Are, It’s How Good You Want to Be.” by Paul Arden. Although the book didn’t really resonate with me (maybe because I was still reeling from the in-your-face effects of IGNORE EVERYBODY), I found some of the ideas very insightful. For example, Paul made the case that out of five sales pitches in a week, the client is most likely to pick the one presented on Tuesday, because Monday was “too early, nothing to judge by”, Wednesday & Thursday were “like eating too much chocolate” and Friday was like “feeling sick”.
  • Meanwhile, Steve Jobs sadly passed away, and the time seemed to be right to read “The Steve Jobs Way: iLeadership for a New Generation” by Jay Elliot & William L. Simon. I found the book to be very balanced, using storytelling to draw focus on best practices and insights that can be applied in our own organizations. Highly recommended if you think you or your place of work could do with a fresh dose of [now legendary] iNspiration.
  • I then started reading “The Go-Giver: A Little Story About a Powerful Business Idea” by Bob Burg & John David Mann, which was the first in a reading list recommended by Venkat during his inspiring talk at BarCampBangalore11 (#bcb11). This is a short book that extols the virtues of giving as the secret to success. If you’re in the business of making profit (who isn’t), this book will surely make you think.
  • There was some promising talk on Facebook about “Plunnge: Reinvention for the New Generation” by Rakesh Godhwani, so I got hold of a copy shortly after it was published. I’ve read many books, and no matter how badly they are written, no matter what subject they’ve been written on, I always find something, no matter how small, to learn from them. So over the years, I’ve never regretted reading a book (except maybe my school textbooks :-p ), but after a bit of a mental struggle, I was forced to admit Plunnge was the first one. Although the subject (essentially a collection of true stories about Indians giving up successful careers to pursue their true passions) is commendable, Mr. Godhwani’s attempt at writing is best described as “otherworldy”, and clouded the true potential of the book.  The writing is heavily biased & prejudiced, almost every single page has either a grammatical or semantic error (although I must concede that some of them are popular usage in corporate India) and there was just too much credit being given to individuals who were correcting their own bad initial career choices (most of all Mr. Godhwani himself – If there was one purpose this book served, it was that of being his personal catharsis). Apparently Peak Publish, headquartered in Derbyshire, U.K. is quite accommodating with the authors they pick. Initially I was so appalled I wanted to write to both publisher & author, but as I read on I realized that (a) the publishers published it, so obviously they didn’t find anything wrong with it, and (b) the author is so pleased with himself and the topic that obviously the finer details were not important to him. So what’s the point? Don’t let your filters fail, and skip this one.
  • To recover from “the Plunnge”, I went on a Malcolm Gladwell reading spree (who I think is a magnificent author), and read “Blink” and “Outliers” (which were somewhat related to the subject matter in “Freakonomics”) and that was time happily well spent. No matter where your interests or disinterests lie, if you’re human, you should read Gladwell.
  • A lot was happening around that time, and I thought it was a good time to revisit the old classic “Who Moved My Cheese?” by Dr. Spencer Johnson, probably the best piece of work written on dealing with Change.
  • Finally, I read the short story “Whispering Wind” by Frederick Forsyth (in his book of short stories called “The Veteran”) which I think is the perfect story. Forsyth fans and those discovering him now will equally be amazed at the level of excellence the Master Storyteller achieved with this story, especially considering that this isn’t one of the topics (or time periods) he usually writes about.
  • Recently I also finished reading “Bozo and the Storyteller” by Tom Glaister, which presents a unique, thought-provoking (and sometimes depressing) view of the human condition.

I got myself  a LightWedge to and will continue reading happily into the night…

The Art of Listing

As I had posted here in 2007, I have been trying to make an effort towards paperless organization of my lists, most of which are ToDo items. The Palm device that I was originally attempting to use for this effort turned out to be a headache because of limitations on formats, storage capacity, speed, interoperability and expandability. I ended up giving it away to my cousin brother who is a student, to make his first attempt at getting organized :-) In the meantime, I picked up a Sony Ericsson P990i, which let me do a lot more, faster and more efficiently (Of course, that device is also fast approaching its event horizon). I found that I have so much going on in my head that often it was a pain to take out the phone, flip it open, navigate to “Tasks” or “Notes” and start typing. Going 100% paperless wasn’t working out too well, sometimes during this physical process I would lose track of my mental process (i.e. forget the idea or task that I wanted to note down). Over the years, I have arrived at the following hybrid approach, which helps me get things done effectively:

1. On my device, I maintain the following lists, in the following order, each of them almost like a Product Backlog:

1) This Week 5) Online - Stuff to do the next time I’m in front of a computer, like e-mailing somebody
2) Weekend 6) Projects - Not just software, even real-world projects like scale models
3) Next Week 7) This Quarter
4) This Month 8) This Year

Plus, the following “dynamic” lists:
a) Groceries - Since the stuff I buy every week/month is almost always the same, I just have a master list in which I keep moving things between “Pending” (unchecked) and “Completed” (checked) depending on what I run out of
b) Shopping – Other things to buy next time I’m out
c) Travel - Places to travel to on the weekends
d) Focus - 1 to 5 items I’m currently focusing on (e.g. “Get to work on time” :-) ), to keep reminding myself regularly

2. My phone lets me prioritize tasks within each list, on a scale of 1 – 3. Also, for example, within “This Month”, if “Pay Rent” has been completed, it gets checked into “Completed” and doesn’t get deleted. At the beginning on next month, I simply uncheck everything back into “Pending”.

3. I maintain a single sheet of pocket notebook-sized paper (more if I’m actively noting down ideas/tasks for an ongoing activity/project), akin to a Sprint Backlog, with the following:

Front Side Back Side
Today - Things to do today (mostly at work) This Week - Including weekend commitments
Calls – Phone calls to make + e-mails to send Home – Things to do when I get back from work

4. Every weekend I move stuff from the “Product Backlog” (long-term list of stuff on the phone) to the “Sprint Backlog” (short-term list of stuff on paper), and *wait for it* stuff gets done! I never use more than one sheet of pocket notebook-sized paper in a week, and this way I also always have paper handy to quickly note down stuff (on the margins). Finally, in case I ever lose/damage my phone (which is backed up every 2 weeks), I don’t lose the things I had planned for the week.

Am I going overboard? (After all, it’s just a glorified ToDo list.) I don’t think so. I find that by keeping things prioritized and focused this way:

1.  I manage to get a lot more done without worrying about what I’m forgetting to do.

2. I don’t lose track of things that I would eventually like to do, but don’t have the time for right now (or this week, or this month, …)

3. Moving the prioritization and organization out of my head helps me think clearer and focus 100% on the task at hand.

But it doesn’t end there. Over a period of time (and with a lot of self-imposed discipline, I must add), I have managed to harmonize the short-term (a.k.a. “sort it when you see it”) organization of things that I come across everyday. I do this by managing the following “tags” (often as Folders, in some cases even physical file folders) across my Inboxes, Browser Bookmarks, Hard Disks and scattered notes (including those on my phone):

  • BlogThis
  • ReadThis
  • WatchThis
  • DownloadThis
  • FollowUp

I visit these as and when I have the time and keep emptying them out. With the addition of lists (as notes) for Movies to watch, Music to get, Books to read and Scale Models to buy, my little universe of lists is complete!

Stuff that I learned along the way, though:

1. Hybrid is more practical than paperless.

2. We need a device (implant?) that can make a note when the wearer thinks of it (and where to put it). The interface & actions between thought and task noted are, well, so ’90s! (Note: Speech Recognition is also so ’90s)

3. It’s best to stick to simple formats like Text and CSV instead of proprietary ones (like Excel). Simpler formats are easily portable and retrievable in case of failure, and suffice for making lists. If your list seems to require a complicated format, well, simplify your list!

4. It may be a good idea to reuse Visiting Cards and such, but your handwriting needs to be tiny.

5. Evernote can probably help.

UPDATE: [2011-07-16] I have since migrated all my lists to my new BlackBerry Curve 9300.

UPDATE: [2012-03-09] I discovered Todoist, which is quite simply the Tao of using Computer Science to solve problems. Although using it means that my todo list is now in the cloud, something that I’m [still] not very comfortable with, I find it indispensable to manage long-term projects. I initially found it attractive due to its Outlook integration, which meant that I didn’t have to grapple with numerous tasks disguised as emails, but the app is constantly being improved with new features, like @labels that enable a task to be present in multiple lists. HTML5 support means my list is now available offline, and it syncs effortlessly across devices, including my BlackBerry. I occasionally take local backups with Todoist Backup.

UPDATE: [2012-09-15] With my mind emptied of the long term stuff now safe on Todoist, I have started relying more on my memory for day-to-day things. I’m also trying to do less and focus more on the important things (not to mention years of long hours have significantly shortened my “backlogs”), and try not to take on more than I can comfortably remember over the span of a few days at a time.

UPDATE: [2012-10-05] I have a new revived obsession with Whiteboards at home. I’m trying to keep it under check to avoid looking like too much of a mad scientist…

24276 Subaru Impreza WRC 2004 Rally Japan

[Originally Published: 2008-04-27]

Scale: 1:24
Make: Tamiya
Model #: 24276
Year: 2004
Name: Subaru Impreza WRC
Description: P. Solberg/P. Mills #1 (Rally Japan)

This one was a bit of a scare. I wasn’t delivered until the day before I left Montreal, and I had to leave a lot of my clothes behind to make space for it. But it was worth it.

From Tamiya’s page about the model:

“Making her WRC debut in Mexico in round 3, the 2004 Subaru Impreza featured major improvements in areas like the bodyshell, engine and aerodynamics. The 2004 WRC season saw the first ever WRC event to be hosted in Japan, with Rally Japan held in Hokkaido in early September. It was no surprise that Japanese rally icon, the Subaru Impreza, had the majority of the crowd’s support as it rushed to the lead from the outset. Driver Petter Solberg didn’t disappoint the fans or the Subaru team, leading Rally Japan from start to finish to take his third victory of the season and move into second place in the drivers’ championship. In 2004, Solberg and the 4-cylinder 16 valve turbocharged Subaru Impreza dominated the gravel tracks, winning victories in New Zealand, Greece, Japan, Great Britain and Italy.”

UPDATE [2011-03-25]: My cousin brother, who is an architecture student, helped me build this during his holidays last year. I later finished the stickering in January, 2011. Here are some pics:

Happy New Year MMXI!

Happy New Year! If the 2012 Phenomenon is to be believed, then we have about 01 year, 11 months and 01 days before the world reboots. Must make the most of it.

On the brighter side, though:

 

In the last week, I have made substantial changes to the categories on the left, just to make them less cluttered and more meaningful. My apologies if this broke something that you had linked to. This was long overdue and any future changes would be relatively insignificant.

Live long and prosper, and follow me on twitter: @survivalcrziest.

 

Follow

Get every new post delivered to your Inbox.