6

I'm looking for design patterns (GOF, but others would be welcome too) for Delphi 2009.

There are some very good and classic articles about Design Patterns in Delphi:

Additionally, the newer Delphi's have some design patterns built in into the IDE via the model view.

However, none of them seem to make good use of the new features that Delphi has to offer, like generics and anonymous methods. There are C# examples that use generics and anonymous methods, but they can't really be translated 1:1 to Delphi, and I'd like to get some advice from people who've got hands-on experience with these specific features in Delphi.

Are any example available online, or in a book, or can anyone provide some useful examples or tips maybe?

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122

2 Answers2

4

I've got a fairly simple example of a Generic Factory that uses anonymous methods up here

Malcolm Groves
  • 771
  • 3
  • 6
  • You may want to take a look at ModelMaker (http://www.modelmakertools.com) since it implements some design patterns IIRC. I mostly use it for documentation and code visualization, but it seems to be a very solid tool. – David Taylor Jun 07 '09 at 19:46
1

GOF patterns are the same for any object oriented language. Delphi 2009 is not an exception. Generics and anonymous methods features are just a syntactic sugar, to make our life easier. So if your read the original GOF Design Patterns book, you can easily apply its concepts to Delphi 2009 and all its previous versions (even some of Turbo Pascal).

Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60
  • Ok, let me clarify: I'm not looking for the patterns (the book you're mentioning is on my desk at the moment). I'm looking for specific implementations and best practices now that we've got new language features that we can make use of. – Wouter van Nifterick Jun 07 '09 at 11:52
  • 1
    Some patterns are not easy to implement in Delphi. The Visitor pattern for example, when the classes are in different units: the only solution I know involves hard class typecasts. – mjn Jun 07 '09 at 17:47
  • @mjn You can implement the Visitor pattern using interfaces: http://www.uweraabe.de/Blog/2010/08/16/the-visitor-pattern-part-2/ – Ian Goldby Nov 18 '14 at 16:38
  • @IanGoldby yes, actually this blog seems to be based on the answer for my question [Delphi Enterprise: how can I apply the Visitor Pattern without circular references?](http://stackoverflow.com/questions/2356318/) – mjn Nov 18 '14 at 17:31