Bonus

Created:12/4/2013 9:44 AM
Updated:12/4/2013 11:00 AM

Table Of Contents  |  <<Previous | Next>>

Now we've vastly improved ACME's codebase in terms of testability, adherence to good design principles, and integrability.  AcquiCorp. is happy with what they see, and everything seems a go for a merger.

But we've caught the improvement bug.  Are there any more improvements we can make to our codebase?  (Hint: there are always improvements that can be made to a codebase.)  I have one in mind; what improvements can you think of?  I wonder if any that you see will be similar to the one I have in mind.  Here are some hints about what I have in mind.

First hint: In 'WizbangComponent.DoItAll()', in the middle of everything is the following code:

if (theNoise.Contains( "Burp!!!")) {
     NoteLoggableEvent(
          string.Format( "Thing {0} made an inappropriate noise." , thing.Name),
          LogEventType.WARNING);
   }

This code was put in to satisfy some specific requirements for ACME; it is not any kind of industry standard, and when WizbangComponent integrates into other clients, this code becomes unnecessary at best.

Second hint: take a look at AcquiCorp's factory for Protocol2.  It uses ThingEvaluatorAndReporterStrategyBag.  'Strategy Bag' is an informal term for a version of aggregation in which a class implements an interface and has little or no code of its own, instead calling on implementations of interfaces (strategies) injected into it.  ThingEvaluatorAndReporterStrategyBag has now implemented 'IThingEvaluatorAndReporter.EvaluateAndReport()' as a variation of the Template Method pattern (but using composition - specifically aggregation - instead of inheritance).

Also, notice the interface that AcquiCorp. has introduced called IEvaluator.  This separates out the evaluation of Thing conformance into its own interface that is then injected as a strategy into ThingEvaluatorAndReporterStrategyBag.  Clients can then use a particular 'Conformance Evaluator' strategy without being tied to the 'Report' algorithm of a given implementation.  Can the version of WizbangComponent that ACME currently has, fit into that?

Third hint: Research the term Iceberg Class, and think about the Single-Responsibility Principle.  How many responsibilities does WizbangComponent currently have?

Do yourself a favor, and give some thought to what's been presented here, before going forward to the answer.  When you're ready, the next section will go over that.


<< Previous: Final Improvement  |   Next: Bonus Answer >>