mloxua
Last Updated: February 25, 2016
·
766
· alexanderbrevig

The Military Design Pattern

Let's say that you want to hide all your UI elements that inherits from a Hideable interface/baseclass.

This pattern enable you to go from code like this:

foreach (Hideable hideable in frame
    .GetWidgetsManager()
    .GetAllWidgets()) 
{
    hideable.Hide();
}
foreach (Hideable hideable in frame
    .GetPopupNotices()) 
{
    hideable.Hide();
}

To this:

Hideable.Hide();

I have written an article about this that explains in further detail with implementation in C#.