Skip to main content

Posts

Showing posts from February, 2018

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/ { &qu

Git rebase 2

I think you should have mention that NEVER REBASE PUBLISHED HISTORY! Interactive Rebase is only a tool to format your local snapshots to more cohesive units before publishing it with push. This is because Rebase replaces commits with new ones with different ID's, and somebody may have and probably has continued his work from the old commits. This will mess the history and create redundant merge commits to confuse people. However, typically git wont't let you push rebased published commits without --force flag. VD Rebase 1 branch vd feature_01 (đã push hay chưa ?). Rebase xong có cần push lên ? Nếu có có cần --force ? Rebase mặc định có hiểu rebase sang branch nào ? hay về branch cha lúc rẽ nhánh ? Sang master check hist commit log => đã thấy rebase gộp commit lại, ko cần làm j bên master ? (magic).

PHP plugin architecture

https://stackoverflow.com/questions/10053479/a-php-plugin-architecture https://roots.io/routing-wp-requests/ https://stackoverflow.com/questions/42/best-way-to-allow-plugins-for-a-php-application Foundation for create Object Oriented Framework http://agile-core.readthedocs.io/en/develop/hook.html http://agile-core.readthedocs.io/en/develop/index.html UPDATE : answer now reflects the up-to-date links and better description. There are certainly many different ways to design a plugin system and perhaps asking on  https://softwareengineering.stackexchange.com/  would give you more ideas, but I'll try to help by sharing my ideas and experience. I'll share some of my own experiences which I've learned through a series of my own frameworks. Currently  Agile UI  and  Agile Data  both support many wasy to be extended, but I'll focus on the "Components" HOOKS When you look to inject code into the existing object, a hook is a standard way to go. It'