Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Wed Dec 08, 2004 5:16 pm Post subject:
This is an addon on to sonora. It inherits from Sonora::InterfaceManager so all of its methods are available. It then adds a single method createInterface. This will create and add an interface. It also returns the interface object back so that you can do anything special needed with handlers etc per interface.
The reason I wanted this was so that I can load my configuration straight out of a file (XML for me!) and have it automaticaly include the needed modules and create the interfaces.
So without further ado the before and after example.
Now remember this isn't realy a lot of use if you are hand coding the connections anyway. When i'm hand coding them I just use the regular InterfaceManager object. Now that I would like to have a config file though, this adds just another layer of ease.
Let me know what you think.
To install: Goto where you installed sonora at. Along side the Interface folder add a "InterfaceManager" folder. Then save this file inside that directory. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
It may be better to, instead of making lots of addon modules, work together to add it all into the main module, with options to use it or not. Just an idea. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
And have the factory add the code straight into the manager. Then you could install as many *features* as you want, if they all play nice that way. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
It's tempting to want to lump everything together into one module, especially when the add-on is only 20 lines of code, like the Factory. But you don't want to program things that way just for the sake of making it easy. Conceptually and practically, it makes sense to keep the Manager code separate from the Factory code. The Manager manages a group of interfaces, while the Factory produces interfaces - they are separate and distinct functionality.
It's possible that future Interfaces will not be in the Sonora::Interface hierarchy, so putting this one function in the Manager is limiting. Similarly, I expect the Factory module to grow and include code that lets you build Interfaces from XML files, from text files, from database records and other structures.
One of the major tenets of Object Oriented programming is to create clearly defined classes. If I combined these two classes now, I can almost guarantee I'd be pulling the Factory out of the Manager a few months down the line.
Ultimately, I see the code changing to work like this: