The best you can do is read the GoF book (yes, the one which is referenced on the very beginning of the Mr. Sierra's article).
And please feel free to post your opinion if you have different than I have. I just finished writing a diploma thesis on design patterns in Java 7, Scala and Clojure, so I can be a little biased, plus I have 6 years of commercial experience in writing C#, my employment in Java (or Clojure?) is yet to come. As Mr. Sierra stated on the beginning of the article, Norvig somewhat criticized the GoF book 1 and half year after it was publicized; that presentation is here: http://norvig.com/design-patterns/design-patterns.pdf. Observer pattern "defines a one-to-many dependency between objects so that *when one object changes state, all its dependants are notified and *updated" (the GoF book, page 293). So imagine that you have a data object, which is changed from one screen of your application (user updates data). Another screen gets notified about this change and updates itself so it shows updated data. But of course it's general, not only tied to UI ... but most common usage is updating UI on data change. In Clojure, you can use function *add-watch* or implement this behaviour yourself, much like in the book (GoF has sample code written in C++ and Smalltalk, no Java in 1994 :-) but there are many books which basically translated the patterns to another object oriented language, plenty of them to Java). I consider this book to be the "basics" for object oriented programmers, but Norvig had a good point that more expressive language makes a lot of the patterns invisible or they completely disappear. Even C# (basically a "Java with renamed namespaces, lower amount of libraries and some nice constructs which make the language more complex and often hides what should not be hidden" ;-) ) you can see that the Observer pattern is usually simplified (= less amount of boilerplate code) thanks to events which Java doesn't have. In Clojure I'd advise to try re-think the architecture if you think you need to use Observer before really implementing it (which however can be done without problems). Martin On Thursday, 7 May 2015 04:33:24 UTC+2, larry google groups wrote: > > I am looking here: > > > https://strange-loop-2012-notes.readthedocs.org/en/latest/monday/functional-design-patterns.html > > I read: > > Observer Pattern > <https://strange-loop-2012-notes.readthedocs.org/en/latest/monday/functional-design-patterns.html#observer-pattern> > > - Register an observer with a stateful function > > The observer could take the old and new state, along with either the > delta, the triggering event, or the container. > > *Can anyone point to something on Github that shows an example of this? * > > > > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
