Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have read the concepts and practiced some examples on OOAD and Design Patterns. But when I was asked to implement the singleton pattern in a little bit different manner, I was unable to do it and failed to reach my goal. I think I need some more in-depth understanding of the basics and some real experience with the concepts.

Please suggest me some good books and mini projects for me to get hands on experience on OOAD and Design Patterns in C#. I have almost 9 months of time frame to retake the test.

I have done this for singleton. It's valid code. But i was asked to implement in such a way that, i should be able to create instance of DBConnection class only once. use that instance to get the Connection object. This is where, i have failed to implement singleton :(

class DBConnection 
{
    private Connection _conn = null;
    static Connection GetConnection()
    {
         if(_conn ==null)
              _conn = new Connection(...);
         return _conn; 
    }
}
share|improve this question
    
What was your goal, and how did you fail? –  kevin cline Jan 24 '12 at 16:36
    
I want to be an expert in OOAD and Design Patterns. I wanted to learn in-depth. –  Dinesh Jan 25 '12 at 2:52
    
I was not able to answer a simple questions like Definition of Polymorphism, Why we have to use class, etc... :( –  Dinesh Jan 25 '12 at 2:53
    
I thought you were "unable to implement the singleton pattern in a different manner". What did you try? –  kevin cline Jan 25 '12 at 4:18
    
@kevin, I have added my singleton code to the question. –  Dinesh Jan 25 '12 at 7:18

2 Answers 2

Check out the dofactory website. They list all of the GoF patterns with concrete examples in C#. They are trying to sell a product that implements the patterns for you but there is a lot of useful examples on their website.

share|improve this answer

Head First into Design Patterns is a great book for beginners that discusses the patterns with practical (but very ficticious) examples.

If you're more inclined into a reference book then the original GoF book might be right up your alley, but is rather lacking in examples other than for descriptive purposes.

There is a book, Agile Software Development, Principles, Patterns, and Practices by Uncle Bob, that is highly regarded and commonly used as college-level course material. It has some practical examples and also goes through the SOLID principles and have a chapter on test driven development (IIRC).

share|improve this answer
    
+1 Much as I hated the dumbed down style of the Head First book, I have to begrudgingly admit that I did learn quite a lot from it. With "Uncle Bob" I'd say his principles are bang on, but his code is at best mediocre. –  user23157 Jan 24 '12 at 10:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.