17

I am planning to learn C# on the job - a moderately complex (2000 lines of code) project. I am interested in picking up "design patterns" along the way.

Can anyone suggest a book that doesn't assume too much of c# expertise and teaches design patterns? It's ok if the book is not devoted to design patterns (it could be one of the chapters).

Soumendra
  • 1,174
  • 1
  • 15
  • 28
  • 5
    Just a sidenote: You won't need many design patterns in a project that small. IMO, design patterns are much more useful in larger projects. I think it's a good idea to practice in a small project, but don't expect the full epiphany until you use them in a large project that's maintained over a long time and that has to be documented and explained to other developers. – Niki Dec 01 '10 at 11:40
  • Originally I wanted to go through [this book](http://www.amazon.com/Design-Patterns-Ruby-Russ-Olsen/dp/0321490452) (designin patterns in Ruby). I am really impressed with that book (after a superficial first reading), but unfortunately I can't do this project in Ruby. I'll keep your sidenote in mind. – Soumendra Dec 02 '10 at 07:46
  • 1
    Shameless plug: I wrote this book (in 2018) covering modern C# design pattern implementations: https://leanpub.com/csharp_patterns – Dmitri Nesteruk Sep 04 '18 at 17:51

8 Answers8

26

An excellent book is Head First Design Patterns. Easy to understand and follow and a fun read.

The GoF book is where it all started, but I found it very dry and difficult to grasp. Not what I would recommend for learning.

Examples are in Java, but the concepts translate well.

You can even get C# examples.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • 3
    +1 for Head First Design Patterns. The cover must drive many people away from it because it looks lame. But, the content is really great if you're just starting out. – TheCloudlessSky Dec 01 '10 at 12:57
  • The official page for the HF Design Patterns lists [another source for C# code](http://www.msquaredweb.com/DesignPatterns/HeadFirstDesignPatternsInCSharp.zip). I am starting with this book plus another one in the series on OOAD. – Soumendra Dec 02 '10 at 07:52
4

HEAD First Series is a good starting point

i would say please use HEAD First OOAD book also

TalentTuner
  • 17,262
  • 5
  • 38
  • 63
  • yes, I checked out the design patterns book and then the ooad one also and I have decided to read them both. – Soumendra Dec 02 '10 at 07:36
4

Design patterns are actually language agnostic. They are not tied to a particular language. So for instance any design pattern that works with Java, will work for C# too.

Of course there are patterns which works with a particular language/technology such as MVVM, but I don't think you are writing in WPF or Silverlight, do you? For web you can choose to go with MVC instead of WebForms.

And about the books, you can take a look at

Because C# is a full OO language, you will have to adapt to OO design principles and patterns.

mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
Davita
  • 8,928
  • 14
  • 67
  • 119
  • I am actually going to use both WPF and Silverlight (for a bit of charting), though I might drop Silverlight if there's too much to do. I just think that if I indeed have to learn it, I might as well learn it the right way and the right tools. – Soumendra Dec 02 '10 at 07:39
2

I agree with the other responses that design patterns are language agnostic. However, coming from a C# background, I have found the book Design Patterns in C# by Steven John Metsker to be a great read and would be relevant for you.

mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
Paige Cook
  • 22,415
  • 3
  • 57
  • 68
1

"Design Patterns" The gang of four.

poporul
  • 1,141
  • 2
  • 9
  • 10
  • 8
    This is a book you have to own if you want 'bookshelf credibility', but it's not a great book to learn from IMO. – Will Dean Dec 01 '10 at 11:33
1

The obvious choice would be Design Patterns in C#, but I've not read it, so I can't comment on its quality.

Edit: As mentioned by Popo, the Design Patterns book itself is a great way to learn design patterns, but the code is not in C#: Design Patterns: Elements of Reusable Object-Oriented Software

mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
Jackson Pope
  • 14,520
  • 6
  • 56
  • 80
1

I would highly recommend this website for design patterns, anti-patterns UML and refactoring

http://sourcemaking.com/

Very well structured and easy to read!!

Andrew
  • 9,967
  • 10
  • 64
  • 103
0

There are several good books (some already mentioned) on design patterns. I actually have around four or so. When learning a pattern I like to read about it in more than one book. Usually the scenarios and examples will be a little different, which helps get the idea better. Wikipedia.org is a pretty good resource too.

That said, I like to spend some time reading code related to the patterns. Code that shows strengths of a platform is nice for obvious reasons. Check out http://www.dofactory.com while you are at it. If you want to see the GoF and other enterprise patterns applied to some real coding problems, then that site is excellent. You have to pay for the reference app and design patterns solutions, but there are examples related to the Head First book, the GoF work, and what they call optimized variations that leverage .NET.

Some books I found useful:

  • Head First Design Patterns: Great book for getting the ideas.
  • C# 3.0 Design Patterns (Judith Bishop) : Not my favorite for the code examples, but there are usually some nice points around comparing a pattern to other related patterns and why you might pick one over another.
  • Design Patterns (Christopher G. Lasater): A pretty good book that is straight to the point.
mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
Burt
  • 73
  • 6