“But People Never Check Return Values!”

The interface of a function, method or procedure, is composed of a number of inputs and output channels, and it is important to choose the correct type of channel to guarantee the function’s contract is being met by callers.

input channels can be roughly classified as follows:

  1. A set of values it explicitly receives through arguments
  2. The state of the object or application at the time it is invoked

and outputs:

  1. Explicit return values (including, for languages that support that, “out parameters”)
  2. Possibly some exceptions
  3. A new state of the object or application after returning
  4. A new state of the parameters

Continue reading ““But People Never Check Return Values!””

Can we Have Zen WET Code?

The DRY Principle says you Don’t Repeat Yourself when writing code. Encoding the same knowledge in two distinct locations means that if the information changes, we need to update both of them.

Failing to apply this principle leads to what is humorously called WET code. (“Write Everything Twice” or “We Enjoy Typing”, according to Wikipedia editors).

What does this mean in terms of zen levels?

Continue reading “Can we Have Zen WET Code?”