Programming	workshop Software	Design	Patterns Structural
Java / Android -- Intellij IDEA Python -- PyCharm C / C++ -- Clion Obj. C / Swift -- App Code C# -- ReSharper / Rider Php -- PhpStorm Ruby -- RubyMine Javascript -- WebStorm DBA -- DataGrip JetBrains student	program jetbrains.com/student
• Install	“Learn”	plugin	(link) • Complete	the	course	(~15	minutes) • Answer	the	survey	(link) • PROFIT!!! Get	a	chance	to	win	$50 Amazon	Vaucher from	JetBrains
Design	Patterns	Explained	Simply https://sourcemaking.com/design-patterns-book Content	in	this	presentation	in	partial	is	taken	from “Designed	Patterns	Explained	Simply”	book.
Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems and improves code readability for coders and architects familiar with the patterns.
Design	Patterns 1.Creational 2.Structural 3.Behavioural
Design	Patterns 1.Creational 2.Structural 3.Behavioural
Structural	Design	Patterns In Software Engineering, Structural Design Patterns are Design Patterns that ease the design by identifying a simple way to realize relationships between entities.
Structural	Design	Patterns • Adapter • Bridge • Composite • Decorator • Facade • Flyweight • Proxy
Structural	Design	Patterns • Adapter • Bridge • Composite • Decorator • Facade • Flyweight • Proxy
Adapter
Adapter Problem A component offers compelling functionality that you would like to reuse, but its "view of the world" is not compatible with the philosophy and architecture of the system currently being developed.
Adapter Intent • Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. • Wrap an existing class with a new interface.
Adapter
Adapter Check list 1.Identify the players: the component(s) that want to be accommodated (i.e. the client), and the component that needs to adapt (i.e. the adaptee). 2.Identify the interface that the client requires. 3.Design a "wrapper" class that can match the adaptee to the client. 4.The adapter/wrapper class "has a" instance of the adaptee class. 5.The adapter/wrapper class "maps" the client interface to the adaptee interface.
Adapter Rules of thumb • Adapter makes things work after they're designed • Adapter is retrofitted to make unrelated classes work together. • Adapter provides a different interface to its subject. • Adapter is meant to change the interface of an existing object. • Adapter reuses an old interface. Remember that Adapter makes two existing interfaces work together as opposed to defining an entirely new one.
Composite
Composite Problem Application needs to manipulate a hierarchical collection of "primitive" and "composite" objects. Processing of a primitive object is handled one way, and processing of a composite object is handled differently. Having to query the "type" of each object before attempting to process it is not desirable.
Composite Intent • Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. • Recursive composition when directories contain entries, each of which could be a directory
Composite
Composite Check list 1. Ensure that your problem is about representing "whole-part" hierarchical relationships. 2. Consider the heuristic, "Containers that contain containees, each of which could be a container.” Divide your domain concepts into container classes, and containee classes. 3. Create a "lowest common denominator" interface that makes your containers and containees interchangeable. 4. All container and containee classes declare an "is a" relationship to the interface. 5. Child management methods [e.g. addChild(), removeChild()] should normally be defined in the Composite class.
Composite Rules of thumb • Composite is usually traversed with Iterator. • Composite can let you compose a Mediator out of smaller pieces through recursive composition. • Composite's focus is not on embellishment but on representation.
Bridge
Bridge Problem "Hardening of the software arteries" has occurred by using subclassing of an abstract base class to provide alternative implementations. This locks in compile-time binding between interface and implementation. The abstraction and implementation cannot be independently extended or composed.
Bridge Intent • Decouple an abstraction from its implementation so that the two can vary independently. • Publish interface in an inheritance hierarchy, and bury implementation in its own inheritance hierarchy. • Beyond encapsulation, to insulation
Bridge
Bridge
Bridge Use when • you	want	run-time	binding	of	the	implementation • you	have	a	proliferation	of	classes	resulting	from	a	coupled	interface	and numerous	implementations • you	want	to	share	an	implementation	among	multiple	objects • you	need	to	map	orthogonal	class	hierarchies
Bridge Check list 1. Decide if two orthogonal dimensions exist in the domain. 2. Design the separation of concerns: what does the client want, and what do the platforms provide. 3. Design a platform-oriented interface that is minimal, necessary, and sufficient. Its goal is to decouple the abstraction from the platform. 4. Define a derived class of that interface for each platform. 5. Create the abstraction base class that "has a" platform object and delegates the platform-oriented functionality to it.
Bridge Rules of thumb • Bridge is designed up-front to let the abstraction and the implementation vary independently. Adapter is retrofitted to make unrelated classes work together. • Adapter	makes	things	work	after	they're	designed;	Bridge	makes	them	work	before they	are.
Next	meeting	of	JetBrains GWU February	25th,	2016 SEH	2000;	5:00	– 7:00	pm “Software	design	patterns	II (behavioural)” Facebook https://www.facebook.com/groups/jetbrains.gwu/ Email jetbrains.gwu@gmail.com aganezov@gwu.edu

Software Design Patterns. Part I :: Structural Patterns