Saturday, 21 January 2012

Ruby Open Classes


Coming from the .NET world, if we ever wanted to improve a class (by adding to it's code), we really only had a couple of options:

Subclass

This is limiting because .NET is a single-inheritence model. This means a class can only be subclassed once. So if other developers want to add more functionality, you can end in an inheritance chain nightmare.

Extension Methods

Since .NET 3.0, we've had extension methods. These allow you to bolt your own methods on to a type - the one gotcha being that they must be static. This would mean that you could only get at any public members of the instance you are executed against.

(I should note, these are not criticisms of the language. Just because I have jumped ship to Ruby, I still consider .NET to be a top-notch framework)

Enter "Open Classes"

In Ruby, we have what are called "Open Classes" - and they are pretty much what they say on the tin. Classes are open for extension and modification (yups, direct violation of the Open-Closed Principle).

Anyway, enough talk, let's see the code.

Example 1: Opening String

First up, let's simply add some nice functionality to String to see if it's a valid email address.

Lets get the a regex for a RFC2822-compliant email address.

Courtesy of [regexlib](http://regexlib.com/REDetails.aspx?regexp_id=2558):
^((([!#$%&'*+\-/=?^_`{|}~\w])|([!#$%&'*+\-/=?^_`{|}~\w][!#$%&'*+\-/=?^_`{|}~\.\w]{0,}[!#$%&'*+\-/=?^_`{|}~\w]))[@]\w+([-.]\w+)*\.\w+([-.]\w+)*)$
Even though this is of course very easy to remember, let's make it a little more readable:



No messing around, and makes for somewhat readable code. Moving on.

Example 2: Opening and using instance variables

What's cool, is that we can access all the instance variables in the class too - this means we can truly extend the class with little effort (and where it gets one over on extension methods).

Let's say we are using a piece of code from an OSS library that returns error codes from printing devices. We don't want to keep passing the return values around to retrieve the commonly used error message that accompanies it. However, these messages are business-specific, so don't belong in the OSS library.


The dark side of the force

As you can see, this is pretty powerful stuff, but as you know with great power comes great responsibility.


Not so good. Jay Fields has a great article on alternatives that may be useful if you find you need to tread on other peoples toes..

A lot of my fellow .NET developers are probably screaming at the monitor at this point "WHY BOTHER IF IT'S SO DANGEROUS" (I thought the same when I first saw it) but the truth is this - in the right hands (and I consider the developers I tend to frequent with far more talented than myself), it's a powerful and can a very useful feature*.

* Especially if you discover some weird bug that you need to patch before you can get it merged into the main code base.

Saturday, 31 December 2011

2012: The Plan

So, here we are with another new year just around the corner.
Call be boring, but this is one of my favourite times of year, not for any parties that may ensue, but because I get a chance to plan exciting things to do - and then do them.

I really did a lot of ground work in 2011, which I really want to build on in 2012 - so here we go!

Business Goals

New category because I started this in 2011 :)

  • Get moflo and dreamBIGLY to the point where it is earning enough for myself and my co-founder back to a normal salary (we have taken a rather substantial paycut since we are bootstrapping).
  • Get one charity project out of the door.
  • Start a secondary business that is completely out of my area of expertise (software development).
Financial Goals

Not much to do here really, I did too good last year ;)
  • Get investments up and running. I've been talking about this for ages - time to stop talking and start doing. Goal is 10% ROIC.
  • Clear my last piece of debt. I have a single loan that remains then I am 100% debt free!
Personal Goals
  • Start getting serious about my life list. Complete at least 2 items (preferably 4).
  • "Go Local" in another country. Live in another country for at least 3 months.
  • Publish, document and complete two projects on Lambs to Lions.

Some pretty big items in there - I really can't wait to get my teeth sunk in to them! It's definitely nice to be working in more of an "improving" mode rather than "starting" - starting is always the hardest bit.

What do you plan to do in 2012?

Make no small plans!

2011 Round-Up - How Did I Do?


Wow, doesn't time fly? I can't believe it was a year ago that I wrote this.

So - how did I get on? :)

Supplement income by 25%

I started off with this one quite slow - I sold a few items (which dovetailed nicely with my minimalism goals) and made a few hundred pounds. Obviously, this is a long way off my goal.

I then decided that is was time to take the plunge and go contracting. This then really gave my bank account the cash injection it needed and brought me up to about 20% increase.

While this didn't hit my goal of 25% - it's pretty damn good because it pushed me to take a bigger step that has pretty much changed my life.

Leonis Software was born.

Reduce fixed outgoings by 25%

Last year, I was living on my own in a 2 bedroom flat in Southampton. I was spending a small fortune commuting, not to mention had a relatively high cost of living. I was hellbent on reducing these costs.

I am really, really pleased to report I have reduced my fixed outgoings by a whopping 68%!! This has really opened a lot of doors for me and was also a big part of enabling me to get Leonis started.

Leave the UK at least four times

Managed 3 - Amsterdam, Las Vegas, Paris. Also went to Scotland (doesn't count as UK though). Loved Amsterdam, Vegas and Scotland. Paris - not so much. Good times had all round though and I love going on flying machines!

Downsize the apartment

From 2 bedroom flat in Southampton to 4-person houseshare in central London. Done.

Launch at least one product that is *at least* self-sustaining

Our first product moflo is live, and currently paying for itself. dreamBIGLY will be live *very* soon.

Now, just need to work on PROFIT!

In summation

I am really, really happy with the progress this year. I really feel like I am back to my old productive self and now working on products that I really, really believe in.

I've already had some contact from people using moflo telling me about how it has made them less stressed and they feel more in control of their finances which really rocks my world!

Super-excited about the imminent launch of dreamBIGLY - while budgeting is important (and not as boring as people think), there is already an amazing community of incredible people that I am really looking forward to engaging with and helping them achieve their goals (as well as my own!).

While financially I do not have the massive amounts of savings I would have liked - I have made a MASSIVE change to my working life. While I may need to go back to contracting for a short while to inject more cash into the business, I really can't help but feel like it's a case of when we get the products profitable, not if.

This year has also put me on a great footing for 2012, which I think will be a lot more "fun" orientated - good times!

Wednesday, 24 August 2011

Agile: Do Or Do Not, There Is No Try

Recently, Paul Stack asked me a leading question in preparation for his post: "Is it really agile?". The question was:

"do you think organisations are turning their back on agile?"

My answer to this question was "no", and here are my thoughts.

Who are we talking about here?

Firstly, we need to establish that there are two kinds of organisation. Those that are actually living, breathing, functioning agile teams that have no problems adopting all the processes, ship regularly and deliver things of high value to their customers. These guys are not who we are going to be looking at here.

We are interested in the remainder, the guys that may or may not be "trying" agile, but for one or more reasons, cannot be considered "agile" (more on this to follow in a later post). This is to keep it simple so we can just focus on the current "problem".

The three wannabe agile-eers

Let's look a bit more closely at these agile wannabes.

In my experience (as well as talking to a variety of people from many organisations), I find that organisations not doing agile fall in to one of these three categories:

  1. They honestly believe they are doing agile, but don't realise they are doing something wrong, or they change/remove practices because they "know better" or it "doesn't apply to us". Let's call these "The [Self] Proclaimers"
  2. They think agile is a bunch of BS and just "another way for developers to get out of doing work". Let's call these "The Non-Believers"
  3. They simply haven't heard of it, or do not know what it all means. Let's call these "The Lost Souls".

I'll go over the last two first, because I actually feel that these are really the minority.

The Non-Believers

This is plain and simple "this agile stuff is a load of BS and it's simply not applicable or not all it's cracked up to be". This is often coupled with "it doesn't work with the type of projects that we do" or disbelief that lightweight processes can *possibly* produce better quality results the incredibly thorough process that has been formed over the last 30 years.

This pains me for two reasons:

  1. The organisation in question are working in a fast paced industry and outright refusing to look at what is changing in the environment around them.
  2. Rather than experimenting with something new, they are reverting to "I know what's best" before even giving something a fair shot.

Tech and a stagnant environment do not mix. Yes, your company may have got along just fine in the last 20 years, but times are changing my friend.

My advice

Managers, stop hating/being dismissive and start finding out. Talk to people, there is an abundant, thriving agile community full of incredibly talented people out there (sure, there is also a lot more untalented people as well now that it's become a bit of a buzzword). Ask questions, lot's of them. It will become pretty clear pretty quickly if people know what the are talking about. Hire them part time (I personally don't believe a "scrum master" is a valid full time job, at least post initial roll-out - sorry guys). Yes, I will be happily be this guy (shameless plug - email me if interested).

Developers, have a chat with your managers. Let them know how much this means to you. Offer applicable advice on how you think agile could improve current processes. Come up with some metrics where possible. If you continue to have problems, consider moving elsewhere. There are plenty of great agile shops doing great things that will snap you up.

The Lost Souls

These poor guys are so out of touch that they really have no idea what agile even is or supposed to do. Aside from wondering what the hell their CTO has been doing, this really leaves us in a bind because if the organisation was to suddenly "discover" agile, then they would have a LOT to take on in both learning and deployment. Ouchies. Thankfully, these companies really seem to be in the minority now. However, some do still exist.

My advice

Same as above really. However keep in mind that we are starting at square 1. In some cases this can be a benefit since it can be easier to get started if people just take the current practices as-is. On the flipside, you could also encounter a lot of resistance. Perhaps more because there is so much to take in.

Take it slow and steady. Learn lots from those in-the-know.

The [Self] Proclaimers

I think these guys are now the vast majority of companies, they have seen about agile, and given it their best shot. Then then tend to end up in one or more of these situations:

  • They don't participate in one or more key agile practices.
  • They "adapt" practices (normally adding more "process") because "agile isn't enough" or "it's our own flavour".
  • The guys heading up the agile rollout move on to another organisation and those that remain don't have the knowledge/passion to follow it through.
  • They are simply lying (yes, I have experienced this).

My advice

These guys are the trickiest to deal with, since they often genuinely believe that they know better.

Managers, stop and listen. Just stop trying to "be in charge" and listen to your dev team. Are they surprised you are listening? Do they have pain points that are slowing them down day after day? Why are they there? Can you remove them? Do you need to know more information about agile? What exactly is it these agile guys do? Can you let someone in the team take responsiblity? How about you get some training yourself, or hire someone to come in and help out? Start respondng to what people are saying. In every organisation like this I have seen one thing in common - all the managers "think" things will be nice, but never take action. Either take action or enable someone else to.

Developers, I warn you, this can be a slog to get through. Keep voicing concerns with current processes. Metrics can often be a big help because no matter what a manager thinks, "numbers don't lie". Try using the questions above to assess what the manager knows, what is blocking them? Help them to help you. In most cases, the developers know what needs to happen, but if unsure, talk to other developers or get someone in to assist. This can be really useful because they become that "target" if anything goes wrong, or meetings etc. are required.

The bottom line

It boils down to this:

When your competitor "gets" agile, they will ship more than you, faster than you and at a higher quality than you. They will have a lower bottom line, and they will erode away at your market until you have nothing left. Waterfall and other broken processes will work, of course they will - but agile works better.

How can you expect to beat a processes designed from the ground up to produce fast, effective and valuable results?

Friday, 12 August 2011

Finding a Cure for the Creative Itch

Itchy!

I am on a journey, and I am walking pretty fast - it feels great, it's invigorating. As I progress, I find myself entering a new environment, one that I have yearned for but is still somewhat alien to me. I am entering a strange new land and I need to acclimatise.

My Journey Thus Far

I am working my way toward my dream. I have freed myself of the corporate shackles and now working on my own project in the background while contracting. Once I have enough cash in the bank, I intend to quit work altogether and go full time on said project to bring it to fruition (or fail and move on).

But as I progress towards this strange new world, I feel one key emotion - sheer excitement. Yes, there is a little fear in there too, but this is the indicator of doing something worth doing. Risk often means greater reward. Rewards are exciting. Yay.

My Best Allergic Reaction Yet

But, I have found myself suffering with something...

I have discovered that the only thing really holding me back from doing something - anything, is me. This has caused my mind to literally explode with ideas. I keep seeing new problems and thinking "how can I solve that?". Not in my traditional "with code" geeky sense, but I am thinking about businesses, profits, sustainability, what people do I need to pay to help me make it happen?

It's fun, it's exciting - but it's overwhelming and distracting me from my current work. It's a really bad itch.

A Cure For the Itch

Right now, I am trying to get over this by simply getting my ideas down into mind maps and thinking "I will come back to it later" and just trying to get my brain back on track. This kind of works, but I find it really hard shutting my brain off once I get excited.

The thing is, I can't help but feel that I cannot be alone here!

How do you find a cure for the itch?