I have my own mental scheme (everyone has their own one) in which a very simple object have some kind of these steps
1.- Memory allocation -> constructor
2.- Variable initialization -> init
3.- Do things -> whatever else
4.- Free the object -> free (or freeandnil).
Computer language syntax is, after all, merely a learned convention. Once you get accustomed to doing things in a certain way, you don't really think much about it and so it feels completely natural to use
Instance := TObject.Create;But yeah, sometimes I find myself on a mental scheme similar to yours---usually while maintaining
very old code bases---and it makes me think that the old Turbo-way of using
New(PObjact, Init(params)); {Your steps 1 & 2 combined}
PObject^.DoThings; { step 3 }
Dispose(PObject, Done); { and step 4 w/ explicit destructor call }
was more logical (except for the pointer thing!).
Looking more closely, though, it just happens that it's all the same. As the old TP55 manual says:
When you use this extended syntax for New, the constructor actually performs the dynamic allocation, using special entry code generated as part of a constructor's compilation*. The instance name cannot precede Init, since at the time New is called, the instance being initialized with Init does not yet exist. The compiler identifies the correct Init method to call through the type of the pointer passed as the first parameter.
(* emphasis mine)
In the end, the question is clear: Are you calling the constructor as constructor or as method? If as constructor, then having to use
AnObject := TSomeClass.Create; serves---even if just mentally---to emphasize the distinction. And remember that nothing prevents you from having an
Initialize method which you can call from your constructor ... or from elsewhere.