Design Pattern - Callback [closed]

这一生的挚爱 提交于 2020-01-01 06:53:06

问题


I have to do a presentation of the callback pattern. I just want to be sure that I got it right because of what I read about callbacks, callback functions and callback pattern...

The design pattern callback is very similar to the observer pattern.


The first one is easier to implement but will probably mess with an MVC implementation. You have to call specific functions or methods to make the callback. There's no specific class diagramm.

http://soapatterns.org/design_patterns/service_callback

http://searchdaily.net/callback-pattern-with-rmi-client-callback/#more-2009


The second is made for MVC, have a specific class diagramm, etc. (I can look on wikipedia if I need)


So my questions are :

Is what I wrote right ?

Are my 2 links correct (speaking of the pattern callback) ?

Do we agree that callback pattern and function are 2 completely different things ?


回答1:


I don't see a difference between a callback and a callback function.

The difference between a callback function and a callback pattern, however, is that the function is the piece of logic that actually gets executed and the pattern is the design of the code that makes the execution happen.

callback function - SO link callback pattern - SO link.




回答2:


So there's no such thing as a Callback pattern. There's callback functions and a callback mechanism (used in the observer pattern).

Here are the links I used. If you want the presentation just ask ;) (Sorry I had to remove http because I don't have enough reputation to add more than 2 links)

Callback Pattern » Searchdaily | Searchdaily.
http://searchdaily.net/tag/callback-pattern/

SOAPatterns.org | Design Patterns | Service Callback. http://soapatterns.org/design_patterns/service_callback

oop - Observer pattern or Callback? - Stack Overflow.
stackoverflow.com/questions/4583269/observer-pattern-or-callback

Callback (computer programming) - Wikipedia, the free encyclopedia. en.wikipedia.org/wiki/Callback_%28computer_science%29

RoR Guide & Solutions: Difference between Validations, Callbacks and Observers. rorguide.blogspot.ch/2011/07/difference-between-validations.html

Software design pattern - Wikipedia, the free encyclopedia. en.wikipedia.org/wiki/Software_design_pattern

Design Patterns - Wikipedia, the free encyclopedia.
en.wikipedia.org/wiki/Design_Patterns_%28book%29

oop - Is there a design pattern that deals with callback mechanism? - Stack Overflow. stackoverflow.com/questions/946834/is-there-a-design-pattern-that-deals-with-callback-mechanism




回答3:


A good pattern description is the Service Callback design pattern. It's part of a catalog of SOA patterns, but the pattern can be used even if you're using generic components instead of SOA services.

The Observer pattern is similar to the publish-subscribe pattern, not callback.

Design patterns can be illustrated with class diagrams when they specify methods and inheritance. Patterns like Service Callback can be illustrated with generic component boxes because they focus on the component interaction.



来源:https://stackoverflow.com/questions/16917088/design-pattern-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!