[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Defining variables in a local scope.

  • Thread starter Thread starter Patrick Tingen
  • Start date Start date
Status
Not open for further replies.
P

Patrick Tingen

Guest
I like my variables' scope to be as small as possible and I define them at the beginning of where the scope starts. Defining them in the middle of the scope, like in the example above, might give new programmers the idea that the variable is scoped to the loop, which it isn't. I think you should program to get the least number of WTF's in your code and defining variables halfway the code does not help IMO. If you have code blocks that are 5000 lines of code, then they are about 4900 lines too long. Recently I modified some of these monsters to become more manageable, and I found that taking small parts out of the code and moving them to their own internal procedure / function / external procedure greatly helps in keeping the code clear. It also greatly reduces the need for variables, because often you don't need anything more than the output parameters of your procedure. This week I split up a large save-routine. It did a lot of checks to see whether the record could be saved. I moved all checks to individual procedures, even when they were only 5-10 lines of code. This keeps it clear and simple.

Continue reading...
 
Status
Not open for further replies.
Back
Top