Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 23.08.08 20:12 
Hallo.

Ich habe eine Frage zu meinem Turbo Delphi (was ja im Prinzip ein BDS 2006 ist):
Ich habe eine Basisklasse, die recht viele abstrakte Methoden bereitstellt, welche die Kinder dann überschreiben müssen.

Wie kann ich denn von der Basisklasse eine neue Klasse ableiten ohne dass ich das ganze Grundgerüst per Hand tippen muss? Geht das in der Delphi IDE ?

Danke,
Matze

_________________
In the beginning was the word.
And the word was content-type: text/plain.
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Sa 23.08.08 20:30 
vieleicht so?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type 
  irgenteineKlasse = Class(<...>)
    procedure do Something; abstract;
    ...
  end;

  MeineNeueKlasse = Class(irgenteineKlasse)
    ...
    procedure do Something; 
   
  end;


du musst lediglich die Deklaration übernehmen und implementieren.

oder verstehe ich deine Frage falsch?

grz
Msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 23.08.08 20:31 
Das ist ihm schon klar, es ging ihm darum dass das automatisch passiert eben ohne das Kopieren der abstrakten Routinen.
Ich kenne da keine entsprechende Funktion.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 23.08.08 22:37 
user profile iconjaenicke hat folgendes geschrieben:
Das ist ihm schon klar, es ging ihm darum dass das automatisch passiert eben ohne das Kopieren der abstrakten Routinen.

Der Mann hat mich verstanden :)

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 23.08.08 23:26 
Für die gesamte Klasse ohne irgendwelche 3rd-Party-Tools: Geht wohl nicht.

Wenn du Intellisense im Interface aufrufst, kannst du wenigstens Methode-für-Methode die korrekten Deklarationen erstellen lassen. Am Schluss noch Strg + Shift + C, um die Rümpfe zu erstellen.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 23.08.08 23:34 
Ich habe mir mal den Code eines Plugins für die Delphi IDE angeschaut, das ich mal geschrieben habe. Das Problem ist, dass die Funktionalität von Delphis ToolsAPI nicht nutzbar ist, weil in Turbo Delphi ja nichts installiert werden kann. Dennnoch denke ich, dass ich da was hinbekomme, nicht so komfortabel integriert wie mit der ToolsAPI und in Delphi selbst, aber fast.

Wie ich mir das denke: Das Programm läuft in der Tray, Hotkey drücken, Name der Elternklasse aus einer Liste auswählen, Name der neuen Kindklasse eingeben, das Programm fügt den Quelltext der neuen Klasse ein, fertig.

Das interessiert mich jetzt :mrgreen:. *Delphi startet*

// EDIT: Warum funktioniert WM_GETTEXT dort nicht? O.o
Der Rest sollte soweit gehen, aber ich komme nicht direkt an den Text heran... Naja, mal schauen.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 24.08.08 09:38 
Oh, das solle ich vielleicht erwähnen: Ich hab die Prof Variante von den Turbos. Also kann man da alles machen was man auch im BDS 06 machen kann. Ok bis auf die anderen Personalities wie C#...

In dem Sinne wäre ein IDE Experte wohl doch die bessere wahl, oder ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 24.08.08 10:23 
Hi,

Also bei meinem Turbo Delphi kann ich theoretisch xml-Templates Schreiben. Damit müsste das doch eigentlich gehen :?:

mfG,
Einloggen, um Attachments anzusehen!
_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 24.08.08 10:33 
Ich glaube nicht. Das geht vielleicht für das allgemeine Grundgerüst einer Klasse aber nicht für ein spezielles einer abgeleiteten Klasse...

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 24.08.08 10:44 
Ich kenne mich jetzt mit xml nicht aus, aber nach reiner String-Verarbeitung müsste ja nur beim Tippen einer Klasse die Klasse in Klammern gesucht werden. Dort dann alle Methoden, hinter denen abstract steht kopieren..

Geht das mit xml nicht?

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 25.08.08 03:46 
user profile iconmatze hat folgendes geschrieben:
Oh, das solle ich vielleicht erwähnen: Ich hab die Prof Variante von den Turbos. Also kann man da alles machen was man auch im BDS 06 machen kann. Ok bis auf die anderen Personalities wie C#...

In dem Sinne wäre ein IDE Experte wohl doch die bessere wahl, oder ?
Ja, sicher und ich glaube den gibts auch schon, ich werde mal schauen, auf jeden Fall funktioniert es bei mir, dass ich aus einer Unit die Klassen erkenne und nach der Auswahl dann das Skelett einer neuen Klasse erstelle. Mit Hilfe der ToolsAPI sollte das dann recht einfach sein das auch direkt im Editorfenster zu benutzen. Ich verreise Ende nächster Woche, werde aber sehen, dass ich dazu noch etwas Zeit finde vorher.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 25.08.08 10:01 
Man darf also gespannt sein :-)

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mo 25.08.08 10:14 
user profile iconKha hat folgendes geschrieben:
Wenn du Intellisense im Interface aufrufst, kannst du wenigstens Methode-für-Methode die korrekten Deklarationen erstellen lassen.

Wenn mich nicht alles täuscht kann man sogar mehrere Methoden auswählen (mit UMSCH und/oder STRG).

Lg, Martin

_________________
Ein Nutzer der Ecke ;-)
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Mo 25.08.08 15:07 
user profile iconmatze hat folgendes geschrieben:
Hallo.

Ich habe eine Basisklasse, die recht viele abstrakte Methoden bereitstellt, welche die Kinder dann überschreiben müssen.


Hallo,

wenn du den Kids Schreibarbeit ersparen willst, füg doch einfach einen Kommentarblock ein mit den Klassendefinitionen aller abstrakt definierten Klassen - Copy & Paste beherrschen die doch im Schlaf.

Ok, ist vielleicht kein glänzendes Beispiel für reine OO-Lehre.

Gruss Reinhard
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 25.08.08 18:00 
:lol: Ich glaube du hast mich da ein bisschen falsch verstanden.. OK ich habe mich da auch missverständlich ausgedrückt.
Gemeint sind die Kind-Klasse und nicht irgendwelche Kinder :lol:

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 25.08.08 19:26 
user profile iconmatze hat folgendes geschrieben:
Gemeint sind die Kind-Klasse und nicht irgendwelche Kinder :lol:

*Sich weg schmeißt* Ich hatte mir schon gemerkt: 'Ah, Lehrer ist der' :lol:

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 25.08.08 20:03 
Kurze Frage; warum schreibst du abstrakte Funktionen in den Classes?
Wäre es nicht günstiger ein oder mehrere Interfaces zu deklarieren und deine Child-Classes (nicht das es wieder zu missverständnissen führt :-) ) sich davon ableiten bzw. diese implementieren?

Das Interface deklarierst du doch nur einmal und deine Klassen erben nicht nur den Vorfahr sondern implementieren
auch die Interfacefunktionen.

:-)msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 25.08.08 21:57 
Das läuft ja auf das gleiche Problem hinaus.
Wenn ich eine neue Klasse habe, die von einem Interface die Funktionen erbt, dann muss diese Funktionen im Interface-Abschnitt per Hand eintippen. Und das können, je nach Modell, recht viele sein.
Und genau das will ich nicht. Ich möchte eine Funktion haben, dass wenn ich eine Klasse erstelle die irgendwas erbt (sei es von einer Super-Klasse oder von einem Interface) diese Funktionsrümpfe automatisch in den Quelltext geschrieben werden.

Zum Verständnis:
Ich habe folgende Super-Klasse: (könnte auch ein Interface sein)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TBasis = class(TObject)
  published
    procedure tuwas(i: integer); virtualabstract;
  end;


Dann möchte ich irgendwo klicken und sagen: "Leite mir von TBasis eine neue Klasse TExtendedBasis ab" und das Programm erstellt mir das:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
type
  TExtendedBasis = class(TBasis)
  published
    procedure tuwas(i: integer); override;
  end;

{...}

implementation

procedure TExtendedBasis.tuwas(i: integer);
begin
   inherited;
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 10.09.08 15:36 
So, mal eine kurze Zwischenmeldung ;-).
Ich bin mittlerweile wieder da, hatte auch etwas Zeit, und habe mich da drangesetzt.
Ergebnis ist, dass es soweit zu funktionieren scheint, es wird der Quelltext geparst (mit einem Open Source Parser) und dann von mir so zusammengesetzt, dass das Gerüst steht. Im Moment gibt es bei manchen Dateien noch Probleme, das habe ich aber bald soweit.

Was ich dann noch machen möchte ist, dass man standardmäßig die Liste der Klassen der aktuellen Datei im Editor bekommt (funktioniert), dann aber auch eine andere offene Unit und eine dortige Klasse auswählen kann und auch eine bestimmte offene Unit als Ziel angeben kann.

Das dauert noch ein paar Tage, je nachdem wieviel Zeit ich habe, aber es sieht soweit gut aus ;-).

Was ich danach dann noch überlege ist, ob ich es auch hinbekomme die Units aus den uses-Klauseln mit zu benutzen. Die müssen ja für das Projekt auch verfügbar sein (ich müsste die also auch nutzen können). Aber das kommt dann, wenn der Rest fertig ist.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 11.09.08 09:04 
Wow. Das hört sich ja schon gut an. Man darf also gespannt bleiben...

_________________
In the beginning was the word.
And the word was content-type: text/plain.