Skip to main content

Posts

Design Pattern, kiến trúc Wordpress so với Framework Front Controller, CMS vs Custom code, design concept, pattern concept ...

MVC là pattern về mặt ý tưởng là tách biệt M V C. Còn cài đặt như nào thì có Front Controller hoặc nhiều controller. MVC is a general pattern. The idea is to separate three aspects (Model, View and Control) of an application from each other. Now, this idea can be realized in different ways according to specifics of a situation/application. One way is to have many controllers, each responding to an action or a set of actions. Another way is to have one main controller which receives all actions and then dispatches them to different controllers, this one is called Front Controller Patter. So, Front Controller pattern is an MVC Pattern. For example, Spring Framework uses the Front Controller pattern to realize MVC. Method is actually a function used in the context of a class/object. When you create a function outside of a class/object, you can call it a function but when you create a function inside a class, you can call it a method. https://en.wikipedia.org/wiki/Front_controller ...

Eloquent append (tạo cột ảo), bảng quan hệ pivot, attach/detach

https://github.com/laravel/framework/issues/2619 https://laracasts.com/discuss/channels/eloquent/append-pivot-data-to-model?page=0 Eloquent $cast, $guarded pivot attach/detach Eloquent accessor trong relationship. ví dụ find()/ first()->username Ok I think I see now what is going on. Your Eloquent model is called subcategory, but so is the foreign key. So when you call $style->subcategory That is returning the foreign key instead of the model. To fix this, I'd recommend changing the name of the foreign key id to subcategory_id. If you can't change the database, you could force it to use the model by chaining the method with something like this $style->subcategory()->first()->name Edit: Another idea, you could change the name of the relationship to something like public function subcategory_item() {   return $this->belongsTo('Paragon\Products\Subcategory', 'subcategory'); } Then you ought to be able to properly reference it ...

WP event-listener system in PHP ...

https://stackoverflow.com/questions/6846118/event-driven-architecture-and-hooks-in-php @MoarCodePlz: This implementation lacks of events/hook contexts. You can for example encapsulate events into classes of it's own as well so they can be fired (interface them). This would add another layer however. Another useful function is is_callable in this context. https://stackoverflow.com/questions/15563005/observer-pattern-vs-mvc You are right in saying that MVC is more a architecture style rather than a design pattern good discussion here :  Is MVC a Design Pattern or Architectural pattern I hope this answers Your other two question too. Observer Design pattern is a Behavirol pattern which is used when we want to notify all of the dependents of an object(say x) in the event of change of the object x. Good read:  http://www.dofactory.com/Patterns/PatternObserver.aspx And they both are closely related, as MVC you would see from MVC diagram - for example: A Change in 'View...

Trello software and system design

https://stackoverflow.com/questions/10505431/how-does-trello-show-history-so-quickly?noredirect=1&lq=1 Trello stores all of the cards in one collection. The collection is sharded on the card's board id. https://stackoverflow.com/questions/12969344/how-does-trello-store-data-in-mongodb-collection-per-board I'm on the Trello team. We use an Actions collection in our MongoDB instance, with a compound index on the ids of the models to which it refers (a Card is a model, and so is a Member) and the date when the action was performed. No fancy caching or anything, except inasmuch as the index and recently used documents are kept in memory by the DB. Actions is by far our biggest collection. It is worth mentioning that most of the data needed to display an action is stored denormalized in the action document, so that speeds things up considerably. https://www.sitepoint.com/fullstack-javascript-trello-clone/ https://blog.fogcreek.com/the-trello-tech-stack/ { ...