ALTERNATE UNIVERSE DEV

CodingBlocks

Episode 19 – Design Patterns Part 3 – Iterators, Observers, and Chains, Oh My

We're back to the gang of four, continuing with another segment of design patterns. This time we're talking about some of our favorite Behavioral Design Patterns: Observer, Chain of Responsibilities, Iterator patterns. Also, why the visitor pattern is weird and what it's like to be raked over hot coals. News Atlanta Code Camp was amazing - $10 for all of this! AngularJS is HUGE, despite the recent controversy Ionic - Cross platform mobile development Bang Bang Javascript - Reddit will beat you up Codecademy - very cool way of learning new programming skills! The visitor pattern is wha,cray,wei@$@af--,what? The Observer Pattern Abstracts message senders and receivers from each other Watch out for memory leaks! Be careful with abstraction layer hopping and event overloading! Examples in .NET Events IObserver and IObservable Chain of Responsibilities Examples in .NET Exceptions - Sorta HTTP Handlers - Sorta MVC Routing - Sorta Decouples the sender from the receiver - allows more than one object a chance to handle it Differences between Chain of Responsibilities and Intercepting Filters Patterns Differences between Chain of Responsibilities and Observer Patterns Iterator Pattern Decouples algorithms from containers - good for data structures...but especially for sequences, algorithms When to use it: Sequentially traverse a collection Decouple the traversal logic/algorithm from the container Dealing w/ sequences - like weird enumerations! Fibonacci sequence Examples in .NET foreach (operates on IEnumerable types) LINQ yield keyword IEnumerable - aggregate/collection/container interface IEnumerator - iterator interface returned from IEnumerable Iterators tracks it's state internally, so beware of concurrency / parrallelization issues Resources we like Codecademy Gang of Four Book Design Patterns on Pluralsight Tips / Tricks Rextester Share code Snippets in the browser The Postman - Test REST in Chrome jsPerf - Performance testing for Javascript Thanks for listening!

Episode source