Re: null terminated strings



Karsten Nyblad wrote:
Dave Froble wrote:

Karsten Nyblad wrote:

Dave Froble wrote:

I'm in the minority on this issue. I'm aware of that. Most of my career has been writing new stuff, and most of the maintenance is on stuff I wrote. Not declaring variables hasn't been a large problem for me. That said, I'll agree that it's safer, and better in many instances.

When using local temporary variables, it is nice to not have to declare such.




Even a programmer with a poor typewriting does not use that much time typing the code his writes. The programmer uses much more time for reading, debugging, and understanding the code. Thus languages should make code readable, easy to understand, and as many errors should be caught before debugging. Say your finger slips, such that you get a new implicitly declare variable. It will take you much longer time finding that bug with a debugger than if it is reported by the compiler.



Well, it can be caught by the compiler. I have utilities that will parse the /LIST output of the compiler, and report on variables that are referenced only once. I can then check out such, and determine whether it's a typo, or something brought in with some boiler-plate sections of code.


Well, then you had better not make the same typo twice. Being bad at spelling I could easily make the same spelling error twice. I have a hunch that writing and using that utility has taken you a sizable fraction of the time you have save not writing declarations.

I have been very successful without declaring variables. You may have different experiences.

Further, you will have to use more time for proofreading your code, because you have to look for faulty typings.



Proof reading your code is a bad thing ??????????


Certainly not, but proofreading to find errors that could be found automatically is a waste of resources. And you can look for only so many different types of errors at a time.

At last it will not be as easy to maintain, because later programmers

will have more problems finding out how and for what purpose variables are used.


When very descriptive variable names are used, this is less of a problem.

> Further, declaring an obscure name for a variable is no help to later

programmers. This is a red herring. The declaration of a variable is

> of no help in determining what a variable is used for.

All programmers have their own way of writing very descriptive variable names. Unfortunately what is very descriptive to one programmer may not be it to an other. Thus the variables and their use should still be documented. The declaration is an appropiate place for a comment doing that.

So now I need to declare a variable, and document it's use? As I said, I know I have the minority opinion, but I have been successful with it.

Is there no room for more than one style, or should we all don jackboots and all march to the same tune?

And if all variables are declared then you know that you can find the declaration. You will not search for a variable's declartion that is not there or worse: Search for a declaration that is there, but you fail to find it and think the variable is not declared.


--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: davef@xxxxxxxxxxxxx
170 Grimplin Road
Vanderbilt, PA 15486
.



Relevant Pages

  • Re: True Name Spaces, when?
    ... explicitly doing a forward declare for types in other units. ... I do not think that the programmer should do the job of the compiler. ... Either the first or the second pass would have to perform the syntax check: Programmers don't magically avoid typos just because the compiler is two-pass. ...
    (borland.public.delphi.non-technical)
  • Re: Java most wanted: Non-null variables
    ... You might never store nulls, and declare it as such, but the ... idea would be that the programmer could tell the compiler that ... One option that the programmer would ... might be false if the programmer abuses constructors. ...
    (comp.lang.java.programmer)
  • Re: simple example
    ... Here you just declare a x member belonging to the Foo class. ... - if you try to use the same name at the same level, the compiler will choke ... Error 1 A local variable named 'x' cannot be declared in this scope ... The second one is writing 1 but how can the compiler know that I don't ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why in stdint.h have both least and fast integer types?
    ... Why would just asking the compiler to ... >>as a programmer I want the following control, ... As such it may inhibit code optimisation rather ... that are at least 16-bits so I declare a bunch of integers at least as big ...
    (comp.lang.c)
  • Re: recursive classes
    ... Before writing this post I must declare that this problem is part of a ... The two classes represent entities that have preferences over one ... allowed to express indifference in their preferences; ...
    (comp.lang.java.programmer)

Loading