Saying goodbye to Ibuildings to found Egeniq

August 12th, 2010

Those who pay attention to my occasional seemingly random tweets may have noticed this tweet, back in March. It's the first line of the Bob Dylan song "Times they are a'changin", and it marked the start of a long thought process. I had a '10 year itch': I was at Ibuildings since january 2000, back then a 5 person web development shop in the south of the Netherlands, and over the years I had helped Ibuildings grow into a 110+ people PHP service company with 5 offices in 3 countries. Very proud of what Ibuildings had become and my own role in the company, I had a growing feeling of 'what next?'.

In my enterprise PHP book I mentioned 5 major goals I wanted to accomplish in life: one of them is to found and build a company of my own. And although Ibuildings has always felt a bit mine, that's not the same. So I slowly started thinking about starting from scratch and building a new awesome company. Over the course of the next few months I searched for reasons to leave and reasons to stay, but eventually I knew that in my heart I had already made the decision in March, and all I was doing was finding reasons to validate that choice. There's a saying that in the end, you'll only regret the things you DIDN'T do, so finally I made the decision to go for it.

What am I going to do? I'm going to found Egeniq, a company centered around a number of mobile products, concepts and related services. Over the course of the next few weeks it will become more clear what exactly we will be doing, but in short it's doing cool stuff with iphones, ipads and android devices (and whatever device makes sense). I've found partners in crime: Bas is going to look after the commercial side of the business, and I'm going to look after the technical side together with a person that I've known and trusted for years (but it will take a couple more weeks before this person's able to announce it).

So far I've been a member of the PHP community; will this change when I am working with mobile devices? No, on the contrary! I'm both proud and happy to be part of this community, and you can bet that the products we will be developing will have loads of PHP in them (for backends, apis, webservices and the occasional web frontend). I'm still speaking at Zendcon in November, have a new book coming out soon and I hope that Egeniq will be able to contribute to a couple of open source projects.

I'm very thrilled to finally have this out in the open. I have very supportive friends and family, but I'm still both excited and scared at the same time; I'm giving up a great career for a lot of unknowns, and this may very well be one of the most important decisions I've made in my life so far. So any words of wisdom, encouragement or just plain 'you are stupid for doing this' feedback is more than welcome!

And to start plugging my new company right away: send all your ideas, project requests and CVs to ivo at egeniq dot com. ;-)

I will be with Ibuildings until the end of September, mainly to hand over my responsibilities and make sure that we part ways smoothly. My job at Ibuildings has been amazing and I'd like to thank everybody I worked with, every client I worked for and everybody at Ibuildings for a great time. This is not the end, it's a new beginning. A beginning I'm very much looking forward to!

Good use of public, private and protected in OO class design

July 19th, 2010

It's been a while since my last post. My blog pattern these days is that I write a blog post when I have an opinion that doesn't fit in a tweet. :)

There's been a debate in the PHP community about the use of public, private and protected. Apparently the Symfony project has decided that private is Evil, and should not be used. I don't care much about Symfony as I'm not a user, but it turned to a discussion on OO theory when Stefan defended the position by claiming that you 'should have the right to extend a class's methods if it doesn't support the use case you have'.

On Twitter, things got worse. Marco Tabini mentioned private has no role in open source code insinuating that it's about who can read the code and Travis Swicegood mentioned that protected code indicates code that is in the wrong place and later that it prevents unit testing because it creates un-testable units of code.

Before I answer to those claims, let me give you an example of a class that uses public, private and protected in the way they were intended.

The Account class

 
class Account
{
    public function depositFunds($amount) {
        $this->_updateBalance($this->currentBalance()+$amount);
    }
 
    protected function _updateBalance($newbalance) {
 
        if ($this->validate($newbalance)) {
 
            $this->__updateRecord($newbalance);
            $this->__publishAccountUpdatedEvent();
        }
    }
 
    private function __updateRecord($newbalance) {
        $this->getModel()->store($newbalance);
    }
 
    ....
}
 

As the designer of this class, I have the following considerations:

  • Somebody that uses my class in an application will need to be able to withdraw and deposit funds. This is the only feature I offer to my class users; it is my class's responsibility to take care of handling the withdrawal and deposits.

  • Derived Account classes (which will follow the 'is a' scenario of inheritance and thus will probably be special types of accounts, such as savings accounts) should be able to withdraw and deposit, but can also call _updateBalance to update the balance directly. This is something I trust derived classes with.
  • The actual act of updating the underlying model is my responsibility and my responsibility alone. This method is private because I do not want other classes to call this function directly. The only way to call __updateRecord is through the protected _updateBalance call. This way I ensure that there's always validation and that notifications get send out. This makes my application more robust because the things that need to happen, will happen. I trust derived classes to update the balance, but the trust goes only so far; the actual act of updating the underlying model is my responsibility.

This process is called 'encapsulation'.

Looking back at the arguments

Now let's look again at the arguments.

  • Stefan says that he needs to be able to override things if they don't support his use case. The above class is designed to support a variety of use cases, through the interface it offers to users and inheritors. Generally a use case is defined by the public methods a class offers, and that should be sufficient. If not, the class may have been designed poorly. Inheritors can change the use case slightly, but only to the extent that they do not endanger the overall robustness of the application.

  • Marco says that private has no use in open source projects. The above example could be part of an open source project. The decision to make a method private had nothing to do with the fact that others could read the code, nor did it have anything to do with the fact that the code cannot be changed. If this is an open source package and you want to change it because in your world you do want unvalidated account updates, you can simply download the code, change the code and be happy.
  • Travis claims that 'protected' signifies code that is in the wrong place. On the contrary, in my example I've used protected and private deliberately to design class responsibility.
  • Travis also says that it is a problem for unit testing because it creates an untestable unit. I would argue that in this case, the 'unit' is the account and its public interface. A unit test should use only the public interface which is sufficient to verify whether or not the class is doing the right things, and whether it's doing those things right. If the class contains so much code that you need unit tests that test the smaller internal functions of the class, you may be looking at a class that has too much responsibilities and that should be split up.

The arguments seem to be mostly about what you can derive but the number 1 use case of access specifiers is defining what you can call. In my opinion, preventing people from using private to make deriving easier at the expense of no longer being able to specify who can call what and define class responsibilities, is wrong. In most cases where this is a problem, the actual problem is poor class design.

There are of course numerous situations where the designer of a class has made the wrong decision and made a method private that should've been protected. In such scenario's, changing it and contributing a patch seems the right thing to do. However removing the use of private from a project entirely because some can't handle the difference, seems very wrong.

Other languages

PHP is not the first language to support private, public and protected. Other languages have seen similar debates, with more or less the same underlying principles. Ruby has built in ways to circumvent private/protected/public so functions can be unit tested. C++ is the most advanced when it comes to OO design. It supports 'private inheritance' and 'protected inheritance'. See here for examples. Also it supports a 'friend' feature that allows a class to define 'friends' that can access their private members. If classes befriend their unit tests, then unit tests can access private functions.

PHP doesn't have a 'friends' feature (I nearly said 'PHP doesn't have friends' which does sound funnier but is not what I meant ;-) ) nor does it have ways to circumvent the access specifiers for unit tests. That doesn't make the concept of private and protected any less useful though.

Twitter Takes Tweetie. Good or bad?

April 10th, 2010

Yesterday Twitter announced it has acquired Tweetie, the popular Twitter client for iPhone (and Mac desktops but the move seems to focus on the iPhone app).

Disclaimer: I love Tweetie; dispite it not being free (it will be free from now on), I liked it much better than the free alternatives.

For Twitter, this is a good move. It will finally give them an 'official' client for phones. They also announced a Blackberry app yesterday, and you can easily see that they needed one by looking at their 'Using twitter with your phone' page. It explains how to use Twitter using SMS, something that never really caught on as a main twitter use. With this move, Twitter fills a hole they had in their product offering. It is very similar to what happened in 2008, when they acquired Summize, which is now search.twitter.com.

Back then I predicted this could be their business model and this move perfectly fits within the strategy I then described.

When acquisitions like this happen, twitter is full of opinions. Here are 2 that stood out for me:

screen-shot-2010-04-10-at-102635-am

screen-shot-2010-04-10-at-102739-am

Now it's perfectly logical that Funkatron is emotional. He is the author of Spaz, another popular Twitter client. When looking at it more closely though, we notice that Spaz is not available for iPhone, and Tweetie is not available for most platforms Spaz supports (the only overlap is Mac desktops). Also, Twitter owning Tweetie has no effect on Spaz's Statement of Purpose. Still I can understand Funkatron's sentiment. I was in a similar position when Google released Google Calendar when I had just developed the first version of Epointment, but in the end that's life. Sometimes you gamble and loose. But Spaz hasn't lost yet. It has a massive amount of followers so there is no reason why it shouldn't continue to flourish.

Ramsey's argument is that this stiffles choice. Surely the fact that Twitter can heavily promote Tweetie as the default iPhone client will help boost Tweetie's popularity and will make it harder for other clients to market themselves, but it does not stiffle choice.

I've seen comparisons to Microsoft killing off Netscape. This was different because Microsoft bundled IE with every copy of Windows; Twitter has no way to bundle Tweetie other than promoting it on their site. As long as Twitter remains an open platform, opportunities to create your own clients will remain. There are numerous examples:

  • Microsoft owns the official MSN client, yet there are tons of popular MSN clients out there.
  • Philips invented the CD yet there are many CD player manufacturers. Philips is not even the most popular one.
  • Google owns Google Apps AND the official iPhone client, yet there's a ton of iPhone application clients that users can choose from
  • Slightly unrelated but very similar: Vimeo wasn't killed when Google purchased YouTube, nor was Facebook when Google acquired Orkut

It will be a different story if Twitter stops playing fair. If they close their platform, shut out other clients, THEN it will be an evil move. But as long as the platform remains open, competition will be slightly harder for Twitter clients, but the rules haven't changed and we're playing the same game.

Remember the Long Tail? Today's business is all about 'finding your niche'. Sure, Twitter just moved Tweetie to the left side of the tail, but there is a huge long tail of users and niches that people can still cater too. Spaz and other Twitter clients have unique properties that make users choose them as their Twitter clients. If they wouldn't have those, they would not have a chance against other Twitter clients no matter what big corporation owns them. In fact, I believe that this move by Twitter will lead to even more Twitter users as it becomes easier to start using Twitter on your phone. This means that the market increases, even for companies that build clients and other software on top of the Twitter platform.

Finally, this discussion is similar to Apple's OS4 announcement. By announcing their own gaming network and their own ad network, they struck a huge blow to existing networks such as OpenFeint and AdMob. These companies are now forced to compete with Apple by building a better product and differentiating their products. Will this kill them? Maybe, maybe not. In the end, it doesn't matter who owns what tools; the users determine what they will use and what products will survive.

And sometimes business is just like playing poker. If you're not willing to lose, you shouldn't play.

A review of Foursquare, Layar and the Foursquare Layer

March 13th, 2010

Location Based Services are hot

Ever since phones have been equipped with GPS devices it's been possible to provide applications with information about the user's location. I used to have a Nokia N95. It had a GPS but other than Google Maps, I never did anything useful with it. When I switched to the iPhone a couple of months ago, I started to use more and more apps that are location aware. The main reason why it works for me on the iPhone is that the iPhone just always seems to know where I am, whereas the N95 only knew where I was when I asked for it. How is this different? If I'm inside a building where GPS signal is blocked, the iPhone still knows where I am, because it remembered the last time it had a GPS signal. The N95 on the other hand would only start to read its GPS device when I started an app, which worst case meant I didn't have a location at all and best case meant I had to wait up to a minute before it had a fix. Usability win for the iPhone.

How is the location generally used? The basic premise is that applications now know where you are, so the most common application is to display maps and your location on them. But what is also fun is that games you play can now compare your score against the score of people in your neighborhood, search engines can show more relevant results based on where you are, shop applications know what shop you are near, travel applications know where you are located so you don't need to enter your start address; the possibilities are endless.

Foursquare is hot

One of the services that draws a lot of attention at the moment is Foursquare. It's basically a game that lets you 'check in' to venues. So you enter a bar, open the foursquare app, it recognizes the bar you are in and finally you press 'check in'. See the official screenshot from the app store:

Foursquare screenshot

What's the point? There are several.

  • First, there's the game element. You get points for checking into venues, and you can earn badges for special achievements. The person that checks in the most becomes the 'mayor' of a place.

  • Second, there's the social aspect. When you check in, you immediately see who else is there, so it provides information on which friends are in the same venue as you. The other way around works too, you can see where your friends are by looking at your friends list.
  • Third is the ability to leave behind tips. As it happens I checked into a restaurant at Gatwick Airport yesterday and got the tip 'before you order a steak, have a look at the knife you're supposed to use'. I had a laugh when I looked at the tiny blunt knife on the table in front of me. Tips such as 'order the Mexican style chicken, it's not on the menu but the chef knows how to make it' are as useful as 'Skip the chili, they have no clue what they are doing'.
  • Finally, Foursquare is working with partners to provide incentives to visitors. It's the Web 2.0 version of bonus point cards. In the future you'll be able to show your Foursquare status to a shop owner to receive special rewards for frequenting the venue.

There is some debate on the downsides of location based applications such as foursquare. Please Rob Me is a spoof of Foursquare that demonstrates how burglars could use the location information to find out which houses are empty. This however is a matter of responsible internet use. I for instance generally only share my location with friends (I don't accept foursquare invites from people I don't know), and if a robber wants to know if a home is empty, there are much easier ways to find that out.

More info: http://www.foursquare.com

Augmented Reality is hot

Not 'hot' in the sense that everybody is using it, but at least large quantities of people are talking about 'Augmented Reality'. For those who are not yet familiar with the term, augmented reality is when you watch the world through the camera of your phone, while your phone adds real-time information about the objects it sees. See the screenshot on the Layar homepage for an explanation.

What's the point? Again, there are several.

  • First, it 'feels like Star Trek'. You point a device at something, and it tells you useful information. This is plain geek fun.

  • Second, it sometimes makes it easier to find things than staring at a map and trying to figure out where to go. Just point your phone away from you and the screen will indicate where you are and what points of interest are in the direction you look at. It's compass 2.0.
  • Third, it's easier to find tourist (and other) information. Instead of firing up a browser or starting a wikipedia app and searching for the statue you're looking at, you just point your phone towards the statue and it will show you what the statue is. This is especially useful if you don't know its name meaning you have no other way to look at it.

Augmented reality is currently based on location (GPS), direction (compass) and sometimes time. This means that if you point your camera at a statue, it will not actually 'see' the statue but it knows you are near the statue and looking in its direction. If there is an object blocking the statue, it would still show the statue. In the future, it will most likely be enhanced with actual object recognition. StickyBits is a prelude to that; it allows you to recognize objects and attach information based on a barcode you stick onto it. Expect similar services using RFID tags in the near future and actual visual recognition in the distant future.

In terms of Gartner's Hype Cycle, I believe Augmented Reality is just moving from the 'technology trigger' phase towards the 'peak of inflated expectations', which means that it will take a while before it becomes truly useful, but it will draw a lot of attention before that happens.

Layar is hot

There are several augmented reality apps in the AppStore, but the one I like the most so far is Layar. Not just because I'm proud that it is of Dutch origin, but because it's the one that is the most usable at the moment. Layar revolves around the concept of 'layers' that you display on top of the camera view of your phone. There are layers showing nearby shops, points of interest, people sending out tweets, foursquare venues, rental price of appartments you look at, houses that are for sale; there are already hundreds of information layers that you can use in Layar.

As to practical usefulness, so far I've used Layar mostly as a gimmick, showing off its capabilities to friends who then also install the app and use it as a gimmick too. I haven't yet had a need or want to actually walk around a city and use Layar to provide me with necessary information. But read on for a practical review.

Layar is available for several mobile devices including the iPhone.

More information: http://www.layar.com

The reality test - Running around with Layar and the Foursquare Layar

The past 2 days I was on a business trip to London, and since my trips to London usually incur a lot of travel with the underground, taxis, buses and just walking around in central London, I decided to put Layar to good use and use it for a couple of days to see if it will 'stick'. Since I also use foursquare, my main goal was to use Layar's Foursquare Layer, developed by Squio.

In practice, this meant that when I walked up to a venue, I would point my iPhone at it with Layar running and the Foursquare layer activated and then check-in. Here are my findings:

  • Phones need a tilted camera for this kind of application. It is very cumbersome to walk and hold the phone in front of you. This means that it blocks your own view and typically looks weird. On two occasions, I had people move out of my way when I was standing on a corner looking at Layar, because they thought I was filming or taking a picture. It would be better if you could hold the phone like you do when you are reading or looking at a map, and the camera would point directly away from you instead of towards the floor. Layar itself has a tilt button that you can use to adjust the display of the layers to how you are holding the phone, but this does not affect the camera view itself.

  • Foursquare's GPS information is not very accurate. While other layers do a pretty good job of exactly pointing out a point of interest, the foursquare layer often gets things wrong. This is caused by the fact that the person who first added a venue is not necessarily located on the exact center spot of the location. I had both a pub and an underground station where Layar would not show me the venue that was in front of me. I had to turn around because the venue in the foursquare layar was located 10m behind me. In the regular foursquare app this is ok, as it is nearby enough, but for augmented reality it is problematic. For underground stations in London it's fairly logical that the GPS spots are outside instead of in the station. When I emerge from the underground and want to add the station as a venue, it takes a few meters before the phone restores both its GPS and network signal, so at the moment I check in, the GPS location is outside of the actual station (but still near enough for regular foursquare use). I have thought of a few great ways to make the GPS more accurate but I'm not working at Foursquare. :)
  • iPhone's lack of multitasking inhibits the user experience. When I wanted to check-in when I spotted a venue in Layar, I had to first authenticate Layar with Foursquare, and then use a custom foursquare check-in page within the Foursquare Layar to perform the checkin. This custom screen lacks most of the features that are important to me, such as directly seeing tips and friends at the venue I check in to. (I had an additional problem where the first day the OAuth authentication between layar and foursquare consistently timed out, so I couldn't check-in using Layar at all at first). If the iPhone supported multitasking, then applications such as Layar could fire up the actual Foursquare app to do the check-in, while keeping the layar open in the background.
  • Maybe this is just a bug, but in map view (where you don't use the camera but a regular street map) in Layar the compass wasn't working, so the map didn't point me in the actual direction of a venue.
  • There are some usability issues with Layar and the Foursquare Layer, where the 'what would apple do' paradigm could help improve the user experience. One is that I always had to do multiple actions: Start layar, select foursquare from my favourites, click through a settings screen even though I didn't want to ever change those settings and then point the camera. Ideally, it remembers the last layer I used and skips settings dialogues and immediately starts with the core functionality.
  • The biggest fun is the gimmick value. When I showed someone what I was doing I almost always got a "wow I didn't know that was possible" response.

So will I be using layar consistently to check into foursquare from now on? No, as, fun as it is, it's not more productive or more practical than using the regular foursquare app. I will use it however as a demonstration of what both augmented reality and foursquare can do. What I will be doing with Layar is find out information about the things around me, most notably when I'm on vacation and want to get information on tourist attractions. In this scenario, augmented reality is more practical and more useful than manually looking things up.