Jump to content

Rike

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Rike

  1. Hallo, it's not easy to write short code, because full version of Controller is very complex (DI), but I try: abstract class Controller { // Template method public final function control(...) { try { $this->before(); $this->process(); return $this->after(); } catch ... } protected function before(...) { // here is code to execute before processing of controller // should throw many exceptions (rights etc.) } protected function process(...) { // body of controller } protected function after(...) { // typically return views data... } } Method Controller::before() throws exceptions on a number of counts, but I am looking for clean way how to throw "silent exception", because controller should be called as "service" and in this case I do not need error message (you are not logged in...) but only stop processing and return context to other controller in queue. Yes, it's easy to define some SilentException extends \Exception, but this I feel a little bit dirty.
  2. As written in title, I use Template method pattern. Template method calls other overloaded methods with particular implementation, but how to solve situation, when this method need to break whole algorithm? Yes, throw exception, that should be the way, but not every interruption is really exception. Is this a mistake in design, or there is any way to implement interruption of template method?
  3. Thank you, nested sets looks very good for me And what about ratings and optimal db solution? For example: post_id, user_id table looks to be very big.
  4. Hallo everybody! I am looking for some information about creating PHP threaded forum (with MySQL). BB forum is easy - db table with forums, topics and posts, every post has foreign key to topic, topic to forum and it's done. But if I want something like Disqus, how to do this more efficiently? How to collect posts in db with minimum query needed to render any thread? And what about post rating? How to prevent user from sending more then one rating?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.