What Design Patterns do you implement in common Delphi programming? -
What design patterns do you apply to Common Delphi Programming ? Which patterns are easy to optimize in Delphi programming? (Each language is excellent in different areas, so what pattern is likely to be a very strong structure while using Delphi?)
I would be happy if you had any changes in the design pattern You can tell about Delphi 2009/2010 (since those support generic and RTTI in 2010).
There are many articles in the wild Internet, but they do not discuss everyday applicability patterns. (Most of them discuss only language attributes, architecture changes)
Only a minority of Delphi developers knows that every Delphi developer is a (delphi.about.com) Uses, but then virtualize is implemented using Constructors. Therefore: Time to put some light at that time: -)
Virtual constellants are like a series of virtual methods, such as object insents.
The full idea of the factory pattern is that you can double the argument, which determines how (in this case "class") in this case "object instance") with the actual creation Make them.
This works by using the Virtual Select Controllers like this:
There is one in TCPN, which can be overridden by a descending class:
Type TComponent = class (TPersistent, ...) Build Creator (AOwner: TComponent); Virtual; ... End;
For example, it overlaps:
Type TDirectoryListBox = class (...) Build Creator (AOwner: TComponent); Override; ... End;
You can store a square reference (the class analogy of the object frequency reference) in a variable type 'class type', for component squares, there is a predefined type:
type TComponentClass = square of TComponent;
When you have a variable (or parameter) of TComponentClass type, you can construct a polymorphic, which is very similar to the factory pattern:
Var Classo Create: Ticomontent Class; ... Process SomeMethodInSomeUnit; Ready to start the classroom: = Teabton; End; ... process AnotherMethodInAnotherUnit; Manufactured Var: Company: Tecompensant; Created Created: = Classroom Cut Create (app); ... End;
Delphi RTL uses this for example:
Result: = TecPontentClass (SearchClasset). Create (zero);
And here:
// Make another example of this kind of grid sub-grid: = TComponentClass (Self.ClassType). (Self) );
The first experiment in Delphi RTL is how the entire creation process works form, data module, frame and components that are being read from DFM file.
The form (Datamadol / Frame / ...) is actually a component in the class that is on the form (DataModol / Frame / ...). That list includes example names and class references for each component. When reading DFM files, Delphi RTL:
- Displays the name of the component instance,
- uses that name to find the context of the underlying class ,
- then uses the cell reference to dynamically create the right object
A regular Delphi developer usually does not, but without it, the whole The Delphi RAD experience does not exist
(Chief Scientist in AmberCadero) wrote a short story also there is a question about it.
Let me know if there is enough light on the constructor subject to create virtual: -)
- jeroen
Comments
Post a Comment