Naming suggestions
Posted: Sat Aug 19, 2006 6:59 pm
Ok, I have an class which has the following methods:
Firstly this is just a mockup, the actual implemention is in Javascript...
getInstance($id); is a factory method which returns the appropriate type of object according to details given when that objects information was registered via registerContextData()
registerContextData($ctx); is called each time a new object is required to be built.
createAllInstances() is called automatically by the framework...
Now this is just a rough draft and may completely change, as I haven't worked out all the quirks of dealing with javascript and the DOM...
It's hard to explain fully what I am trying to do, so please read and understand the best you can before firing off suggestions...
The class itself is a singleton, acting much like a Windows process and getInstance() is a factory which (doesn't actually build but..) returns existing objects created when appropriate by the framework by calling createAllInstances()
To stick with the analogy getInstance() would be returning something of a thread...but the threads are not created by calling getInstance() but rather by registering a "context" structure (actually an object) with the framework calling registerContextData() and then later, when the framework determines the "threads" can be created, it actually creates the instances of the threads by calling createAllInstances()
This is not a proper design type question...as like I said it's still rough draft and is a improved version (at least the direction I'm heading) of the TinyMCE_Engine class
Yes I'm re-writing a WYSIWYG editor...
Likely make it open source...anyone else care to help???
Anyways, knowing all of the above...what kind of "name" would you give the class?
I can't decide, currently I have the following:
MyEditor_Interface - As it's a singleton, which provides an abstract base class (interface & implementation) for a subclass
I refer to an interface as a special kind of class which is intended to be derived from and cannot be instantiated, much like an ABC. However in this case, an interface would also provide some minimal implementation. Basically what I defined above...
It's an interface (contains the data members used in subclass) to a subclass, but also acts as a class in that it encapsulates instance functionality...
MyEditor_Instance as the interface/class also is the class responsible for handling a single editor instance. An editor will have sub-editors which are returned via the getInstance() factory method...
MyEditor_Engine The one I most dislike as it's already used and not very well modelled IMHO...
So...design opinions, naming opinions, etc...???
Interface or Instance? Has a subclass called MyEditor_Control currently, but I think that will soon change to something else very soon...
Cheers
Code: Select all
class Context{
function registerContextData($ctx);
function getInstance($id);
function createAllInstances();
}getInstance($id); is a factory method which returns the appropriate type of object according to details given when that objects information was registered via registerContextData()
registerContextData($ctx); is called each time a new object is required to be built.
createAllInstances() is called automatically by the framework...
Now this is just a rough draft and may completely change, as I haven't worked out all the quirks of dealing with javascript and the DOM...
It's hard to explain fully what I am trying to do, so please read and understand the best you can before firing off suggestions...
The class itself is a singleton, acting much like a Windows process and getInstance() is a factory which (doesn't actually build but..) returns existing objects created when appropriate by the framework by calling createAllInstances()
To stick with the analogy getInstance() would be returning something of a thread...but the threads are not created by calling getInstance() but rather by registering a "context" structure (actually an object) with the framework calling registerContextData() and then later, when the framework determines the "threads" can be created, it actually creates the instances of the threads by calling createAllInstances()
This is not a proper design type question...as like I said it's still rough draft and is a improved version (at least the direction I'm heading) of the TinyMCE_Engine class
Yes I'm re-writing a WYSIWYG editor...
Likely make it open source...anyone else care to help???
Anyways, knowing all of the above...what kind of "name" would you give the class?
I can't decide, currently I have the following:
MyEditor_Interface - As it's a singleton, which provides an abstract base class (interface & implementation) for a subclass
I refer to an interface as a special kind of class which is intended to be derived from and cannot be instantiated, much like an ABC. However in this case, an interface would also provide some minimal implementation. Basically what I defined above...
It's an interface (contains the data members used in subclass) to a subclass, but also acts as a class in that it encapsulates instance functionality...
MyEditor_Instance as the interface/class also is the class responsible for handling a single editor instance. An editor will have sub-editors which are returned via the getInstance() factory method...
MyEditor_Engine The one I most dislike as it's already used and not very well modelled IMHO...
So...design opinions, naming opinions, etc...???
Interface or Instance? Has a subclass called MyEditor_Control currently, but I think that will soon change to something else very soon...
Cheers