Tuesday, 11 March 2014

I want off

Today is the day I lost my last remaining ounce of hope. I want it to go on record I tried with you people, I really did. I wanted this work, I wanted us to be happy, but.. we just can't. Oh and by the way, it's not me... it's you.

First, this is a thing

I found this today: literally unbelievable. It's a collection of references to The Onion articles taken as factual by the author. I just don't want to live in a world where satire has been rendered obsolete... either because people are too broken to recognise it, or because reality is too broken for people to tell the difference.

Secondly, parcel deliveries

I ordered a book to my work address, which is a company name at an industrial estate. First attempt was made to deliver on Sunday. Today, I received a text saying delivery would be attempted at some point after 5. Just after 5, I thought I would stop by reception on my way out and check if the delivery had been made. The van was parked outside and the receptionist kindly caught up with the delivery driver to ask him if he had my parcel. He stated he had one more left to deliver, for Sarah, in my office. I explained I had a text stating the delivery was due today, at which point he looked at me and said "Are you Anthony?". I confirmed that I was and he replied "Ah great, your parcel is in the van, I was going to deliver it later, so you've saved me a trip" and gave me a big grateful smile.

Thirdly, ban bossy

Ban bossy Really? I mean, seriously? All I have to do, in the opinion of Jennifer Garner, Beyonce and other such assorted ass-clowns is not call my daughter bossy in order to rear a confident, self possessed young woman brimming with self-esteem. Wow, well that's just lifted a massive burden from my shoulders, because, up until now, I'd foolishly assumed rearing a child might be a super complex task which couldn't be boiled down to a simple slogan!

I've needlessly fretted that I may have to handle each scenario based on it's own merits, with no real road map to guide me but an abiding love for my child and desire to do what was best for her in the long run (which, I'd chauvinistically thought might include teaching her when it was time to give daddy just a touch of peace and shut her noise hole). However, I now realise that it's only male children that need to be prepared for the harsh realities of life by learning to curb their natural self obsession in order to become more rounded and caring individuals in the future. Girls on the other hand, need to be encouraged towards narcissism so that one day they'll have the self confidence to stand in front of a camera and say, with a straight face, "I'm not bossy, I'm the boss". Imagine your pride as you turn to the person next to you and announce "That megalomaniac douche burger is my daughter".

Previously, I had failed to realise how powerful a word bossy is. As Anna Maria Chavez tells us "When I was growing up, I was called bossy" and we can see that she's turned out to be a complete idiot, so... case closed, lets ban the word bossy. The powerful info-graphics make the case even more air tight by claiming "Between elementary and high school, girls’
self–esteem drops 3.5 times more than boys’.", obviously with a statement that powerful, you don't need to cite the study involved, it's just a fact! The correlation between a self reflective property measured in juveniles and the use of the offensive word being self evident and thus requiring no proof.

I shall be spending all my resources on finding a way off this planet and leaving you to it.

Saturday, 1 March 2014

Considered harmful: rockstar developers

Ten years ago when I told people that I worked with computers I would often get the response "you don't look like a geek". These days no one seems to think it strange. I currently work in an office in which some of the developers talk about football and have meaningful social relationships. Being a software engineer has become somewhat cooler; as part of that "coolification" process, certain things have changed and other things, which always existed, have been named and magnified. Rockstar developers have always been a thing, but now they have a name and are often seen as desirable. Before I start to explain why I think rockstar developers are harmful, lets define one and the circumstances in which they are harmful.

Characteristics

  • Above average understanding of their language.
  • Love of esoteric knowledge.
  • Egotistical style of programming.

The first two items on the list aren't in any way negative, however, they can lead to problems if not applied responsibly with reference to the environment they are used in. It's the third characteristic that I believe leads to harmful behaviour, because the "me, me, me" can overrule common sense when it comes to the application of logic in a given environment. So there is a tendency to create overly complex solutions to simple problems as small monuments to personal vanity.

Habitat

If you are a rockstar developer as described above, working on a solo project, then go ahead, knock yourself out. It's like being a singles tennis player, there's no need to alter your style for the benefit of others. Have fun, it's your code.

If you are working in a commercial environment, being paid to do a job, then it's not your code. If you are working with a small team of like-minded rockstars, then I hope it's the nirvana it should be and once again, have fun! Unfortunately, the likelihood is that you are working as part of a team of individuals of mixed ability. This, to me, is where rockstars become harmful. It's almost always a problem related to the egotistical programming style creating problems for others. If you are part of a team, then you need to act like it and put the needs of others above your own need to show off.

Obfustication

Yea, sure, bitwise operators are interesting and using them can be a shining badge of your elite status, I mean, how else will people know you can use them unless you do? In a large team, with high code churn, it's pretty likely that someone else will have to read / understand and then modify your code. If you have code reviews, then it's a certainty. Here's an illustration with some reasons why obfustication is awesome and my rebuttals. It's not a real conversation as I wouldn't change someone's code without talking to them first.

"Hey broheim, I was checking the logs and saw you changed my code dude, what's up with that man? It's like, you took my gnarly code, babyfied it. You know your code doesn't do the same thing right?"

"Yup, it's more readable now and therefore maintainable by all members of the team, so I figured it was worth changing. I understand that your code is checking purely for -1, but that's a different discussion."

  • Original code: if (!~index) index = 0
  • New Code: index = index < 0 ? 0 : index;
  • The new code is a conditional ternary operator which is used quite widely in the codebase, if it wasn't, I'd have written:
    if (index < 0){
        index = 0;
    }

Here are the most common reasons I've heard as to why something like the original code is better. In my rebuttals my arguments are designed to be for the general case of unnecessarily complex code while still referring to the specific example.

It's not my fault everyone else is an idiot.

Although I've put this point in it's harshest possible form, this is the point I feel has the most value. Finding code you don't understand and looking it up is a very valuable way of learning. In this case though, I'd argue that it's not the right code in the right place, it's just a block of vanity code. Even though you understand that the ~ operator switches the 0's and 1's around in the binary representation of the operand, it still isn't immediately obvious that the code is checking for the case where index is equal to -1. There are enough complex things which require complex solutions, lets leave simple things as simple. It's also hopelessly naive to assume that people will understand unnecessary complexity just because they should. It's like leaving your wallet in your unlocked car because no-one should steal it.

Optimisation dude!

Ok, this is a blog post all on it's own, so we'll gloss a little here. Lets just say that there are two forms of optimisation that are important in a commercial environment.

Code Optimisation

Most important point: optimise where it hurts. Looking at the performance difference in time between our different approaches is all well and good, but we need to take into account the environment in which we are working. At the end of this code, we then append the result to the DOM. Optimising a conditional in this environment is like optimising your drive from Glasgow to London by running to the car (perf. test).


Graph showing the similarity in speed between multiple conditionals when compared with the act of accessing the DOM

Maintenance optimisation

In general it is much easier to show the cost to a company in lost man hours caused by hard to maintain code than it is to show the boost in profits caused by pre-optimised code (I'm referring here to code optimised by a developer prior to any requirement from the customer). So it's usually preferable to write maintainable code first and then optimise where it's hurting.

Complexity is better

I know this may sound strange, but I have first hand experience of a culture in which a complex solution to a problem was considered better by virtue of it being more complex. After a long discussion of the differences between two possible solutions, it was finally agreed that both solutions achieved the same goal. One group insisted that the more complex solution was better "if you are a developer", yet were unable to define a single benefit of the complex solution over the simpler one. I have also been told, as a put down, "yes, I understand your proposal, it's so simple even my grandmother could understand it". Despite how crazy this sounds, it's actually an easy trap to fall into. If something has been hard to work through, it can be difficult to accept that there is an easy solution, you want it to be difficult and require a complex solution to justify the time it took you. Again, beware of your ego.

Conclusion

Coding is interesting and those of us who do it for a living are lucky, we get paid to do fun stuff. Being good at coding is something you want to show off, but like many things it's not the flashy stuff that shows your mastery. A complex piece of work, that is simple to read and understand is the sign of great coder. The good thing about this attitude is that it scales. What you think is easy to read depends on your level of competence, to someone less experienced there may be logical tricks you've used that they have trouble following. This is where they will learn from reading your code, but without the unnecessary obfustication we've been discussing.