Posted on: 2010/9/1 22:11
Re: Making a module clonable?
I am not working on any current modules that this would come into play but I am asking so I better understand the concept so I am able to better program modules with this in mind.
I was actually looking more for "renamable" then a true clone. I miss said what I meant but you pretty much answered the question nonetheless... (if its clonable it is also renamable)
If I am understanding what you are saying is that you build the structure of the module in a manner that makes it easy to change the code so it will work no mater the name of the module or directory. Then you make install scripts that modify the code during the install to make it work correctly as intended. (Or you can manually change the code with a program such as notepad++ and just do a simple find replace.)
Guessing at this point you couldn't just make a file like the language constructs where it has constants that you then use in your code. Then if you want to clone the module you just have to change this "constants" file to make things work right.
I did not consider the classes and functions but I can see where they might clash if you have multiple functions/classes of the same name loaded up. And I am guessing if you use something like "#include once" that wouldn't fix it either since they physically would be separate files.
Sounds like for me to save in duplicate code it would be best to have a main module be "renamable" and have "daughter" modules that would work like the cloning. The "daughter" modules would be clonable but require the main module to be loaded to operate. Thus the "daughter" module would be quite lite and only require the things that make it work separately. Instead of having 2 or more copies of the same module and copies of the same code.
Although in this method if you remove the main module you would have to have a way to preserve the "daughter" module. Duplicating all the code of course would make any of the modules work regardless of which is removed or added.
Hope that all made sense.. Just want to understand the concepts before I go diving into anything.