Skip to content

bogdanorzea/dart-head-first-design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Head First Design Patterns adapted for Dart

I've adapted the Java examples from the Head First Design Patterns book to Dart.

Setup

dart pub get

Patterns

Strategy pattern

Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

dart run bin/strategy_pattern.dart

Observer pattern

Defines a one-to-many dependency between objects so that when an object changes state, all it's dependents are notified and updated automatically.

dart run bin/observer_pattern.dart

Decorator pattern

Attach additional responsibilities to an object dynamically. Decorator provides a flexible alternative to sub-classing for extending functionality.

dart run bin/decorator_pattern.dart

Factory pattern

The Factory Method pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method pattern lets a class defer instantiation to subclasses.

The Abstract Factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.

dart run bin/factory_pattern.dart

Singleton pattern

The Singleton pattern ensures a class has only an instance and provides a global point of access to it.

dart run bin/singleton_pattern.dart

Command pattern

Encapsulates a request as an object, thereby letting you parametrize clients with different requests, queue or log request, and support undo-able operations.

dart run bin/command_pattern.dart

Adapter pattern

Converts the interface of a class into another interface the client expects. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

dart run bin/adapter_pattern.dart

Facade pattern

Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-lever interface that makes the subsystem easier to use.

dart run bin/facade_pattern.dart

Template Method pattern

Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

dart run bin/template_method_pattern.dart

Iterator pattern

Provides a way to access elements of aggregate object sequentially without exposing it's underlying representation.

dart run bin/iterator_pattern.dart

Composite pattern

Allows to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

dart run bin/composite_pattern.dart

State pattern

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class

dart run bin/state_pattern.dart

Proxy pattern

Provides a surrogate or placeholder for another object to control access to it.

dart run bin/proxy_pattern_machine.dart 4040
dart run bin/proxy_pattern_machine.dart 4041
dart run bin/proxy_pattern_monitor.dart

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages