← Back to context

Comment by aazaa

5 years ago

> First, the class name, SetupTeardownIncluder, is dreadful. It is, at least, a noun phrase, as all class names should be. But it's a nouned verb phrase, the strangled kind of class name you invariably get when you're working in strictly object-oriented code, where everything has to be a class, but sometimes the thing you really need is just one simple gosh-danged function.

Moving from Java as my only language to JavaScript and Rust, this point was driven home in spades. A programming language can be dysfunctional, causing its users to implement harmful practices.

SetupDeardownIncluder is a good example of the kind of code you get when there are no free-standing functions. It's also one path on the slippery slope to FactoryFactoryManager code.

The main problem is that the intent of the code isn't even clear. Compare it with something you might write in Rust:

    fn render(page_data: &PageData) -> String {
        // render the page
    }

If you saw that function at the top line of file, or if you saw render.rs in a directory listing, you'd have a pretty good idea of what's going on before you even dug into the code.

Just randomly searching the Fitness repo, there's this:

    // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
    // Released under the terms of the GNU General Public License version 2 or later.
    package fitnesse.html;

    public class HtmlPageFactory
    {
 public HtmlPage newPage()
 {
  return new HtmlPage();
 }

 public String toString()
 {
  return getClass().getName();
 }
    }

https://github.com/unclebob/fitnesse/blob/3bec390e6f8e9e3411...

Really, how does this file even justify its existence? Its a subsidy courtesy of language design decisions made a long time ago.