Skip to content

Commit

Permalink
AppVeyor Publish: a4d3047
Browse files Browse the repository at this point in the history
Merge pull request #21 from bbtsoftware/feature/toc-heading-fixes

Use correct heading levels for TOC generation
  • Loading branch information
web-flow authored Nov 21, 2019
1 parent ed63a36 commit 11a2aec
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 79 deletions.
48 changes: 24 additions & 24 deletions assets/js/searchIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,84 +39,84 @@ var searchModule = function() {
a(
{
id:0,
title:"IStrategyLocator",
content:"IStrategyLocator",
title:"GenericInstanceCreator",
content:"GenericInstanceCreator",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IStrategyLocator_1',
title:"IStrategyLocator<TStrategy>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/GenericInstanceCreator_2',
title:"GenericInstanceCreator<TInterface, TClass>",
description:""
}
);
a(
{
id:1,
title:"IGenericStrategyProvider",
content:"IGenericStrategyProvider",
title:"IGenericStrategy",
content:"IGenericStrategy",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategyProvider_2',
title:"IGenericStrategyProvider<TStrategy, TCriterion>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategy_1',
title:"IGenericStrategy<T>",
description:""
}
);
a(
{
id:2,
title:"IInstanceCreator",
content:"IInstanceCreator",
title:"GenericStrategyProvider",
content:"GenericStrategyProvider",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IInstanceCreator_2',
title:"IInstanceCreator<TInterface, TClass>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/GenericStrategyProvider_2',
title:"GenericStrategyProvider<TStrategy, TCriterion>",
description:""
}
);
a(
{
id:3,
title:"GenericStrategyProvider",
content:"GenericStrategyProvider",
title:"IInstanceCreator",
content:"IInstanceCreator",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/GenericStrategyProvider_2',
title:"GenericStrategyProvider<TStrategy, TCriterion>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IInstanceCreator_2',
title:"IInstanceCreator<TInterface, TClass>",
description:""
}
);
a(
{
id:4,
title:"IGenericStrategy",
content:"IGenericStrategy",
title:"IGenericStrategyProvider",
content:"IGenericStrategyProvider",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategy_1',
title:"IGenericStrategy<T>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategyProvider_2',
title:"IGenericStrategyProvider<TStrategy, TCriterion>",
description:""
}
);
a(
{
id:5,
title:"GenericInstanceCreator",
content:"GenericInstanceCreator",
title:"IStrategyLocator",
content:"IStrategyLocator",
description:'',
tags:''
},
{
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/GenericInstanceCreator_2',
title:"GenericInstanceCreator<TInterface, TClass>",
url:'/BBT.StrategyPattern/api/BBT.StrategyPattern/IStrategyLocator_1',
title:"IStrategyLocator<TStrategy>",
description:""
}
);
Expand Down
38 changes: 21 additions & 17 deletions docs/getting-started/fundamentals.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
<section class="infobar" data-spy="affix" data-offset-top="60" data-offset-bottom="200">

<div><p><a href="https://github.com/bbtsoftware/BBT.StrategyPattern/tree/develop/docs/input/docs/getting-started/fundamentals.md"><i class="fa fa-pencil-square" aria-hidden="true"></i> Edit Content</a></p></div>
<div id="infobar-headings"></div>
<div id="infobar-headings"><h6>On This Page</h6><p><a href="#case-study-the-switch-case-block">Case study: The Switch Case Block</a></p>
<p><a href="#improvement-use-strategy">Improvement: Use strategy</a></p>
<p><a href="#improvement-use-generic-strategy-and-and-provider">Improvement: Use generic strategy and and provider</a></p>
<hr class="infobar-hidden">
</div>

</section>
<section class="sidebar">
Expand Down Expand Up @@ -118,12 +122,12 @@
<h1>Fundamentals of strategy pattern</h1>
</section>
<section class="content">
<h2 id="case-study-the-switch-case-block">Case study: The Switch Case Block</h2>
<h1 id="case-study-the-switch-case-block">Case study: The Switch Case Block</h1>
<p>A lot of documentation and tutorials exist explaining the implementation of the strategy pattern.
For an overview see <a href="https://en.wikipedia.org/wiki/Strategy_pattern">Strategy pattern (wikipedia)</a>, at least the chapter of <a href="https://en.wikipedia.org/wiki/Strategy_pattern#Strategy_and_open.2Fclosed_principle">Strategy and open/closed principle</a> is recommended to read.
The approach of this fundamentals article is to introduce and explain the concepts and reasons of strategy pattern based on a case study: The refactoring of a switch case block.
Many code bases contain distinction of cases implemented by switch case blocks. Those implementations have numerous issues.</p>
<h3 id="violation-of-openclose-principle">Violation of open/close principle</h3>
<h2 id="violation-of-openclose-principle">Violation of open/close principle</h2>
<p>See also <a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle">Open/close principle (wikipedia)</a>. An appropriate class design supports the enhancement of functionality (open for extension) without changing the class itself (closed for modification).
Switch case blocks do not fulfill this principle.</p>
<pre><code class="language-csharp">public void Foo(FooEnum fooEnum)
Expand All @@ -141,7 +145,7 @@ <h3 id="violation-of-openclose-principle">Violation of open/close principle</h3>
}
</code></pre>
<p>If the FooEnum is extended by further enum values, the switch case block must be modified as well.</p>
<h3 id="violation-of-single-responsibility-principle">Violation of single responsibility principle</h3>
<h2 id="violation-of-single-responsibility-principle">Violation of single responsibility principle</h2>
<p>See also <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">Single responsibility principle (wikipedia)</a>. The switch case block from the example above does two things.</p>
<ol>
<li>A distinction of cases based on the enum values</li>
Expand All @@ -154,15 +158,15 @@ <h3 id="violation-of-single-responsibility-principle">Violation of single respon
</ol>
<p>Therefore the single responsibility principle is violated and consequently the reusability is limited.
Neither the distinction of cases nor the code within the case blocks could be used separately.</p>
<h3 id="maintainability">Maintainability</h3>
<h2 id="maintainability">Maintainability</h2>
<p>Most likely the above mentioned distinction of cases happens in multiple code areas.
Each time the FooEnum is extended all those areas must be modified and extended as well.
As a consequence effort increases. Without appropriate test coverage code stability decreases.
This are the main reasons why distinction of cases should be centralized and separated from executing code.</p>
<h3 id="readability-and-code-structure">Readability and code structure</h3>
<h2 id="readability-and-code-structure">Readability and code structure</h2>
<p>To fully understand the switch case block from the example above the whole block must be analyzed. Each case section can be freely implemented.
The case section has no limitations and can access all members and variables within the method scope. The code has a lack of structure.</p>
<h2 id="improvement-use-strategy">Improvement: Use strategy</h2>
<h1 id="improvement-use-strategy">Improvement: Use strategy</h1>
<p>As a first step the functionality of the case sections should be separated into classes. Those classes should be structured by implementing a common interface.</p>
<pre><code class="language-csharp">public interface IFooStrategy
{
Expand Down Expand Up @@ -208,23 +212,23 @@ <h2 id="improvement-use-strategy">Improvement: Use strategy</h2>
}
}
</code></pre>
<h3 id="improvements-with-strategy-usage">Improvements with strategy usage</h3>
<h2 id="improvements-with-strategy-usage">Improvements with strategy usage</h2>
<h4 id="single-responsibility-principle">Single responsibility principle</h4>
<p>With the introduction of FooStrategyFactory the distinction of cases is moved into its own class and separated from execution logic in case blocks.
This leads to higher chance of reuse. If other areas of code also need a distinction based on FooEnum, the FooStrategyFactory can be reused.</p>
<h4 id="maintainability-1">Maintainability</h4>
<h3 id="maintainability-1">Maintainability</h3>
<p>Because the switch case block of FooEnum is centralized by FooStrategyFactory, maintainability and code stability is improved.
Enhancements on FooEnum affects only this single existing class (and the implementation of a new FooStrategy).</p>
<h4 id="readability-and-code-structure-1">Readability and code structure</h4>
<h3 id="readability-and-code-structure-1">Readability and code structure</h3>
<p>After the refactoring the original method became explicit, structured and focused on the Bar method call.</p>
<h3 id="issues">Issues</h3>
<h4 id="violation-of-openclosed-principle">Violation of open/closed principle</h4>
<h2 id="issues">Issues</h2>
<h3 id="violation-of-openclosed-principle">Violation of open/closed principle</h3>
<p>The strategy factory still consist of the switch case block. If the FooEnum is enhanced the GetStrategy method must still be modified as well.</p>
<h4 id="violation-of-single-responsibility-principle-1">Violation of single responsibility principle</h4>
<h3 id="violation-of-single-responsibility-principle-1">Violation of single responsibility principle</h3>
<p>Besides the strategy selection the implementation of the FooStrategyFactory has another responsibility: The instantiation of the strategy instance.
This aspect should be separated and should have its own realization. There are third party libraries available for object instantiation.
Commonly used are IoC-containers. With those containers the behaviour of object lifecycle (e.g. transient, singleton) can be declared and therefore delegated to those libraries.</p>
<h2 id="improvement-use-generic-strategy-and-and-provider">Improvement: Use generic strategy and and provider</h2>
<h1 id="improvement-use-generic-strategy-and-and-provider">Improvement: Use generic strategy and and provider</h1>
<p>BBT.StrategyPattern defines an interface for declaration of strategies based on a generic type parameter.</p>
<pre><code class="language-csharp">public interface <a href="/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategy_1">IGenericStrategy&lt;T&gt;</a>
{
Expand Down Expand Up @@ -279,11 +283,11 @@ <h2 id="improvement-use-generic-strategy-and-and-provider">Improvement: Use gene
kernel.Bind&lt;IFooStrategy&gt;().To&lt;Foo1Strategy&gt;();
kernel.Bind&lt;IFooStrategy&gt;().To&lt;Foo2Strategy&gt;();
</code></pre>
<h3 id="improvements-with-generic-strategy-and-generic-strategy-provider-usage">Improvements with generic strategy and generic strategy provider usage</h3>
<h4 id="openclosed-principle">Open/closed principle</h4>
<h2 id="improvements-with-generic-strategy-and-generic-strategy-provider-usage">Improvements with generic strategy and generic strategy provider usage</h2>
<h3 id="openclosed-principle">Open/closed principle</h3>
<p>When FooEnum is enhanced, with the generic strategy provider, additional strategies can be added without modifying existing classes.
As soon as the new strategies are registered in the IoC container, the provider is extended.</p>
<h4 id="single-responsibility-principle-1">Single responsibility principle</h4>
<h3 id="single-responsibility-principle-1">Single responsibility principle</h3>
<p>The generic provider has one single responsibility: Providing the requested strategy. How this strategy is instantiated is separated and handled be the strategy locator (i.e. IoC container).</p>

</section>
Expand Down
9 changes: 6 additions & 3 deletions docs/getting-started/principles.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
<section class="infobar" data-spy="affix" data-offset-top="60" data-offset-bottom="200">

<div><p><a href="https://github.com/bbtsoftware/BBT.StrategyPattern/tree/develop/docs/input/docs/getting-started/principles.md"><i class="fa fa-pencil-square" aria-hidden="true"></i> Edit Content</a></p></div>
<div id="infobar-headings"></div>
<div id="infobar-headings"><h6>On This Page</h6><p><a href="#advantages">Advantages</a></p>
<p><a href="#implementation-details">Implementation details</a></p>
<hr class="infobar-hidden">
</div>

</section>
<section class="sidebar">
Expand Down Expand Up @@ -123,13 +126,13 @@ <h1>Core principles</h1>
The library introduces an <code><a href="/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategy_1">IGenericStrategy&lt;T&gt;</a></code> which needs to be implemented for every case a strategy with a given criterion is supporting.
The instances of the <code><a href="/BBT.StrategyPattern/api/BBT.StrategyPattern/IGenericStrategy_1">IGenericStrategy&lt;T&gt;</a></code> are managed by the <code>IGenericStrategyProvider&lt;out TStrategy, in TCriterion&gt;</code> which resolves the correct implementation for the given criterion.
The generic parameter acts as selection criterion and declares the responsibility of the specific strategy.</p>
<h2 id="advantages">Advantages</h2>
<h1 id="advantages">Advantages</h1>
<ul>
<li>The generic strategy interface leads to more structured code.</li>
<li>Based on their generic type parameter, strategies are categorized and make their responsibility explicit. As a consequence this leads to higher chance of reuse and better readable code.</li>
<li>The implementation is driven by SOLID principles like open/closed, single responsibility and dependency inversion. For further explanations see <a href="./fundamentals">Fundamentals of strategy pattern</a>.</li>
</ul>
<h2 id="implementation-details">Implementation details</h2>
<h1 id="implementation-details">Implementation details</h1>
<ul>
<li>Introduces a generic strategy interface</li>
<li>The generic parameter represents the criterion for the selection of the specific strategy</li>
Expand Down
32 changes: 16 additions & 16 deletions docs/getting-started/whystrategypattern.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="description" />
<meta name="keywords" content="static content generator,static site generator,static site,HTML,web development,.NET,C#,Razor,Markdown,YAML" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="description">
<meta name="keywords" content="static content generator,static site generator,static site,HTML,web development,.NET,C#,Razor,Markdown,YAML">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/BBT.StrategyPattern/assets/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="/BBT.StrategyPattern/assets/img/favicon.ico" type="image/x-icon">
<title>BBT.StrategyPattern - Why does BBT.StrategyPattern exist?</title>
<link href="/BBT.StrategyPattern/assets/css/highlight.css" rel="stylesheet">
<link href="/BBT.StrategyPattern/assets/css/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="/BBT.StrategyPattern/assets/css/adminlte/AdminLTE.css" rel="stylesheet" />
<link href="/BBT.StrategyPattern/assets/css/theme/theme.css" rel="stylesheet" />
<link href="/BBT.StrategyPattern/assets/css/bootstrap/bootstrap.css" rel="stylesheet">
<link href="/BBT.StrategyPattern/assets/css/adminlte/AdminLTE.css" rel="stylesheet">
<link href="/BBT.StrategyPattern/assets/css/theme/theme.css" rel="stylesheet">
<link href="//fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,400i,700,700i" rel="stylesheet">
<link href="/BBT.StrategyPattern/assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="/BBT.StrategyPattern/assets/css/override.css" rel="stylesheet" />
<link href="/BBT.StrategyPattern/assets/css/override.css" rel="stylesheet">
<script src="/BBT.StrategyPattern/assets/js/jquery-2.2.3.min.js"></script>
<script src="/BBT.StrategyPattern/assets/js/bootstrap.min.js"></script>
<script src="/BBT.StrategyPattern/assets/js/app.min.js"></script>
Expand Down Expand Up @@ -74,7 +72,9 @@
<section class="infobar" data-spy="affix" data-offset-top="60" data-offset-bottom="200">

<div><p><a href="https://github.com/bbtsoftware/BBT.StrategyPattern/tree/develop/docs/input/docs/getting-started/whystrategypattern.md"><i class="fa fa-pencil-square" aria-hidden="true"></i> Edit Content</a></p></div>
<div id="infobar-headings"></div>
<div id="infobar-headings"><h6>On This Page</h6><p><a href="#features">Features</a></p>
<hr class="infobar-hidden">
</div>

</section>
<section class="sidebar">
Expand Down Expand Up @@ -121,7 +121,7 @@ <h1>Why does BBT.StrategyPattern exist?</h1>
</section>
<section class="content">
<p>BBT.StrategyPattern is a generic implementation of the strategy design pattern.</p>
<h2 id="features">Features</h2>
<h1 id="features">Features</h1>
<ul>
<li>Support the usage of strategies with no need to implement specific strategy factories</li>
<li>Provide a generic strategy provider based on generics</li>
Expand All @@ -140,8 +140,8 @@ <h2 id="features">Features</h2>
<div class="wrapper bottom-wrapper">
<footer class="bottom-footer">
<p class="text-muted">
Copyright &copy; <a href="http://bbtsoftware.ch" target="_blank">BBT Software AG</a> and <a href="https://github.com/bbtsoftware/BBT.StrategyPattern/graphs/contributors" target="_blank">contributors</a>.
<br/>
Copyright © <a href="http://bbtsoftware.ch" target="_blank">BBT Software AG</a> and <a href="https://github.com/bbtsoftware/BBT.StrategyPattern/graphs/contributors" target="_blank">contributors</a>.
<br>
Website generated by <a href="http://wyam.io" target="_blank">Wyam</a>
</p>

Expand Down Expand Up @@ -268,5 +268,5 @@ <h2 id="features">Features</h2>
}, 500);
});
</script>
</body>
</html>

</body></html>
Loading

0 comments on commit 11a2aec

Please sign in to comment.