Thursday, October 28, 2010

Singleton Pattern Implementation Template

The following is a Java Template to implement the Singleton pattern. 
 
public class SingletonObject
{
  private SingletonObject()
  {
    // no code req'd
  }

  public static SingletonObject getSingletonObject()
  {
    if (ref == null)
        // it's ok, we can call this constructor
        ref = new SingletonObject();  
    return ref;
  }

  public Object clone()
 throws CloneNotSupportedException
  {
    throw new CloneNotSupportedException(); 
    // that'll teach 'em
  }

  private static SingletonObject ref;
}
 
For more explanation visit: http://www.javacoffeebreak.com/articles/designpatterns/index.html 

Thursday, October 7, 2010

How to evaluate/purchase tools, systems, and products? - Need for process

We all know in the Information Systems industry, there are too many commercial and open source vendors that serve your business needs. Say for ex: you want a portal in your enterprise then you have Liferay, JBoss portal, Oracle weblogic, IBM, Vignette portal, Microsoft SharePoint etc... to name a few. Same applies if you want to purchase a enterprise bus (Oracle, Sun, IBM, WSo2, etc..), cloud service providers (Amazon, Google, Salesforce, Microsoft, Rackspace, etc..), and many other software and hardware systems. If you have delegated to lead a software or hardware system purchase, how do you go about it? what do you consider?

I have been involved directly and indirectly at the companies i have worked and working in purchasing and evaluating some systems. I have seen the leaders taking a formal and informal approaches. I observed that the teams have missed considering some medium and low priority requirements and elements by taking informal/semi-formal approach over formal approach. With the over all experience I gained through my learning from some good leaders, I feel that it is essential to follow a pattern/template/principles to accomplish the better results in a consistent manner. A evaluation/purchase life cycle involves the following steps:

1. Understand: understand the business vision and goals, high level requirements, cost, time lines, and expectations.

2. Planning and Analysis: Form a small to medium sized team of resources if necessary. Analyze the strengths and weakness of legacy systems, existing systems/products, and technical infrastructure if it is a requirement to integrate with the new system. Document the functional requirements and the technical limitations or features.

3. Research and Analysis: Do market research with respect to the systems and products that are available in the market. Share the analysis work across resources. After your analysis, shortlist the potential vendors and get RFP (Request for Proposal) if necessary.

4. Develop a score sheet or score card: After understanding the requirements,  analyzing your current infrastructure and its limitations, and shortlisting the vendors,  prepare a score sheet. A score sheet contains a the key sections (functionality, total cost,  service support, technical solution and architecture, execution,
weighted summary score) against the vendors to be evaluated.
  •   Functionality: often contains functionality, performance/security, scalability, easy of use and administration,  and integration capability.
  •   Cost: may contain integration cost, support cost, infrastructure cost, contract cost, etc.. Also, you can calculate long run cost i.e. 5 year cost.
  • Service Support: contains information on technical staff support,  web and phone support, documentation, and availability.
  • Technical Architecture: may contain how well the system is designed, the technology used, language support, compliance to your organization standards, portability, reliability, security, performance, auditing, and etc..
  • Execution: involves in evaluating the company's survivability considering its financial assets and market growth in the past, current, and future road map. 
  • The weighted summary scorecard: may contain the percentage of weight you put on key sections as shown in the figure scoresheet2.  
This score sheet can be a excel sheet. For ex: if you want to evaluate portal, see the following excel sheet images that contains the sample score sheet.

Scoresheet1: contains functional, services and support, and technical architecture.

Scoresheet2: contains Execution and Weighted summary score



5. Invite the vendors  for demonstration or proof-of-concept. Evaluate the vendor using the score sheet described above.

6. The vendor with the highest score would be your ideal vendor that can deliver the system/product that meet your business needs. In some cases, you can modify the percentage of weights placed on key sections in the weighted summary score and re-evaluate the vendor.

The above mentioned procurement evaluation process can be used as a framework and a process. There may be better ones but in my experience, following the score card process helped in accomplishing better results.

Monday, October 4, 2010

C# code to query LDAP directory and Active Directory

To query LDAP or AD server with out the domain in the path, see the following code:

public List GetAllUsers(string query)
        {
            var users = new List();
            //ldapServer does not contain the domain i.e. server.company.com 
            using (var dir = new DirectoryEntry(ldapServer, ldapUser, ldapPassword,
                      AuthenticationTypes.ServerBind))
            {
                using (var search = new DirectorySearcher(dir))
                {
                    search.Filter = query;
                    SearchResultCollection resultCol = search.FindAll(); 
                    foreach (SearchResult userProfile in resultCol)
                    {
                        LdapUser user = PopulateUserObject(userProfile);
                        users.Add(user);
                    }
                }
            }
            return users;
        }

To query LDAP or AD server domain, see the following code:

var dir = new DirectoryEntry(adPath, adUser, adPassword)
     { // ad path contains the domain i.e. DC=TEST,DC=Your_COMPANY,DC=COM   
      using (var search = new DirectorySearcher(dir))
      {
       search.Filter = query;
       SearchResultCollection resultCol = search.FindAll(); 
       foreach (SearchResult userProfile in resultCol)
       {
           LdapUser user = PopulateUserObject(userProfile);
           users.Add(user);
       }
      }                                     
      };

To learn more about AuthenticationTypes (part of System.DirectoryServices.dll), go to http://msdn.microsoft.com/en-us/library/system.directoryservices.authenticationtypes.aspx