News for hackers. Stuff that matters.
Re:Why you should never ever ever have Managers in your clas... by cpeterso on Sunday March 31, 2013 @08:44PM (#5470840)
The class name modifier that irks me is "Base", as in BaseWidget or ConnectionBase. Just call them a Widget or Connection! :)
Re:Why you should never ever ever have Managers in your clas... by yen223 on Sunday March 31, 2013 @09:57PM (#5471038)
BaseWidget is useful when it's an abstract class, to differentiate it from the actual implementations WidgetA and WidgetB.
Re:Why you should never ever ever have Managers in your clas... by cpeterso on Sunday March 31, 2013 @10:07PM (#5471068)
Wouldn't a "Widget" abstract class name also be differentiated from "WidgetA" and "WidgetB" implementations? Then APIs could take parameters of type Widget instead of type BaseWidget. "Widget" is a shorter, cleaner name and avoids documenting implementation details like names such as "BaseWidget" or "AbstractWidget".
Re:Why you should never ever ever have Managers in your clas... by dack on Monday April 01, 2013 @09:11AM (#5472778)
Usually, I want to make the name of my interface the cleanest possible name. In that case, my interface would be named "Widget". Then, if it makes sense, I might have a partial implementation that works for many cases - I would probably call that WidgetBase. Actual implementations of the widget would try to have a name related to what makes them different than the others - maybe Button, TextBox, etc. Those implementations might inherit from WidgetBase if it makes sense, or just implement the interface. At any rate, WidgetBase is only ever referenced by subclasses - the users of the widget code would either depend on "Button" or "TextBox" specficially, or the "Widget" interface for more generic handling. WidgetBase is really just there for convenience, and you could remove it if it turns out not to be as useful as you thought.
Re:Why you should never ever ever have Managers in your clas... by cpeterso on Monday April 01, 2013 @04:19PM (#5475622)
Java frameworks use a similar pattern with a "Widget" interface and an "AbstractWidget" partial implementation.
Re:Why you should never ever ever have Managers in your clas... by sha90 on Sunday March 31, 2013 @10:58PM (#5471203)
There are certain ... linguistic... reasons why Base appears in class names. It's important to understand the subtlety. In certain languages, especially those with packages or namespaces, you'll likely have a namespace Foo::Bar::Widgets where you put your WhateverWidgetWhatever classes. The package foo.bar.widgets.widget, or namespace Foo::Bar::Widgets::Widget, can look weird to some; it's also longer / less predictable, so you could potentially see them simply be called Foo::Bar::Widget::Base, which avoids naming duplication, and allows developers to not have to worry about plural/singular names.