AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Delphi-PRAXiS - Lounge Delphi-News aus aller Welt Delphi Tip of the Day: Use Your Own Unique Prefix for Types and Constants
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi Tip of the Day: Use Your Own Unique Prefix for Types and Constants

Ein Thema von DP News-Robot · begonnen am 20. Dez 2023
Antwort Antwort
Benutzerbild von DP News-Robot
DP News-Robot

Registriert seit: 4. Jun 2010
15.473 Beiträge
 
#1

Delphi Tip of the Day: Use Your Own Unique Prefix for Types and Constants

  Alt 20. Dez 2023, 12:30
I'm in the process of converting an old Delphi 5 VCL application to Delphi 11 FMX. Yeah, I have Delphi 12 but I'm waiting for the first bug release before I start using it. Well, this morning I learned a valuable lesson. A lesson which stopped me dead in my tracks.

There's nothing stopping you from creating an already existing type!


I was making some refactoring changes to my code. I didn't realize I was about to make a huge mistake. I went plodding ahead pleased with the progress I was making and admiring the beautiful, refactored code I was creating. When boom... I renamed a type that stepped on a type already inside the System.UITypes unit.

There's nothing to stop you from creating an already existing type. Of course I didn't use the preview changes function. I just hit go!

I had defined my own enumerated type called TMyImageIndex. I decided to just simply call it TImageIndex. So, that's what I did using Refactor > Rename type TMyImageIndex CTRL+SHIFT+E

I knew I messed up when I saw way too much code show up in the results panel.

How dare Embarcadero define a type called TImageIndex


WTF. If it already existed the IDE should have prevented me or at least warned me. How dare Embarcadero define a type called TImageIndex.

type //TImageIndex = (iiAdd = 2, iiUpdate = 3);) TZwImageIndex = (iiAdd = 2, iiUpdate = 3);) const ZW_WIDTH_COLUMN_GLYPH = 20; ZW_WIDTH_COLUMN_DATE = 90; ZW_WIDTH_COLUMN_AMOUNT = 74 It took me about 30 minutes, but I was able to get the original code back in place, And working.

So going forward I have created my own unique prefix of TZw (Zw = ZilchWorks). Going forward I will preface all Types and Constants.

Enjoy!
Semper Fi
Gunny Mike
https://zilchworks.com



Weiterlesen...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz