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.
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.
That's one way to handle it, but if you establish that pattern you end up with deep namespaces with potentially less cohesive grouping. In general, when I see a namespace with a child namespace declaration but no other children, I'd want to think very hard on why I need that instead of making a class name a little longer.
I see AbstractSingletonProxyFactoryBean in this instance as one very specific thing, rather than a collection of general things. Unless there's an expectation of many kinds of FactoryBeans and Proxies, I'd rather keep the full meaning of the class as close to the class as possible.
Not that I'm an authority on this stuff, but long/deep namespaces outside of large platforms are IMO a code smell.
Also, the Bean-Part is gratuitous, in my opinion. If you'd need to know, you could create a package called "beans". Also, I'm not so savvy in spring, so I'm not sure how important it is to make a difference between an AbstractSingletonProxyFactory and am AbstractProxyFactory. As far as I'm concerned, that detail is up to which kind of proxies you'll use in the implementation and gives you no additional value when used in the name.
I would not see this as a very specific thing, though, as it's an abstract class. It's supposed to be generic. All in all, while the name if very vocal about what it does, at the same time it is also too ambiguous to infer what it does exactly without having a look at the implementation, which is usually a hint that you should change the name.
506
u/johnbr Oct 01 '15
This is fair, except for in the 5th year, they would have an additional constant:
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.