4

There are a lot books/online resources about using patterns. But I didn't find any tasks for using it. But for good understanding of patterns it's need practice. Maybe someone faced with some resources where there are tasks for using patterns.
For example. Mediator pattern:1)write chat application where... Thanks in advance.

UPDATE: I found: http://www.cs.sjsu.edu/~pearce/modules/labs/patterns/

How to study design patterns?

Community
  • 1
  • 1
user1074896
  • 1,025
  • 2
  • 15
  • 27
  • 4
    Maybe not quite what you are looking for, but I personally found the Head First Design Patterns book a good combination of how the patterns work and a task that they solve (which it encourages you to work through) – matt freake Feb 14 '12 at 12:55
  • I want to find if it's possible tasks for all gof patterns. I saw HFDP and it's not what I am looking for. – user1074896 Feb 14 '12 at 12:59
  • I think that it defeats the principles of design-patterns to say you must use x to achieve y, just write a chat application thinking about it's achitecture, identify the what, where, when and why and where applicable apply a known pattern or perhaps mix them up, patterns I thought should lend themselves to design, I don't think you should design to a pattern – T I Feb 14 '12 at 13:00

3 Answers3

2

I'll give you five, with easy and/or moderate difficulty:

Singleton

  • easy: single database access class for the entire application.

Factory

  • easy: English-to-another-language translator. I need to be able to add and then access a new language translator with minimal code changes.

Observer

  • easy: Central data structure that has several copies within the application that need to be updated automatically when a change to the main DS occurs.
  • moderate: Make this work over a network with cooperating processes updating a central data structure.

Memento

  • easy: A simple game with the ability to save/load.

Decorator

  • easy: A simple persistence class with read/write ability. I want to be able to dynamically switch between XML or database persistence.
Tudor
  • 61,523
  • 12
  • 102
  • 142
1

I know only of one such resource, and it is not formulated as you have specified, but maybe it'll help a bit: In the last chapters of the Head First Design Patterns book, the MVC pattern is explained as a compound pattern, involving several others : Composite, Strategy, Adapter etc. It is explained with the help of a small application. You could look up the chapter and build the described to practice.

kostja
  • 60,521
  • 48
  • 179
  • 224
1

Ever use an iterator? Pattern. My guess is you use a lot of patterns without even really realizing you're using them. Created a buffered reader out of a file reader? Decorator; pattern. Don't set out trying to use patterns--let the problem discover them. They're everywhere, that's why they're patterns.

Things like facades, decorators, iterators, factories, etc. crop up in every single domain. Pick anything you're interested in writing, and discover the patterns already present. Refactor mercilessly--patterns.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • And I want to find such tasks that I can solve at first without any patterns and then trying to improve it - to came to patterns. – user1074896 Feb 14 '12 at 13:06
  • @user1074896 So you're asking for ideas of programs to write? Just pick something. A wiki. An editor. A bot.anything. – Dave Newton Feb 14 '12 at 14:30