Wednesday 19 January 2011

Rails namespacing test gotchas

We have some controllers that are namespaced as Admin controllers eg: Admin::ProductController.

...and this is a legacy system, and never had any functional tests created for those...

So I was trying to get started on adding some functional tests. I created a test/functional/admin folder, then added a product_controller_test.rb under that, with the usual:

class ProductController < ActionController::TestCase

At first, the tests wouldn't even load properly, and I was getting the following error:

uninitialized constant ActionController (NameError)

That, apparently, is solved by explicitly putting:

require 'test_helper'

at the top of the file. After which it loads fine, and the null-test runs. but after that, I kept getting the following error:

RuntimeError: @controller is nil: make sure you set it in your test's setup method

It seems that you need to namespace your tests too, so instead of the class declaration I have above, you need:

class Admin::ProductController < ActionController::TestCase

The admin folder isn't enough.

Sunday 16 January 2011

Link: Building mazes with Ruby

JamisBuck has started writing a whole bunch of posts on techniques for maze generation, with examples in Ruby.

It's a fascinating read, and I love the little javascript visualiser for the technique (pretty!).

His idea is that maze-building algorithms are a great way to learn a new language - small projects, but fascinating. I agree.

Friday 14 January 2011

Bosses prefer overconfidence to accuracy

Well, this should come as no surprise, but it's confirmed that bosses prefer overconfidence to accuracy when asked for estimations.

I've spoken before about how I personally prefer Truth over Harmony, with estimation as a prime example. Mainly because, when it turns out that an estimate was inaccurate... you know who's going to get the blame for "coming in late".

And yet I've found in the past that if I try for accuracy, the truth is taken as "pessimism" (by comparison with the overconfident, optimistic estimates given by others).

What I found particularly scary (and accurate) was the final quote of the article:

"Thus bosses of software managers take accurate estimates to be a signal of a lack of competence."

This is not how the world should work :(

Friday 7 January 2011

Seven signs your company is really a cult

I just read this article on signs you might be in a cult and Eliezer Yudkowsky's article on cultish countercultishness (where he discusses the cultishness of all groups of humans, and a few theories on how to fight against it happening) and realised that most of the places I *didn't* like to work in - displayed strong cultish tendencies.

Here's a list of the common tendencies I noticed in companies I didn't like working for:

1 - Hierarchical authoritative structure

While hierarchy is inherent in almost all businesses, it was particularly strong in the ones I didn't like working for. What got me was the fact that these companies *stressed the importance* of the hierarchy - ie, the higher up you were, the more important you are and the more you should be faithfully obeyed, rather than, say, the more responsibility you were taking onto your shoulders.

I follow the spider-man principle that "with great power, comes great responsibility"... rather than "with great power comes greater ability to boss everybody else around".

Of course, exaggerated hierarchy goes hand-in-hand with "exaggerated adoration of the respected leaders" (one of the cultish-signs in the articles).

I find this especially the case in companies with strongly charismatic CEOs (or even just one or two managers). Especially so if they can name-drop other big names of the business world they've worked with/for (whether human or corporate)

When you start feeling that you cannot criticise anything that the CEO/manager says simply *because* he's your manager/CEO - then something is rotten in the state of Denmark.

Nothing is absolute - even the perfection of "our great leader". Everybody has faults, and everybody has the potential to learn, yea even from the mouths of babes. So when people are literally told off for having the gall to question "orders from above", you've got something fishy going on.

Sometimes, this idea can affect the whole company:

2 - Absolutism about the company

Either you adore the place with tears-of-joy staining your face, or else you're suspect, "not a team player".

How do you expect the company to improve if you start from a position where everybody must repeat the mantra "the company is perfect and can do no wrong"?

Unfortunately, I've seen this particular problem run hand-in-hand with the next one:

3 - Total immersion

Absolutism can be taken to a personal extreme when you get the sense that you are being told that you are a better person, the more you do for the company. If you spend all your waking hours at work - it shows how virtuous you are, how much of a "team player"... conversely, if you show yourself to be less than ecstatic at a chance to work unpaid overtime, then you must be "not a team player", and thus are suspected of being against the company (somehow)... rather than just, say "a normal person who likes their homelife".

4 - In-groups vs out-groups

AKA "group members encouraged to distrust outside criticism as having hidden motives"

While all companies will of course have in-groups (ie members of the company) vs out-groups... some companies go on to demonise those in the out-groups. I've noticed two obvious groupings that fit in this category:

4a - The inter-company version

"We're much better than *that* company - our competitor over there... everyone there is evil... I mean, they create poor quality products, are trying to take our profits away from us, and are bad for business. They are out to get us! We must beat them and laugh in their faces!"

IMO it is not necessary to demonise your competitors to deal with them. They are just trying to get along in the world, just like "our" company - so they are quite deserving of being treated with the same respect that we'd like to be treated. For example, one should not take every opportunity to take advantage of them. It is certainly not necessary to revel in (or even to actively bring about) their destruction.

4b - The intra-company version

See also: "absolutism about the company" and "total immersion". Especially the use of derogatory phrases for out-groups such as "not a team player".

I've worked in companies where people that resign (even on good terms) are considered to be traitors. Yes, literally traitors, as though you are betraying the trust invested in you by the company. Sometimes they are treated as having taken advantage of the company for money (as though the company did not receive equal value for said money). If you're still working in that company, you're no longer allowed to associate with the "traitors" without also being tainted by the brush of distrust.

Clearly this is pathological behaviour.

In my opinion, healthy companies respect the fact that you are a person first, and a company-member second. People leave companies for reasons other than "betrayal" - and that should be respected, in the same way that an amicable split-up can occur.

Some (good) companies even go on to actually care about what happens to you *after* you leave the company - for example, the well-known google alumni program.

Still, the cultish companies tend to view this as a thought-stopper. If you leave the company, you are now part of the out-group and, by definition, evil. You are simply not allowed to think about it in any other way, or else you are also suspected of being part of the out-group.

Other ways of thought-stopping are inherent in:

5 - Thought-terminating cliches

Some companies are full of these. There are many things that you are *not* allowed to think. Taboos that you shouldn't break or be stigmatised, and they are often hidden behind a cliche that is intended to stop thought in the matter.

The best (general) case I can give is that of "the way things are done here". If this is uttered by anybody at your company, it is intended as a way to stop you from continuing the discussion. It's a big, flashing sign that says "Just don't go there". Trying to show the limitations of such taboo areas just puts you under suspicion.

IMO this is not a healthy attitude towards your company. If you have things that "are just the way we do things here"... then the question naturally arises as to *why*, and whether or not there might actually be a better way. Sure, we shouldn't needlessly poke holes in everything for the sake of it, but somebody asking why things are the way they are isn't trying to tear everything down.

It's also perfectly reasonable to answer the question with "well, it's not optimal, but the time it'd take to change it would outweigh the benefits gained".

That would be an honest answer, and would actually answer the question, instead of "Just don't ask alright?"

6 - Isolation from people not in the in-group

Not as common, but some companies try to keep everything in-house. I've found that the more cultish companies are more likely to look at you strangely if you decide to take lunch outside (you know, with regular people, instead of just with your team-mates every single day of every week...).

I find that this one tends to lead on from strong inter-company in-groupishness. ie, if you view all outsiders as suspect... then anybody that associates with outsiders must also be suspect.

It's also related to the "total immersion" idea. If you truly are a "team player", then surely you want to spend all your waking hours at your beloved company, rather than going out and having a break.

7 - All forms of individuality must be de-emphasized

This is more about the fact that individualism is actively quelled. If you're in a company where the only individual expression you are allowed is in what photo to sit on your desk, and what the trite saying is on your coffee-mug... then you're in trouble.

Cubicles, rules about personal items and the wearing of business-attire certainly all contribute to quelling individuality, but even if these are not present, individuality may be de-emphasised in purely psychological ways.

There are even interesting-but-weird cultural forms of this effect where you are expected to share the passions of your colleagues regardless of whether you, say, don't actually enjoy watching sporting events in favour of reading physics textbooks... or prefer to spend your lunchtime reading rather than discussing said sporting-games (or hairstyles and office gossip, in the case of one set of women I worked with).

It's ok to invite team-members to join into these activities. It's *not* ok to treat people as pariahs if they choose not to participate.

I've even had one company tell me off at my annual review because I wanted to abstain from the company "tipping competition"... regardless of the fact that I have no clue about the sport in question (I was advised to choose randomly... and that <the secretary> had found this strategy very effective to win.)

The most insidious individuality-repression I've found is with excessive worship of groupthink. Where you are expected to agree with all the decisions of your colleagues - and dissuaded from (or actively told off for) finding flaws in "the plan". This especially occurs in conjunction with leader-adoration.

I've spoken about the pitfalls of this in The two faces of optimism.

But it's all just a game isn't it?

Now, I recognise that even in the companies that inculcate these tendencies, the actual people involved (at least at the lower levels) realise that it's all kind of a game... That you don't have to actually *believe* any of this bullshit - just to play along and pretend, in order to "win".

but my response is: why do we have to pretend?

Surely it'd be healthier (for all of us) if we just admit that it's all bullshit and get on with actually enjoying our life?

Especially when a lot of the things we have to pretend actively work against you.

I do not want to pretend that I love unpaid overtime - because I actually hate it - as do most people in the vast majority of jobs that exist in this world.

I really do have better things to do than marching up and down the square... and I think that everyone can actually come up with something or other they'd rather be doing with their life. So why go through the charade? Why force me to lie to you about it? What does that gain?

There are actually companies that don't.

They are unfortunately few and far between... but they do exist.

I've noticed that smaller companies are actually far less prone to cultishness. Perhaps because there are so few people that everyone's more accountable, perhaps because they're too new to have an ingrained cultish culture... I don't know.

There are also companies who have purposely adopted a culture that leads to a good work-life balance.

I do like Eliezer's Cultish countercultishness post because it gives a good overview of the problem (with reference to his particular group), with the final moral being that almost all groups have a tendency to cultishness... that you have to actively work against these natural tendencies to make sure you don't fall into the trap.

So, in short, if you're in a company that is not cultish - my advice it to work hard to make sure it stays that way.

If you find that you are in a company that is irreparably becoming a cult... look elsewhere.

Saturday 1 January 2011

Link: How to ask a blogger for backlinks

An excellent new post on kissmetrics about How to ask a blogger for backlinks and reviews.

It gives some great tips about how to be professional and non-spammy, and stands in stark contrast to my own recent experience.

...and no, they didn't ask me to write this :)