case sensitivity

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff S

    #1

    case sensitivity

    I'm getting started with C# and was just wondering if C# veterans LIKE the
    fact that the language is case sensitive. If so, how is case sensitivity
    helpful? Do you create multiple variables, functions, and objects with
    identical names that differ only in case?

    Really wondering....

    Jeff


  • Ayende Rahien

    #2
    Re: case sensitivity


    "Jeff S" <JeffJeff@asdf. com> wrote in message
    news:OP5dp73uDH A.1996@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I'm getting started with C# and was just wondering if C# veterans LIKE the
    > fact that the language is case sensitive.[/color]

    I do.
    [color=blue]
    > If so, how is case sensitivity
    > helpful? Do you create multiple variables, functions, and objects with
    > identical names that differ only in case?[/color]

    I don't, I really don't!


    You've to understand that the fact that the language is case sensitive help
    to trap errors as they occur, and the ability to visually recognize a
    variable just by its consistent casing (How do I seperate XmlDocument &
    XmlNavigator, I read the upper case letters and in 99% it allows me to know
    what class is being used.
    Just think of the resulting code:

    XmlWrTier xNoCAsEisFUN = nEw xMLWRitER("foo. xml");
    XnOCAseISFuN.Wr ite();

    This is an exteme example, but anything that helps is good.
    And no good-coding-style manual will help you if the compiler isn't
    enforcing this.


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: case sensitivity

      Jeff S <JeffJeff@asdf. com> wrote:[color=blue]
      > I'm getting started with C# and was just wondering if C# veterans LIKE the
      > fact that the language is case sensitive.[/color]

      I do.
      [color=blue]
      > If so, how is case sensitivity
      > helpful? Do you create multiple variables, functions, and objects with
      > identical names that differ only in case?[/color]

      I often have a property and a variable which have the same name but
      differ in case:

      int count;
      public int Count
      {
      get
      {
      return count;
      }
      }

      etc.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Daniel O'Connell

        #4
        Re: case sensitivity

        In most cases, I find it useful to not have to qualify members, like
        properties, when I have a parameter or local of the same name. It is also
        just very inbred, case sensitivity should be there(as all C based langauges
        are case senstive, including java), its just how it works.
        I also tend to do things like
        public string Name
        {
        get
        {
        return name;
        }
        }
        string name;

        for properties.
        "Jeff S" <JeffJeff@asdf. com> wrote in message
        news:OP5dp73uDH A.1996@TK2MSFTN GP12.phx.gbl...[color=blue]
        > I'm getting started with C# and was just wondering if C# veterans LIKE the
        > fact that the language is case sensitive. If so, how is case sensitivity
        > helpful? Do you create multiple variables, functions, and objects with
        > identical names that differ only in case?
        >
        > Really wondering....
        >
        > Jeff
        >
        >[/color]


        Comment

        • Shawn B.

          #5
          Re: case sensitivity

          I don't particularily like that it is case-sensitive but I don't not like
          it, either. The fact that it is case sensetive is simply just how it is
          built. Sometimes it's daunting to remember to always type in the correct
          case (when you type very fast by the time it registers in your brain that
          there was a typo (I always know because it "felt" wrong when I typed it) I'm
          already 15 characters ahead and have to backspace or arrow-key back to it
          and it breaks the flow).

          In VB I have mixed case but when I reference them I type in small case and
          if it automatically corrects the case-sensitity I know I typed it in
          correctly. I suppose C# will tell you also.

          Where it is useful (albeit perhaps confusing) in C# is when I have a public
          member mixed case and a local/private member small case. I never ever ever
          use a small case type as a public referencable/usable
          method/variable/object. But in some projects it can be confusing. In VB I
          prepend an underscore if it is private or local. In C#, I don't have to, I
          juse make 'em all small letters.

          Yes... I do:

          public class X {
          private string name;

          public string Name {
          get() { return name; }
          set() { name = value; }
          }
          }

          I suppose that illustrates a simple example of the concept. At least, if
          I'm consistant I'll never get lost in the code (even 13 months later -- I
          know, I'm at that point). But we have other developers here and no standard
          and it'll throw them off or you off but for the most part, everyone here is
          adaptable and there have never been problems because of this, only because
          of lack of code re-use but that's another thread topic.


          Thanks,
          Shawn


          "Jeff S" <JeffJeff@asdf. com> wrote in message
          news:OP5dp73uDH A.1996@TK2MSFTN GP12.phx.gbl...[color=blue]
          > I'm getting started with C# and was just wondering if C# veterans LIKE the
          > fact that the language is case sensitive. If so, how is case sensitivity
          > helpful? Do you create multiple variables, functions, and objects with
          > identical names that differ only in case?
          >
          > Really wondering....
          >
          > Jeff
          >
          >[/color]


          Comment

          • Ayende Rahien

            #6
            Re: case sensitivity


            "Shawn B." <leabre@html.co m> wrote in message
            news:%23vQLvi4u DHA.2360@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > I don't particularily like that it is case-sensitive but I don't not like
            > it, either. The fact that it is case sensetive is simply just how it is
            > built. Sometimes it's daunting to remember to always type in the correct
            > case (when you type very fast by the time it registers in your brain that
            > there was a typo (I always know because it "felt" wrong when I typed it)[/color]
            I'm[color=blue]
            > already 15 characters ahead and have to backspace or arrow-key back to it
            > and it breaks the flow).[/color]

            Alt+Space is your friend, if you've 15 letter vars, then IntelliSense is
            sure to get the right one.



            Comment

            Working...