You are at the newest post.
Click here to check if anything new just came in.

## January092011

### Terminology: theory, fact, or truth.

Far too often I hear/read people’s stories on topics formulated in a way that they are stated as ‘truth’, when they are actually ‘theories’. Often this is simply a human error, but it can also be intentional and used to ‘brainwash’ people.

DISCLAIMER: I know I have used the terms loosely myself, far too often, out of human error. Hence this article is as much a reminder to myself as it is to others.

I’ll try to keep it short, as this fun article explains it way better than I could ever formulate and I urge you to read it. (Especially don’t miss out on the “What to do” section.)

So why is it so important that you should use these terms the right way? Because using them in the wrong way will undermine your own statements. I’ll try to illustrate this with a real-life example that I have encountered a couple of times.

Consider a discussion on whether or not alien life forms exist. It is my personal belief that they do exist, but I have no irrefutable proof for such a statement. So if I were to say “alien life forms exist, because I read such and such”, I will undermine my own statements, because I can NOT (for a fact) proof them to others. Instead I should say “It is my belief that alien life forms exist, because I read such and such”.

The bonus of proper use of the terms is that opposing parties often use the terms incorrect as well. For example, one might tell me (which they do) “alien life forms do not exist”. At this point I can, rightfully so, dispute them by asking for the evidence that they do not exist. As they probably don’t have such proof to back these claims (at least I haven’t seen it yet), they are ‘theories’ and I can call them out on it.

To summarize, not having proof for some theory is NOT proof that the theory might not actually be the truth. There is also nothing wrong in believing something for yourself so strongly that you might consider it to be the truth, but that does NOT mean you can state it to be true.

In the end, using the right terminology can make a discussion much more fun as there will not be any miscommunication and the discussion can be kept on-topic.

## November192010

### When not to use mocking/stubbing?

When you are testing a method like the following contrived example:

  def make_pony_eyes_pink
before, Pony.eye_color = Pony.eye_color, :pink
yield
ensure
Pony.eye_color = before
end


Don’t do it with expectations such as these:

  it "changes the eye color to pink for the duration of the block" do
Pony.expects(:eye_color=).with(:pink)
pony.make_pony_eyes_pink {}
Pony.eye_color.should.be :black
end


Your expectation would still succeed if the implementation of the method would change to reset the eye color before yielding the block:

  def make_pony_eyes_pink
before, Pony.eye_color = Pony.eye_color, :pink
Pony.eye_color = before
yield
end


Therefore, check that what you describe is actually what you get:

  it "changes the eye color to pink for the duration of the block" do
eye_color_during_block = nil
pony.make_pony_eyes_pink do
eye_color_during_block = Pony.eye_color
end
eye_color_during_block.should.be :pink
Pony.eye_color.should.be :black
end


Astute readers will note that I do not make the assertion inside the block, because that would mean the assertion could potentially *not* run without making the test fail.
I should patent bad ideas so no-one can ever come up with one again.
— me
Lost in UI poetry 1.
In a Objective-C application which uses garbage collection, like a MacRuby app, any objects instantiated in a NIB will get collected as well. Unless you keep a ‘strong’ reference to them from an object reachable from a ‘root’ object, such as NSApplication.sharedApplication (NSApp).

As I normally make my AppController instance the NSApp's delegate (‘strong’ reference) right from the start, I didn't notice this and it kept me busy for a good hour.
Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.