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.

Delphi has a few problems implementing some design patterns because some features it lacks, like multiple inheritance and no pure abstract classes.

Are there any good resources or "Adaptation-Patterns" to convert some or all of the Design Patterns in the GoF book, to Delphi applications?

share|improve this question
5  
What necessities are there for multiple inheritance in implementing which design patterns? –  Frank Shearar Feb 4 '11 at 15:48
4  
"Delphi has a few problems implementing some design patterns because of the necessity of multiple inheritance."? Please provide an example or two. –  S.Lott Feb 4 '11 at 16:28
2  
@Peter Turner: Java and C# don't have multiple inheritance, but they still implement the Adapter pattern. Look up how they do it to get some hints... –  FrustratedWithFormsDesigner Feb 4 '11 at 16:58
1  
"I've just found the examples in the book difficult to translate into Pascal." I'm sure that's true. But we can't imagine what's "difficult" for you. Could you provide a specific example of a pattern and the specific Pascal-related questions you have? –  S.Lott Feb 4 '11 at 17:03
1  
I'm talking about objective difficulty in terms of the translation of the pattern isn't possible in 1-to-1 (like lifting a C++ merge sort algorithm) –  Peter Turner Feb 4 '11 at 17:12
show 6 more comments

closed as off-topic by gnat, BЈовић, Kilian Foth, GlenH7, Dan Pichelman Jul 31 '13 at 19:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, BЈовић, Kilian Foth, GlenH7, Dan Pichelman
If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

A pure abstract class is just an interface in Delphi. And since Delphi allows a class to implement as many interfaces as possible, that should really remove the worst burden.

share|improve this answer
add comment

The Design Patterns as presented in the GoF book are very heavyweight solutions. I would consider them over engineering in many cases. I would suggest implementing the patterns using much simpler class structures.

I think it is the complexity of the structures you are trying to recreate, rather than the patterns themselves, that are causing you problems.

share|improve this answer
add comment

The VCL is literally filled with implementations of patterns, many of which have come straight out of the GoF book itself.

I think that one problem that many people have when using Delphi is that Delphi allows a class with abstract methods to be compiled and used at run time provided the abstract methods are not called. The only thing that is purely abstract are Interfaces. Everything else that is needed for class inheritance and supporting multiple interfaces works with Delphi, so I can't really see how you would have any difficulty implementing ANY of the GoF Patterns. I've certainly never had any difficulty in the 14 or so years that I've been using the language.

As for multiple inheritance, what does that have to do with patterns? Multiple inheritance is rife with problems conceptually, particularly if you are attempting to implement a descendant of two classes that present interfaces where there are identical methods with slightly different implementations. Which one would be used, and how would you choose? Interfaces solve this problem very elegantly in that you can use many interfaces in a single class implementation, and at different levels of the ancestry of a class.

If you have problems implementing specific patterns, perhaps a question on ProgrammersSE with some example code would help you to gain a better understanding about ways to overcome a particular problem in Delphi. I'm sure they would make great questions.

Cheers,

share|improve this answer
add comment

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