![]() |
code smell
Bei uns werden viele Forms in der Datenbank gespeichert, damit Kundenspezifische Anpassungen leicht möglich sind.
Beim auslesen aus der Datenbank hat es eine stelle die für mich einfach nach schlechtem Design aussieht.. Ein sehr grosser Block von If-Abfragen(für jede Komponente die verwendet werden kann ...):
Delphi-Quellcode:
Weiss jemand, wie man dies schöner gestalten könnte bzw. ein sinnvolles DesignPattern? :)
if c = 'TLabel' then control := NewLabel;
if c = 'TMyEdit' then control := NewEdit; if c = 'TMyMemo' then control := NewMemo; if c = 'TButton' then control := NewButton; if c = 'TMyButton' then control := NewButton; if c = 'TMyCheckBox' then control := NewCheckBox; if c = 'TRadioButton' then control := NewRadioButton; if c = 'TListBox' then control := NewListBox; //...usw. |
AW: code smell
Nutze doch den Weg der VCL, wenn sie die VCL-Formulare (DFMs) läd.
- am Anfang alles Nötige via ![]() ![]() - dann statt deiner IFs nur noch ein ![]() - und am Ende das ![]() ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz