Nuno Picado

Member since: Tuesday, 24 January 2017
Last login: 5 years ago
Profile viewed: 758 views

No Rank
Points: 0

Like I said, no advantages in readability or verbosity. This would probably look better if anonymous methods in Delphi could be declared some other way, with less verbosity.

Yes, than is indeed the main goal!

I have found some Delphi programmers use Destroy instead of Free. This will of course create problems freeing a nil object. Of course one has to wonder why they are doing that in the first place. I can't think of any good reason to use Destroy direct

The Using class will allow you to replace the #1 solution, like so:// Multiple resource protection #1 Using.New( procedure (A1: TTest) begin Using.New( procedure (A2: TTest) begin A1.DoSomething; A2

The Using class is basically an anonymous method wrapped inside a try...finally block.

On "my" objects, I tend to use interfaces, so that particular problem I don't usually have to deal with. Whenever using non interfaced objects, I use them with the Using class I made (Nick Hodges tip):

I recently started to learn (real) OOP, after years os using procedural code inside Delphi. Decoupling GUI from business logic was something that wasn't being easy. I tried several models, like MVC for instance, and just couldn't get myself to like t