Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 21.01.07 22:31 
Also ich habe einen Fehler in meinem Konzept entdeckt. Ich möchte z.B. folgendes machen können:
ausblenden Delphi-Quelltext
1:
MyClass.Attributes[index].DataType := 'bool';					

Ich hatte mir schon die Klassen TParameter, TParameterlist, TAttribute und TAttributelist entwickelt. In Planung waren noch TMethod, TMethodlist und TObjectClass.
Nun jedoch habe ich ein Problem:
Laut meinem Konzept würde der Code von oben so lauten:
ausblenden Delphi-Quelltext
1:
MyClass.Attributes.Attributes[index].DataType := 'bool';					

Ich war erst der Meinung, ich könnte z.B. die Verwaltung der Attribute (TAttribute) in die Unit Attributelist (TAttributelist) auslagern. Wenn ich nun aber TObjectClass definiere:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
unit ObjectClass;

interface

type

TObjectClass = class
   private
    //blubb
   public
     property Attributes: TAttributelist //hier kann ja eigentlich nicht TAttributelist hin!
end;

implementation

end.

dann habe ich ein Problem, weil:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
//TAttributelist hat u.a. folgende Property
property Attribute[index: integer]: TAttribute read GetAttribute write SetAttribute;

//So würde der Aufruf dann aussehen
MyClass.Attributes.Attributes[index].DataType := 'bool';

Da ich aber nicht zweimal Attributes haben will, müsste die Verwaltung von TAttribute, die eigentlich TAttributelist übernehmen sollte, direkt in TObjectClass implementiert werden. Da es aber auch noch MyClass.Methods[index] geben soll, kann ich das nicht so machen, da die Verwaltung auf einer verketteten Liste basiert und ich diese nicht zweimal in die gleiche Klasse einbauen will.
Was kann man jetzt tun?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 21.01.07 22:39 
Du kannst Array-Properties als Default deklarieren ... Dann würde das 2. Attributes implizit von Delphi ergänzt werden.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 21.01.07 22:41 
Ich bin mir nicht sicher, ob ich verstanden habe, wie deine Klassen aussehen. Ist TAttributeList.Attributes ein Array Property (property Attributs[index: Integer]: TAttribute;)? Wenn ja, dann interessierst du dich vielleicht für den Modifier default.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 21.01.07 22:43 
user profile iconBenBE hat folgendes geschrieben:
Du kannst Array-Properties als Default deklarieren ... Dann würde das 2. Attributes implizit von Delphi ergänzt werden.

Öhm wie würde das im Code genau aussehen? So?
ausblenden Delphi-Quelltext
1:
 property Attribute[index: integer]: TAttribute read GetAttribute write SetAttribute; default;					

Oder muss das in TObjectClass?

user profile icontommie-lie hat folgendes geschrieben:
Ich bin mir nicht sicher, ob ich verstanden habe, wie deine Klassen aussehen. Ist TAttributeList.Attributes ein Array Property (property Attributs[index: Integer]: TAttribute;)? Wenn ja, dann interessierst du dich vielleicht für den Modifier default.

BenBe war schneller. :P Du hast aber Recht! :zustimm:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 21.01.07 22:46 
user profile iconMarco D. hat folgendes geschrieben:
So?
Jo.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 23.01.07 18:31 
Ich habe jetzt das gleiche Problem, nur analog mit TMethod in das die Property Parameters hinein soll. :P
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
unit Method;


interface

uses Parameterlist,main,Objectclass;

type

TMethod = class

 property Parameters: TParameterlist //und jetzt?

//TParameterlist:

 property Parameter[index: integer]: TParameter read GetParameter write SetParameter; default;

Was muss ich in der Unit Method hinzufügen?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 23.01.07 20:17 
user profile iconMarco D. hat folgendes geschrieben:
Was muss ich in der Unit Method hinzufügen?
Das gleiche, was du auch in der Unit ObjectClass hinzugefügt hast. Wenn mich meine Erinnerungen nicht im Stich lassen war das exakt "nichts".

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert