in reply to Re: Re: Testing for existence of subroutine ref?
in thread Testing for existence of subroutine ref?

It's often a symptom of poorly organized code if you have to check explicitly what something is in order to determine what to do with it. Ideally you'd want the structure of your code to shape the flow of data/entities such that at any given point you can reliably expect a certain type of thing.

Imagine walking around with a single instruction "doIt" along with a collection of minor instructions that you had to follow according to what the thingy was to which you were to "doIt". You don't want to have to decide to "drink" from a coffee cup and "drive" a car; rather, you want to be able to rely on the thing you attempt to drink from being a coffee cup, and the thing you hotwire being a car.

Another way of thinking about it is that it's better to offload decision-making onto the surrounding structure as opposed to navigating an open-ended environment according to a complex rulebook.


"The dead do not recognize context" -- Kai, Lexx
  • Comment on Re: Re: Re: Testing for existence of subroutine ref?