Intermodule functions

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
100rk

Intermodule functions

Post by 100rk »

Hi Wishy,
with new module API it seems like there is no any obligation to register intermodule function, we only have to call 'GetModuleInstance()' function which returns an instance of any installed && active module and all methods of this module are accesible from now. But - why You don't use passing by refererence? (I am talking about function 'GetModuleInstance()' from /lib/classes/class.module.inc.php) Is it a feature? In this case I can have many independent instances of one module object in one time, and it may be unwanted situation if i want to change any data or 'state' of module object - this change will be not projected to other instances...
Am I correct, or did I miss something?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Intermodule functions

Post by Ted »

To be perfectly honest, i didn't that far into it. I just assumed that situations where people would use the intramodule functions would be only need them passed normally. I don't think it would be a bad thing passing by reference, but because modules don't really keep state, I still can't think of a very good reason where it would help... maybe just because it would take less memory to pass by ref?
100rk

Intermodule functions

Post by 100rk »

wishy wrote:..., but because modules don't really keep state...
maybe just because it would take less memory to pass by ref?
Yes, memory optimization is one important argument, but not last. In case there is more then one module with dependency on other module, it will be more then 'useful' - one dependent module can change state of 'root' module and other dependent module can not get those changes in this time - it will be working with its own copy of module object... :) Passing instance of module by value seems like really bad idea to me... Or - is there any reason for passing by value instead of by reference? Just for example: I am still thinking about multiple language support and also about 'multi domain' operation CMSMS with default language for every domain - so I would like a truly object-oriented behavior of module objects (not for save amount of SQL queries only) - I mean keeping state of every object for its whole lifetime. CMSMS is nice product - and really great base for almost ANY extension - and passing module by value mean closed doors for enhanced truly object oriented modules. Other example: if i include module to page more then once and every time with different parameters, I need all occurences of module in one page to work with only one copy of required object - in this case 'root' module.
Excuse me for my impertinence ;-), but I recommend to You check passing all variables - lets go utilize all benefits from new API 8)
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Intermodule functions

Post by Ted »

Yeah, you make a lot of sense as to why pass-by-ref is more valuable. I think I'm going to update that now. Thanks.
100rk

Intermodule functions

Post by 100rk »

I'm glad to help, thanks for Your time :D
BTW, creating new instances (resp. copying existed into new variable) of db-connection of gCms object in all functions which needs db-connectivity is also unnecessary. I don't know how much memory is allocated for every AdoDB object, but CPU time wasted by this operation (creation copy of initialized complex object) is also important - not in case small website, I agree :wink: And another thing: what about file 'lib/module.functions.php'? Has it any purpose in version 0.9?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Intermodule functions

Post by Ted »

That's a good point. Maybe it would be a good idea to make GetConnection functions, along with some others for things like config and variables.

As for module.functions.php, it's only real purpose at the moment is to handle the rendering and smarty processing for moduleinterface.php. At some point, I'll probably get index.php and moduleinterface.php to use to the same rendering functions, but not before 0.9 comes out, that's for sure.
Post Reply

Return to “Developers Discussion”