Other articles

  1. Refactoring: like a clean kitchen

    I once explained what refactoring was to a non-programmer. It went like this:

    “We software developers (programmers for short) do not only need to write a program that accomplishes a task. That’s the easy part. The difficult part is to change an existing program to adapt to new requirements / problems.

    read more
  2. Can Contracts replace Unit-Tests?


    What are “contracts”? Contracts are the key element in the design-by-contract technique, natively supported by the Eiffel programming language.

    They allow operate at many levels:

    1. methods: as pre- and post-conditions
    2. classes: as class invariants
    3. loops: as loop variants/invariants

    In this article we shall only consider method pre- and post-conditions. That means, before method execution the pre-condition is checked and after the method is finished (upon completion) the post-condition is checked.

    read more
  3. Scala Beginners: counting words and lines

    A simple command-line tool

    At work, I’m teaching one intern and one colleague how to program.

    I gave them the following exercise:

    Write an utility that takes 3 command-line parameters P1, P2 and P3. P3 is OPTIONAL (see below) P1 is always a file path/name. P2 can take the values:

    • “lines”
    • “words”
    • “find”

    Only P2 is “find”, then P3 is relevant/needed, otherwise it is not.

    So, the utility does the following:

    • If P2 is “rows” it says how many lines it has
    • If P2 is “words” it says how many words it has (the complete file)
    • If P2 is “find” it prints out the lines where P3 is present
    read more

Page 1 / 2 »