NetInverse Developers Blog

May 10, 2009
Category: Agile, Architecture, Design Pattern — Tags: — admin @ 8:59 pm
  1. On the criteria to be used in decomposing systems into modules – David Parnas
  2. A Note On Distributed Computing – Jim Waldo, Geoff Wyant, Ann Wollrath, Sam Kendall
  3. The Next 700 Programming Languages – P. J. Landin
  4. Can Programming Be Liberated from the von Neumann Style? – John Backus
  5. Reflections on Trusting Trust – Ken Thompson
  6. Lisp: Good News, Bad News, How to Win Big – Richard Gabriel
  7. An experimental evaluation of the assumption of independence in multiversion programming – John Knight and Nancy Leveson
  8. Arguments and Results – James Noble
  9. A Laboratory For Teaching Object-Oriented Thinking – Kent Beck, Ward Cunningham
  10. Programming as an Experience: the inspiration for Self – David Ungar, Randall B. Smith

by Michael Feathers. You can read the original post here.

April 4, 2009
Category: Design Pattern — Tags: — admin @ 9:57 pm

Design patterns are just for Java™ architects — at least that’s what you may have been led to believe. In fact, design patterns are useful for everyone. If these tools aren’t exclusive to architecture astronauts, what are they, and why are they useful in PHP applications? This article explains.

April 2, 2009
Category: Design Pattern — Tags: — admin @ 7:03 pm

1. Is easily testable
2. Constains no duplication
3. Has intentional coupling, strong cohesion, and clarity.

March 9, 2009
Category: .Net, Design Pattern — Tags: , — admin @ 8:18 pm

A typicaly Singleton implementation in C# looks like below:

    using System;

    public sealed class Singleton
    {
       private static volatile Singleton instance;
       private static object syncRoot = new Object();

       private Singleton() {}

       public static Singleton Instance
       {
          get
          {
             if (instance == null)
             {
                lock (syncRoot)
                {
                   if (instance == null)
                      instance = new Singleton();
                }
             }

             return instance;
          }
       }
    }

[MSDN]This approach ensures that only one instance is created and only when the instance is needed. Also, the variable is declared to be volatile to ensure that assignment to the instance variable completes before the instance variable can be accessed. Lastly, this approach uses a syncRoot instance to lock on, rather than locking on the type itself, to avoid deadlocks. This double-check locking approach solves the thread concurrency problems while avoiding an exclusive lock in every call to the Instance property method. It also allows you to delay instantiation until the object is first accessed.

Above solution looks perfect, however, actually the ‘Double-Checked Locking’ can be still broken under certain multi-processor machine. A recommended way to implement Singleton correctly is below:

    public sealed class Singleton
    {
        Singleton(){}
        public static Singleton Instance
        {
            get
            {
                return Nested.instance;
            }
        }

        static class Nested
        {
            internal static readonly Singleton instance = new Singleton();
        }
    }

Above code looks weird, but correct. It leverages .Net’s Class Loader to achieve thread-safe.

March 6, 2009
Category: Design Pattern — Tags: — admin @ 11:03 pm

Please check out Scott Bain’s http://www.netobjectivesrepository.com. This is a site where you can find authoritative information about design patterns.

This respository is sponsored by Net Objectives, a Seattle-based organization dedicated to training, coaching, and consulting on software design, agile methodologies, test-driven development, lean software process, and scrum.

You are free to use this material for your edification and study, and, optionally, you may contribute your views on patterns and forces in software development by signing up for a free membership. For other online resources provided by Net Objectives, please visit Net Objectives Online. The site manager is Scott Bain.

Knowing the OO basics doesn’t make you a good OO designer. You need to know OO principles and Patterns. Following is cited from the book Head First Design Patterns.

OO Basics

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance

OO Principles

  • Encapsulate variation
  • Favor composition over inheritence
  • Program to interfaces, not implementations

OO Patterns

  • Strategy- defines a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
  • Bridge…

©2009 NetInverse. All rights reserved. Powered by WordPress