Iceberg features

Business, Programming·Startups

Iceberg features are where on the surface they seem small and simple while backed by a huge un-seeable chunks of functionality and processes. Like their real counterpart they come in many different shapes and sizes. From the “Oh, just add an extra field to this form”, which in-fact impacts the business logic, to “Just copy this feature on site X”, without taking into consideration the processes that go on behind the scenes. I’m sure we’ve all experienced the first sort of “small change” problem before, but the second one is a lot more subtle and easy to miss.

A lot of sites successful implement a “invite your friends” feature, which grabs a user’s address book and messages each of them asking them to join. The simplistic way of copying the functionality is to think that the road to success is simply grabbing the needed details and messaging them, thinking that what makes the functionality successful starts with the form and stops with the initial message. That’s just the tip of the feature iceberg. Is it successful for another site as they have a planned out set of campaign emails they send out to an invited person, with timed followups and different possible campaign routes depending on a user’s reactions. It may well be that having a naive imitation of the feature is better than not having one at all, but it’s the compromise of deciding what to do. Is a poorly imitated, half implemented and thought out feature better than a smaller, but more complete and well thought out one.

User's wont do what you want them to

Programming, Business·Design Marketing

I spent the day at Infusionsoft’s Customer Tour Conference. It was interesting to see some of the more advanced things that are possible using their product as well as listening to how some people are using it to market and sell their products. One of the things said during the day was in regards to  sequences and moving user’s through a series of steps and goals, but which applies quite heavily to programming, which was:

“Build your process assuming the user won’t do what you want them to do.”

I found this quite a succinct quote and an excellent rule of thumb for when designing pages. Once you reach a certain size, your clout allows you the freedom to get away with less than stellar design choices. For instance, personally I think the Amazon site is a mess, and this was re-affirmed to me recently while trying to show someone how to go about ordering things from it.

When it comes to Amazon their reputation means a user is more likely to jump through hoops to complete their order, but for a never heard of site, any signs of hassle and they’ll be out the window and onto the next (Unless your offering is just so amazing they can’t resist). News and unheard of sites that are successful, “reduced friction” for their users. They seamless move users from one stage of a process to the next without having to make them think or accidentally moving them onto the wrong path. A good site needs to be more than a set of CRUD pages. It needs to be an experience that helps the user achieve what they want, in the clearest way possible.

Why Code Quality Matters

Programming

Recently the discussion of code quality has come up with a couple of different people. With the main question:

“If the app does what it’s supposed to do, why does code quality matter?”

In one instance an application that was bringing in over a £1m in revenues a month had one of the worst code bases a friend had ever seen. And I totally agree that there is no correlation between code quality and the earnings/growth potential of an application. Then a few days ago I was reading the brilliant Zed Shaw article “Products For People Who Make Products For People” which completely crystalised why code quality is important:

“… the frontend product is what brings your revenue stream in, but your backend operations quality is what keeps your costs down as you grow. If your backend costs get out of control because of technical debt then you won’t make a profit, or someone who can keep them down will just copy you and wipe you out with less.”

Perfect! That’s it exactly. Code quality matters as that’s what allows you to grow the system beyond your v1. If you never plan/or want to get past v1, then perhaps you can get away with being a lot more lieniet in your “quality”. I know that’s what I do, if it’s a quick app then normally I have only the most basic of tests and cut corners where I wouldn’t normally. Maybe in a sense, code quality is a reflection of technical debt. The lower the quality, the higher the debt and sooner or later you’re going to have to pay that back (Unless you’re fortunate enough to close up shop before that time comes). I’ve worked on projects where the technical debt is so high that you’re paralysed and just can’t do anything. Simple changes become huge problems as you’ve been painted into a corner, and the fear of breaking something is so huge that new feature requests are shied away from.

If you want/expect to be able to grow your business then keep the bar high. Code quality matters a hell of a lot.

Everyone is a Designer

Programming, Business·Design

Design is hard. No, actually, design is really hard. I think many people are deceived by the way good design seems so effortless and so simple. Antoine de Saint-Exupery said it “perfectly” when he said “Perfection is achieved not when there is nothing left to add, but when there is nothing left to take away”. The temptation of non-designers is to add and add and add. Then when a true designers work is inspected, the temptation is to remark “Is that it?”. And to then think “I could do that”. Of course, anyone can follow the same blueprint and produce the same result, but given a blank canvas, would the same quality of work have been produced?

Design is so subtle. Sometimes it would appear that no thought or care has gone into what is being presented, but then there is a purpose and a goal behind every decision and every element made. Did I mention how hard design is?

It's the polish that takes the longest

Programming·Design

After spending a few hours in Photoshop trying to get some buttons to just look “right”, I started to think about how I seem to spend the majority of my time adding “polish” to applications. Getting features in is easy, getting them working nicely and looking great is hard. It’s the 80/20 principle, it’s that final 20% that makes the difference between good and great. Apple is the obvious choice of reference here when it comes to polish. Their products are polished to such a high degree, that can’t help but I wonder what percentage of time they spend getting it right over getting it done.

What we all need is understanding

Business, Programming·Customer-Service

There’s always that storyline in films and TV shows. Parents despair as they become more and more distant from their angst ridden teenage son/daughter who complains of just being mis-understood. There all the signs of neglect on the parents side, by not spending enough time/showing enough love, then there’s normally some sort of event that brings them all together again to be one big happy family. Think John McClane in Die Hard and his daughter Lucy, or Sean Archer in Face/Off and his daughter Jamie. The parents and the teenager are living separate lives and there’s a clash when they come together, because neither understands where the other is coming from.

As a developer one of the ways this problems often occurs is when working with people not from a technology background. Warren Buffett’s famous advice is to simply “Invest in what you understand.”. Many people take the time to understand their market, but do not take the time to understand the technology/process. It’s no surprise to me that the only company that I’ve worked for that’s actually achieved a measure of success is run by people who not only have a very clear understanding of their market, but also have a very clear understanding of the technology they provide. And what of the others that are no longer around? It’s no surprise I spent a lot of time at those places trying to explain how things worked and why things couldn’t be done. Yes, and while some businesses needs to be about pushing the boundaries and innovation, to do so also requires a knowledge of the limitations of what currently exists.

I have been as guilty of this sin as everyone else. As a developer it’s very easy to take no interest in the customer side of things and care only about the technology, and perhaps to a degree this is an even worse situation to be in over having management that don’t understand technology. When this happens solutions that are unusable by anyone can end up being delivered. I know for a fact I have delivered plenty of products without ever asking myself who the product is actually aimed at, all the while being feature focused. Where as now, rather then only caring if something can be done or not, I try and ask myself who will be trying to achieve a task and what is the best way for them to go about doing so. As with anything, there is a balance that needs to be found.

Managers, understand the technology. Developers, understand the market.

There’s always that storyline in films and TV shows. Parents despair as they become more and more distant from their angst ridden teenage son/daughter who complains of just being mis-understood. There all the signs of neglect on the parents side, not spending time with them or not showing enough love. Then there’s normally some sort of horrible event that brings them all together again to be one big happy family and they all live happily ever after. Think John McClane in Die Hard and his daughter Lucy, or Sean Archer in Face/Off and his daughter Jamie. The parents and the teenager are living separate lives and there’s a clash when they come together because neither understands where the other is coming from.

As a developer this problems often occurs when working with people not from a technology background. Warren Buffett’s famous advice is to “Invest in what you understand.” and while many managers take the time to understand their market, they don’t take the time to understand the technology/processes of their business. It’s no surprise to me that the only company that I’ve worked for that’s actually achieved a measure of success is run by people who not only have a very clear understanding of their market, but who also have a very clear understanding of the technology they provide. What of the others that are no longer around? It’s no surprise I spent a lot of time at those places trying to explain how things worked and why things couldn’t be done. And while some businesses are about pushing the boundaries and innovating, to do so requires a knowledge of the limitations of what currently exists.

As a developer I have been as guilty of this sin as everyone else. It’s very easy to take no interest in the customer and to care only about the technology. Perhaps to a degree this is an even worse situation to be in over having management that don’t understand technology, as when this happens, solutions that are unusable by anyone are usually delivered. I know for a fact I have delivered plenty of products without ever asking myself who the product is actually aimed at, all the while being completely feature focused. When I think back to those products, it’s a wonder they survived any sort of usage at all. Now, rather then only caring if something can be done or not, I try and ask myself who will be trying to achieve a task and what is the best way for them to go about doing so. As with anything, there is a balance that needs to be found.

Managers, understand the technology. Developers, understand the market.

Broken Window Policy of Programming

Programming·Teams

There comes a point in every software projects life where everything just feels wrong. No one wants to touch the code as it stinks and everyone working on the project just feels demotivated and would rather just go home then have to do anything more on it. On projects like this, when it comes to adding new features or bits of code, because everything else is such a mess, the changes are just hacked in rather than being properly thought out and coded up well.

We’ve all been there and the frustrating thing is that our opinion of the project, from good to bad, seems to happens over night. If you sit down and think back, you can probably pick out all the things that were just shoved in that eventually led to the project becoming a mess, but at the time we never chose to do anything about. It’s almost always a case of deferring better solutions or a round of refactoring to some point in the future. “I’ll knock this up now and come back to it later.”. The problem is that later never comes. This is the essence of technical debt. You may only go into debt by a fraction, but do it a few times and eventually all those fractions add up. Until one day when you go to check your balance, you find yourself swimming in the middle of the ocean with no land in sight.

Implementing a broken window policy can go a huge way towards keeping a project healthy. If there is a broken window (bad code) fix it as-soon-as-possible. It doesn’t have to be that instant (although if you can, you should), but fix it. Part of the policy also means trying not to break windows yourself. Write the best code you can, as often as you can. Set the benchmark of quality for the rest of the team, even if they don’t follow suit. The danger is that many people are very “me too” about things. “Well if such-and-such can do it like this, then so can I *hack* *hack* *hack*”.

Of course we all write crap from time to time. TBH most of the stuff I write is crap. But I honestly feel more motivated to work on code that’s been loved and looked after, rather than something that’s hanging together by a thread.

Law of Demeter and the delegate method

Programming·Ruby Rails

The Law of Demeter, or Principle of Least Knowledge is a fairly simple design pattern, which, simply put means that an object should only talk to it’s immediate “friends”

The law states that a method M of and object O may only invoke the methods of the following kind:

1. a method on O itself
2. any parameters passed to M
3. any objects instantiated within M
4. any direct components of O

The classic example coined by David Bock used a Paperboy (one object) delivering a paper, then extracting money from a Customer’s (another object) Wallet (and another):

 class Paperboy
    def get_payment(customer)
      self.money += customer.wallet.take_out(10)
    end
  end

In the “real world” the Paperboy would ask the customer for the money who would then take it out for them, rather then the Paperboy reaching into the customer’s back pocket and getting it for themself.

Really we want something as follows:

  class Paperboy
    def get_payment(customer)
      self.money += customer.get_payment(10)
    end
  end

  class Customer
    def get_payment(amount)
      wallet.take_out(10)
    end
  end

This may all seem trivial and a waste of time, but what happens if some Customers want to pay by cheque? Those decisions should have an impact on the Paperboy, otherwise we end up with:

 class Paperboy
    def get_payment(customer)
      if customer.pay_by_cash?
        self.money += customer.wallet.take_out(10)
      elsif customer.pay_by_cheque?
        self.money += customer.cheque_book.write_cheque(10)
      end
    end
  end

Where as it makes more sense for the change to be contained within the Customer:

class Paperboy
    def get_payment(customer)
      self.money += customer.get_payment(10)
    end
  end

  class Customer
    def get_payment(amount)
      if pay_by_cash?
        wallet.take_out(10)
      elsif pay_by_cheque?
        cheque_book.write_cheque(10)
      end
    end
  end

So what does this have to do with Rails and the delegate method? The delegate method adds a quick and simple way of following the Law of Demeter without having to do very much at all.

  class Order
    belongs_to :customer
  end

  class Customer
    has_many :orders
    has_one :credit_card
    has_one :bank_account

    def payment_method
      if pay_by_card?
        credit_card
      elsif pay_by_account?
        bank_account
      end
    end
  end

  class CreditCard
    belongs_to :customer
  end

  class BankAccount
    belongs_to :customer
  end

This setup means to get an Order’s payment we would have to say:

 @order.customer.payment_method.withdraw(amount)

But if we simply change our objects as such:

  class Order
    belongs_to :customer
    delegate :withdraw_payment, :to => :customer
  end

  class Customer
    has_many :orders
    has_one :credit_card
    has_one :bank_account

    def withdraw_payment(amount)
      if pay_by_card?
        credit_card.withdraw(amount)
      elsif pay_by_account?
        bank_account.withdraw(amount)
      end
    end
  end

Now all we have to say is:

@order.withdraw_payment(amount)

So at any time, the details of how a payment  is to be decided can be contained with the Customer. This is of course a simplistic example, but hopefully explains how you chould be using this handy feature.

The Code Shall Set You Free

Programming·Ruby

I was recently asked why I don’t comment my code. It’s a fair enough question. There was a time when commenting your code was the done thing. I was once a great believer in commenting code as much as possible and would bash those that didn’t, but now I vary rarely comment my code at all. In my current project of over 1,500 LOC, there are only a handful of comments. Many people will argue this is irresponsible. Well how is anyone supposed to pick up and understand my code, if it’s not commented?

The code should comment itself.

That just sounds silly. It’s like saying a car should drive itself. But it can be done. A lot of this change of heart about comments has come from my commitment to becoming a better developer and spending countless hours reading about the practice of great development, which is something I’ve written about in the past. I’m a big believer that most of the time if you need to comment a piece of code, then it’s either bad code or too complicated. Of course that’s not true 100% of the time, but for the other 99% it really is. There are cases where things need to be explained and especially warned of, but a lot of the time, commenting is just an easy escape from having to do “proper” coding. It took me years and years to get a basic understanding of proper OO and I’ve still got a long way to go to reaching Journeyman levels of understanding, but I would always create large objects with huge and complex methods, when really what I needed were more concise classes with more responsibility for what they should be able to do. It’s not object orientated when you’re focus is on the method and not the class.

A simple example of commented code:

  # Feed the fish.
  def check_food(food)
     # Check if Fish has eaten more then 5 hours ago.
     if self.last_meal_time < 5.hours.ago
       return "Not hungry"
     # Check if the Fish eats this food.
     elsif !self.edible_foods.contains?(food)
       return "Can't eat that!"
     # Make sure the fish isn't being underfed.
     elsif food.amount <  fish_feeding_amount(self.type)
       return "Not enough food."
     # Make sure the fish isn't being over fed.
     elsif food.amount > fish_feeding_amount(self.type)
       return "Too much food."
     end
     # Eat food.
     self.eat(food)
  end

Most comments can be done away with. If we split out functionality into more concise bits, then just reading the code should explain what’s happening better:

  def feed(food)
    return "Not Hungry" if self.recently_eaten?
    return "Can't eat that!" if self.does_not_eat?(food)     
    return "Not Enough food" if self.not_enough_food?(food)
    return "Too much food" if !self.too_much_food?(food)
    self.eat(food)
  end

This isn’t a great example as once again the validation of whether the food can/will be eaten should move into it’s own method or class ever. If we’re follow Uncle Bob’s SOLID principles, the above examples breaks the OCP (Open Closed Principle) where entities should be open to extension and closed to modification. If more validation rules were needed, then that would require the code to be modified.

So you want to be a developer?

Programming·Career Web Learning

I’m so glad that I’m not just getting started as a web developer these days. Facebook is the main example I give to people when talking to about this. It has set the standard for what and how people think a web app should behave. Move forward or backwards through photos and they are dynamically loaded without refreshing the page. Send someone a message and a modal box appears with autocomplete on the textboxes. You can browse the site, chat to friends and do all sorts of stuff without ever having to experience a page refresh. I even remember when they added AJAX to their photo albums. I mentally flipped as it made the site so much more usable. I showed it to someone going “Look! Look! There’s no page refresh.” while they just shrugged and went “I don’t see what you mean.”, D’oh… exactly! The sort of stuff no one even realises is happening. But I’m sure they’ll feel the difference if they use functionality on your site that’s similar to something Facebook does, but which requires a refresh where as Facebook doesn’t. Even I feel the pain of moving forward and backwards through photos on Flickr. After the third or fourth page refresh, I just give up.

When I got started, web stuff was so new and so simple that in hindsight it was amazing what you could get away with. You could just fly by the seat of your pants. I know I did. The first piece of web development I ever did was back in the mid nineties two days before my first interview. I wrote a Java servlet that simply took a single text parameter and queried a MySQL database using JDBC. I showed it at the interview and got a job as a web developer using Perl. I didn’t even know the Perl but still got the job. All I had to do, day-in, day-out was write HTML and scripts that responded to clicked links or submitted forms. Submit, refresh and display the result, job done, I can go home now. Creating a site wasn’t hard, almost anyone could do it and almost everyone was at the time. Life was simple and it was pretty much a level playing field. Now though, it is a totally different ball game. You’ll need good knowledge of at least a couple of languages, HTML, CSS (Yes we need it to work across all the major browsers), SQL, Javascript + a framework like jQuery + how to use AJAX.

There is just so much that you need to know that if you’re not doing this in your spare time, how are you supposed to ever compete with the kids nearly half your age who can already do this stuff with their eyes closed. Even me, who does this stuff every day as a job has to learn more and more if I even want a chance of staying relevant and employable. I love learning, so it doesn’t bother me. Programming still excites me on and it has to if you ever want to make a go of doing this for a living. Sometimes you can be in the fortunate position of working for a company that really loves this stuff, so you can learn and grow, but I suspect the majority of IT related jobs are done in companies where IT is a second thought to their overall business goal. Where managers prefer to say “no” to your ideas rather then say “ZOMG we could totally awesomely AJAX th1s!!!11!”. And the learning doesn’t just stop at work related subjects. There’s a lot to be said about learning new languages and techniques totally unrelated to your work. Not only for the mental stimulus but also how they can teach you to approach a subject in a new way. I admit this is perhaps one area where I don’t spend enough time, but I’m trying. So go forth and learn. Be totally awesome.