How should I name a "re-usable" object?
I'm at the beginning stages of a new web application, and I need to create two classes. One class is a "widget" that a user configures according to their specifications - let's say "height", "width", "color", etc.. The other object is a "pre-configured" "widget"开发者_如何学编程 that has the "height", "width", "color" preset, and they can't be changed by the user. If the user selects one of these "pre-configured" "widgets", they can only set a few other options. So I'm thinking both of these objects should extend a base class, since they will share several properties and methods. But, I really want to name all three of these classes properly. Here's some ideas I have, that all look horrible to me. Please help me out.
Base Class: "Widget"
Pre-configured: "WidgetPreset"
User-configured: "WidgetUserSet"
Base Class: "WidgetBase"
Pre-configured: "PresetWidget"
User-configured: "UserWidget"
Base Class: "Widget"
Pre-configured: "WidgetPreconfigured"
User-configured: "WidgetUserConfigured"
I've been doing OOP for a while now, and I've come up with some good naming conventions in the past, but I'm just drawing a blank on this one.
How about this..
Base Class: "AbstractWidget" - Abstract because it do not define the properties by itself.. and by defining it Abstract you want the implementing class to configure it properly.. though I am just talking about the name.. to make it real abstract, you got to use language construct to make it an abstract class.
Pre-configured: "PresetWidget" - I liked this word preset.. IMHO you should use this one as it makes perfect sense.
User-configured: I guess it depends what widget user is creating.. it could be anything followed by Widget in the name.. like if its a weather widget it could be named as "WeatherWidget" or another example "ClockWidget", "CalendarWidget" and so on..
I hope it helps..
精彩评论