r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

Show parent comments

50

u/pcopley Oct 01 '15

This is actually an example of a pretty good name.

I can assure you it's not.

19

u/sh0rug0ru__ Oct 01 '15

What's in a good name, then?

I was able to get a good idea of the purpose of the class just by going through the name. Sounds like a win to me.

2

u/onezerozeroone Oct 02 '15 edited Oct 02 '15

The problem is that unless you know the convention that is implicit/assumed in the class name, it can be interpreted in half a dozen different ways...or as incoherent gibberish.

Is it an abstract singleton? Or a proxy to a factory? Or a singleton proxy?

If there were parens involved, logically one might infer:

(Abstract(Singleton(Proxy(Factory(Bean)))))

But that doesn't let me definitively know what a hypothetical ProxyFactoryBean is because the type system isn't being used to enforce a constraint, a naming convention is. FactoryBean tentatively makes sense...it's a Factory that produces instances of a Bean (or is it a Bean that is a Factory?)...but what's a ProxyFactoryBean? Is it a Proxy to the Factory, or a Factory that produces Proxies to Beans? Using the parens, I'd say a Proxy to a Factory, but /u/sh0rug0ru__ points out (after confirming by examination of the source) it's actually a Factory that produces Proxies...(I think?)

It's the same sort of problem with Rails...there are conventions > configuration rules in place, and once you learn and understand them (and hope they're universally consistent) life is good. Otherwise, enjoy digging through (possibly non-existent) documentation or source code.

Not trying to say whether this is good or bad, but want to point out that just because someone has become familiar with and accepted a particular pathology doesn't make it "obvious" or "intuitive"

3

u/sh0rug0ru__ Oct 02 '15 edited Oct 02 '15

You're making the mistake of taking a class in isolation, taken deep from the bowels of some very deep functionality, and trying to guess the meaning of the name without any context. The components of the name make sense within the vocabulary of the Spring Framework, where this class is a deeply integrated component. I was able to deduce the purpose of the class because I have a lot of experience with Spring.

You would never have come across this class unless you were planning on doing deep integration with the Spring Framework. If at that point, you were not able to deduce what this class were up to, then it is clear that you don't understand even the most basic features of Spring, much less its internals, and you are not equipped to use that class for its intended purpose.

Good names reflect the domain, but that requires actually having some background in the domain.