Difference between revisions of "DoDont/de"

From Free Pascal wiki
Jump to navigationJump to search
Line 8: Line 8:
 
== Right ==
 
== Right ==
  
#Use checks (Range, IO, Overflow) when developing. You can enable them with "-Crio" compiler switch.
+
# Verwende während der Entwicklung die Bereichsüberprüfungen des Compilers (Bereich, IO, Überlauf). Compilerschalter "-Crio"
#Use heaptrace from time to time to see if you have any memory leaks. Enable via "-ghl" compiler switch to get best result.
+
# Verwende von Zeit zu Zeit heaptrace, um zu sehen, ob Sie irgendwelche Speicherlecks haben. Compilerschalter "-ghl"
#Split huge [[Glossary#Unit|units]]. Big units are ALMOST ALWAYS a sign of bad design or logic. (you know it's bad when you have unrelated constructs in one unit).
+
# Teile grosse Units in mehrere kleinere Units auf. Grosse Unist sind fast immer ein Zeichen von schlechtem Programmdesign.
#Split huge [[Function|functions]] / [[Procedure|procedures]] / [[Method|methods]]. Big functions/procedures/methods are sign of bad design or logic.  A good rule of thumb is to have no function, procedure or method longer than one printed page (about 55 lines) or, even better, one screen if you can. What you can visualize in one screen (or on one printed page, if you use printed listings) you can probably understand better than what you can't see or have to flip from page to page to read.
+
# Versehen sie Ihre Variablen und Unterprogramme mit sprechenden Namen. Verfolgen Sie bei der Namensgebung konsequent einen einheitlichen Stil.
#Name your variables/functions properly lest you will damn yourself with unmaintainable code. Be consistent in how you do things.
+
# Es ist allgemein üblich für die Namen der Identifier sinnvolle Namen zu verwenden
#It is commonplace to use meaningful identifier names. While every languages advises this, it is way more common in practice in Pascal.  However, the variable names I, J and K are commonly used as general purpose FOR control variables and similar usage for loop counters, especially where the loop is only being used to initialize or display members of arrays. Loop variables must be local anyway.
+
# Verwenden Sie bei den Variablennnamen soetwas wie die "ungarische Notation" (ein Präfix zeigt an, um welchen Datentyp es sich handelt.)
#Hungarian notation ( a "prefix code" to indicate what the type of a variable is) is frowned upon (Pascal has strong enough typing). Except maybe for components on a Lazarus form. e.g. edsomething for an edit field and labsomething for the corresponding label etc
+
# Arbeiten Sie beim codieren mit Einrückungen. Dies macht den Code lesbarer und verständlicher.
#Stick with one identation style. Change only if you hadn't followed a standard style till then.
+
# Die einzig wahre Programmiersprache für Ihre Arbeit ist Pascal.
#The only right language for the job is the one you started the work with. And that's [[Pascal]]!
 
  
 
== Wrong ==
 
== Wrong ==

Revision as of 19:11, 10 September 2013

Deutsch (de) English (en) français (fr)

Die richtige und die falsche Art mit Pascal zu programmieren

Das sind alles selbst erarbeitete Hinweise zur Programmierung. Ich habe die richtige und die unrichtige Art der Programmierung auf die harte Tour gelernt, und zwar, indem ich die falschen Dinge zu erst gemacht habe.

Right

  1. Verwende während der Entwicklung die Bereichsüberprüfungen des Compilers (Bereich, IO, Überlauf). Compilerschalter "-Crio"
  2. Verwende von Zeit zu Zeit heaptrace, um zu sehen, ob Sie irgendwelche Speicherlecks haben. Compilerschalter "-ghl"
  3. Teile grosse Units in mehrere kleinere Units auf. Grosse Unist sind fast immer ein Zeichen von schlechtem Programmdesign.
  4. Versehen sie Ihre Variablen und Unterprogramme mit sprechenden Namen. Verfolgen Sie bei der Namensgebung konsequent einen einheitlichen Stil.
  5. Es ist allgemein üblich für die Namen der Identifier sinnvolle Namen zu verwenden
  6. Verwenden Sie bei den Variablennnamen soetwas wie die "ungarische Notation" (ein Präfix zeigt an, um welchen Datentyp es sich handelt.)
  7. Arbeiten Sie beim codieren mit Einrückungen. Dies macht den Code lesbarer und verständlicher.
  8. Die einzig wahre Programmiersprache für Ihre Arbeit ist Pascal.

Wrong

  1. Put all points from Right section here and negate them.
  2. Have doubts in Pascal.
  3. NEVER use -Ct (stack check) in Win32 with threads! There's a "feature" which can be a problem.
  4. Don't name your arguments with names of fields. Even if they are private ie: FField and Field in argument.