Chicken or Egg
Posted on 2007-04-05 00:21:44 EEST.
As soon I as added midgard_config methods to create midgard tables I wanted to create new midgard_sitegroup.
( Midgard Sitegroup concept is well known but I still think I should write new mRFC. Especially now, when this class ( and simple&powerfull feature ) has new advantages. )
What should be done to create new sitegruop? Some simple method which just creates some record in database. OK, piece of cake, but to make this you need to know if logged in person is root. Hmmm... how can I check if logged in person is root if I have no such feature in core? That's clear, user accounts management should be written first. Simple...but wait. How am I to create user account in sitegroup scope if I have no sitegroup management?
It's not fun. Far from it. Writing two functionalities at the same time is not fun. To test them, you also need some simple environment. So writing two different functionalities and writing PHP bindings for them is far far from being fun.
Less fun is even if you think "it would be cool to reuse MidgardQueryBuilder for those classes". Not because one ( me for example ) may be lazy. But because the less duplicated ( or similiar code ) the less bugs should be resolved in a future. So, how can I use not MgdSchema classes with MidgardQueryBuilder if this one is highly optimized for them?
This question forced me to blessed refactoring. Review, tweak, tune, refactor, test, fix memory corruption and get the same with "new soul". And at the end MidgardDBObject class has been born from the will of having new midgard_sitegroup.
So now, class inheritance looks like this:
- GObject
- MidgardDBObject
- MidgardObject
- Any MgdSchema class
or
- GObject
- MidgardDBObject
- MidgardSitegroup
This change brings more power, so now I am even able to reflect or introspect MidgardSitegroup class object and check if such class is multilang one. I do not have to hardcode it's table or property's column name everywhere. For such features I can use introspection. Now I can say: plain and simple :)
You should stay ( still ) tuned to learn more about "how to create new sitegroup and new user accounts". But probably I will add API documentation instead of blog entry. And as I said, new mRFC will be also nice. Not for voting, but for keeping specification and idea in one place.
In other news: Bergie in his blog mentioned 'offline vs online debate'. Yes, offline is wasting the time feature if you keep in mind services like GMail or any "typical" PHP based CMS. But what about CMS or framework which has independent logic library? One which is not aware if you work offline or online? Something like Midgard :) All you need to do is to focus on GUI. I think it's worth time and work and very good to have. All in all we can also start debate: do I need battery in my laptop or in any other mobile device if electricity is almost everywhere?