The interface approach introduced in Part 2 of this series and extended in Part 3 did cover most of our needs. But there is nothing that can’t be done better with the right tools.
Continue reading “The Visitor Pattern – Part 4”
In Part 2 of this series we learned about a more flexible implementation of the Visitor Pattern than the traditional approach. But we can do better.
Continue reading “The Visitor Pattern – Part 3”
In Part 1 of this series we learned about the benefits of the Visitor Pattern and saw a basic approach according to the GoF description.
As clean and elegant the visitor pattern might look in the first place, it nonetheless has its disadvantages. Say, we want to add a new shape TShapeTriangle. We have to do it inside the same unit the other shapes are declared. As the shapes reference the visitor and the visitor references the shapes we have to put all shape classes together with the visitor into the same unit. Although this might work in some smaller scenarios, it definitely doesn’t in most of the real ones. Probably this is one of the reasons why the Visitor Pattern is not as famous as it should be.
Can we find a solution? Yes, we can!
Continue reading “The Visitor Pattern – Part 2”
Some of you might have already heard of the Visitor Pattern, especially if you have read the GoF book Design Patterns, but do you really use it? Do you use it often?
The common answer to this question is No. Once I was even confrontated with the question “Does anybody use it in real code at all?”.
Well, I do – and here I’m going to explain the why and the how. Actually there are different hows and at the end I will introduce a real elegant how…
Continue reading “The Visitor Pattern – Part 1”
Thanks to this article by Raymond Chen we can read what garbage collection really is and (perhaps even more valuable) what it is not.
I don’t want to start a new flame war about garbage collection (and even when – hey, this is my blog!), but I for myself I’m glad that Delphi doesn’t offer such a feature. We are always tempted, aren’t we?
Not that I don’t have any memory leaks in my programs. Not that I don’t use memory already freed. But with the right tools you can actually spot those errors and solve them. Doing so I often find some other error lurking in my code, just waiting to pop up like a jack-in-the-box. If there were no more such leak hunting, I would know less about my code than I do now.
Delphi doesn’t lack garbage collection – Delphi doesn’t need one.