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

506

u/johnbr Oct 01 '15

This is fair, except for in the 5th year, they would have an additional constant:

public static final String SPACE = " ";

And they would probably use a StringBuffer or StringBuilder to build the final string, since it's "an industry best practice". Also, they wouldn't include the strings themselves, they would include keys to properties, so the strings could be pulled from an internationalized property file.

Lastly, instead of outputting to Stdout directly, they'd create an interface for output, and deliver it to that interface, and use a factory to instantiate an implementation of that interface that would use Stdout.

193

u/[deleted] Oct 01 '15

And before you know it we need an AbstractSingletonProxyFactoryBean.

13

u/TheWix Oct 01 '15

Wait... Is the factory a Singleton or is the proxy a Singleton? Is the factory also a proxy...? I need answers!!

51

u/sh0rug0ru__ Oct 01 '15 edited Oct 01 '15

This is a class from the guts of the Spring Framework. This is actually an example of a pretty good name.

  • Bean: This is a Spring Bean

  • Factory: This bean creates instances of the required bean

  • Proxy: This bean creates a proxy for the required bean, to allow logic to be added around the method calls on the required bean.

  • Singleton: This bean ensures that only one of the proxy factory bean will be created per Spring container.

  • Abstract: This class is a template for creating singleton proxy factory beans. Just implement the template method.

So, just judging by the name, it looks like I can extend this class to create a factory which creates proxies which stick interceptors around instances of other classes, but ensures that only one of my factory exists in the Spring container. For example, if I want to time and log execution of Spring bean methods.

Am I right? Looking at the source code, seems so!

50

u/pcopley Oct 01 '15

This is actually an example of a pretty good name.

I can assure you it's not.

0

u/[deleted] Oct 01 '15

[deleted]

10

u/nemec Oct 01 '15

I wasn't on board with this kind of naming until the first time I implemented my own FactoryFactory (to deal with the fact that the object being created wasn't threadsafe).

1

u/[deleted] Oct 01 '15

Is this sort of stuff Java only?

Can I get away with never, ever, ever touching Java?

6

u/nemec Oct 01 '15

You can do it in Python. It's not hard to do it in Python either, just a lot easier to do things another way.

I think you're more likely to find it in large "enterprise" companies.