Created
April 26, 2011 22:07
-
-
Save stephaneerard/943302 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hello Community, | |
| When considering writting large apps with sf2, with a back and a front, some questions are occuring, about how to structure things. | |
| Say we have one large website with a front-end for end-users and a back-end to feed the front-end, control objects, etc. | |
| The two "apps" will use same models, obviously. | |
| We'd like to separate our "views" on the models for the two apps (I call them "perspectives"). | |
| Let say we have a model named "Topic". | |
| On BackOffice, we'd like to speak about Topics using a TopicBO class, which will only have methods for backoffice problem solving. | |
| Same on FrontOffice, we'd speak to TopicFO instance. | |
| Let say TopicBO and TopicFO are two perspective objects for the Topic object. | |
| There are two problematics : | |
| How to structure the bundles, when we have more than 100 entities, when they have to be used between the two apps | |
| How to have such distincts *FO and *BO classes ? Inheritance or compositing(-wrapper) ? | |
| About question 1.: | |
| I'll try to dig somehow. | |
| Let say we have Customer, Topic & Space (a forum space) models. | |
| First try : | |
| One bundle for Core (the model in itself, with methods that could be used by both FO and BO) | |
| One bundle for FO | |
| One bundle for BO | |
| Leading us to having | |
| CustomerCoreBundle : class, metadata mapping | |
| CustomerFrontBundle : actions, templates, resources, wrapper for Front | |
| CustomerBackBundle : actions, templates, resources, wrapper for Back | |
| TopicCoreBundle : class, metadata mapping | |
| TopicFrontBundle : actions, templates, resources, wrapper for Front | |
| TopicBackBundle : actions, templates, resources, wrapper for Back | |
| SpaceCoreBundle : class, metadata mapping | |
| SpaceFrontBundle : actions, templates, resources, wrapper for Front | |
| SpaceBackBundle : actions, templates, resources, wrapper for Back | |
| This is great when we have many different actions, resources, templates to bundle within one of these bundles for specific app. | |
| Yet I'm pretty sure we can have one bundle for each object, and create directories within the bundle to have a separation between front & back stuffs. | |
| Not talking about dependencies here (how the hell hard would it be ? If it even would be hard to manage ?) | |
| We'd get a FrontBundle which would require somehow (is it even possible) all bundles for the Front, and same thing for the Back. | |
| Second | |
| One bundle "rule them all" (bundling core model, metadata, FO & BO inheritance/compositing objects, resources, actions, etc) | |
| CustomerBundle : class, metadata, actions, templates, resources, wrapper for Front & Back | |
| TopicBundle : class, metadata, actions, templates, resources, wrapper for Front & Back | |
| SpaceBundle : class, metadata, actions, templates, resources, wrapper for Front & Back | |
| How "easy" would it be to have a separation (with the mean of directory structure I guess) between Front & Back stuff ? | |
| I guess here dependencies are a lot easier to manage | |
| About question 2.: | |
| The goal is to have a class with methods specific to the application at hand. So it is easier to write and maintain (I guess). | |
| *FO classes will have methods only used for Front app. | |
| *BO classes will have methods only used for Back app. | |
| Would we go by inheriting or by wrapping them ? | |
| Inheritance: | |
| Class BaseCustomer | |
| Class CustomerFO extends BaseCustomer | |
| Class CustomerBO extends BaseCustomer | |
| (I don't go using aliases and namespaces here, KISS for the example) | |
| When methods are needed on both side, put them in BaseCustomer | |
| Compositing: | |
| Class Customer | |
| Class CustomerFO which "wraps" a Customer instance | |
| Class Customer BO which "wraps" a Customer instance | |
| When methods are needed on both side, we create proxy methods on both wrappers & implement them in the Customer (no __call() + docblocks) | |
| By writting it down, I see it's easier to inherit. Anyway, what are your feelings/experiences about such problem ? | |
| Thank you for reading and your time ! | |
| Regards, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment