Skip to content

A sandbox for the testing and storage of useful software patterns.

Notifications You must be signed in to change notification settings

johnmaloney/Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patterns

A sandbox for the testing and storage of useful software patterns.

Recursion

Towers Of Brahma (or Hanoi) This is a famous recursion problem and the pattern I am using is the most basic use of recursion to solve it.

Strategy Pattern

The strategy pattern helps mitigate the tight coupling inherent in the use of static methods. For example take this method

    public static string HasWithin(string searchFor, string searchWithin)
    {
        // implentation //
    }

There is no way to replace the use of that static method when trying to mock items within a test project. Using the Strategy pattern we can implement a way to inject a different implementation during a test projects execution. alt text

Here is the main method for using the strategy:

    public static T For<T>() where T : class, IStrategy

then to use the method:

    Strategy.For<IStringSearch>().HasWithin(searchFor, searchWithin)

Pipes and Filters Pattern

This pattern is a variation on the long standing Pipes and Filters pattern. The example stays within the purpose of the pattern but terms the group of pipes as a pipeline and the filter as the "Process" method of a pipe (i.e. no explicit class for the filter concept).

alt text

Pipes and Filters .Net Fiddle Example

##Blockchain

###Merkle Tree

About

A sandbox for the testing and storage of useful software patterns.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages