Adaptive Code via C#: Agile coding with design patterns and SOLID principles by Gary McLean Hall
Author:Gary McLean Hall [Hall, Gary McLean]
Language: eng
Format: epub, pdf
Published: 2014-09-16T19:58:06+00:00
private ICollection<IComponent> children;
}
// . . .
class Program
{
static void Main(string[] args)
{
var composite = new CompositeComponent();
composite.AddComponent(new Leaf());
composite.AddComponent(new Leaf());
composite.AddComponent(new Leaf());
component = composite;
component.Something();
ptg14200592
}
static IComponent component;
}
In the CompositeComponent class, there are methods for adding and removing other instances
of the IComponent. These methods do not form part of the interface and are for clients of the
Composite Component class, directly. Whichever factory method or class is tasked with creating
instances of the CompositeComponent class will also have to create the decorated instances and pass
them into the Add method; otherwise, the clients of the IComponent would have to change in order
to cope with compositions.
Whenever the Something method is cal ed by the IComponent clients, the list of composed in-
stances is enumerated, and their respective Something is cal ed. This is how you reroute the call to a
single instance of IComponent—of type CompositeComponent—to many other types.
Each instance that you supply to the CompositeComponent class must implement the IComponent
interface—and this is enforced by the compiler due to C#’s strong typing—but the instances need
not all be of the same concrete type. Because of the advantages of polymorphism, you can treat all
implementations of an interface as instances of that interface. In the example shown in Listing 5-15,
the CompositeComponent instances provided are of different types, further enhancing this pattern’s
utility.
Download
Adaptive Code via C#: Agile coding with design patterns and SOLID principles by Gary McLean Hall.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(26274)
Hello! Python by Anthony Briggs(25203)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(24432)
Kotlin in Action by Dmitry Jemerov(23523)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(22869)
Dependency Injection in .NET by Mark Seemann(22655)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21419)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20255)
Grails in Action by Glen Smith Peter Ledbrook(19331)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17045)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16356)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14070)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12244)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11519)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10635)
Hit Refresh by Satya Nadella(9209)
The Kubernetes Operator Framework Book by Michael Dame(8573)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8423)
Robo-Advisor with Python by Aki Ranin(8366)