Showing posts with label Patterns. Show all posts
Showing posts with label Patterns. Show all posts
Sunday, January 19, 2014
Dependancy Injection
How would you pass a static class like the Console? I am not seeing good solutions out there
Favor composition over inheritance
I guess VB6's class model wasn't so bad after all.
Thursday, January 9, 2014
Factory pattern with DB objects
make sure the server (IIS) is not caching the structure of your objects if you are getting errors upon changing the sp's
Labels:
c#,
Factory Pattern,
Patterns,
sql server
Wednesday, January 8, 2014
Immediate invocation in Javascript
is handled, for example, thusly
(function ($) {
})(jQuery);
(function ($) {
})(jQuery);
the () is needed because otherwise JS thinks function is a decleration, the JQuery is passed in
so the code can now reference JQuery as a "$" without having to traverse the scope chain looking for the variable
Patterns in Javascript
Patterns and problems
I was reminded of patterns when I read E.O wilson's Letters to a Young Scientist that every form of life is an answer to a problem.
Here is a short list of patterns and problems they attempt to answer
Here is a short list of patterns and problems they attempt to answer
| Pattern | Problem |
| Singleton | Only one instance of an object |
| Strategy | Apply functionality only where needed - not the whole inheritance chain |
| Avoid multiple switch statements | |
| Observer | Loosely coupled way to notify |
| Template | force child classes to implement what they need (by making those methods abstract) , but follow the parents process |
| Factory Method | Method for subclasses to create correct class |
| Works in tandem with strategy | |
| Abstract Factory | Defer concrtete implementation for child classes |
| Avoid multiple switch statements | |
| A way to have multiple versions of a class | |
| Façade | Simplify gateway to single/multiple interfaces |
| Command | Loosely coupled way to execute a method |
| good for Qeues |
Wednesday, November 27, 2013
Example of Singleton pattern
public class sing
{
private static sing Sing;
private sing()
{
}
public int x;
public int y;
public static sing SING
{
get
{
if (Sing == null)
{
Sing = new sing();
}
return Sing;
}
}
}
static void Main(string[]
args)
{
sing.SING.x = 7;
Console.WriteLine(sing.SING.x.ToString());
Subscribe to:
Comments (Atom)