Difference between CallBack and Listener and Observer as Design Pattern

cocoamaemae
1 min readSep 19, 2019

--

  • CallBack

Brief

After the specific processing ends, registered callback object is called.

E.g.

In advance, pass phone number to callback object.

After active processing like ‘Taking photo’ ends, notify callback object and execute methods.

  • Listener

Brief

When the specific events occurred, registered listener objects are called.

E.g.

In advance, listers are registered by an object which controls passive processing.

After passive processing like ‘Touch screen’ is executed, notify registered listeners and execute specific methods.

  • Observer

Brief

When the specific states were changed, registered observer objects are called. Mostly same as lister pattern.

E.g.

After battery charge remaining is less, notify registered observers and execute specific methods..

The difference between callback and listener is that events when they are called are active or passive.

Reference

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

cocoamaemae
cocoamaemae

No responses yet

Write a response