Easy Syntax Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Skeet [C# MVP]

    #16
    Re: Easy Syntax Question

    Bruce Wood <brucewood@cana da.com> wrote:

    <snip>
    [color=blue]
    > If you work in a C#-only (or C-only or C++-only) shop, then I see no
    > problem with the ternary operator. In my work environment, however,
    > it's just one more mysterious C-ism that the other poor sods around me
    > have to cope with, so I avoid it wherever I can.[/color]

    My problem with that approach is - how far do you take it? Do you
    assume that they don't know that && and || are shortcircuiting , too? Do
    you assume they don't know default access modifiers? Do you assume they
    don't know default variable values? What about the using/lock
    statements, which will confuse C/C++ programmers if they don't know C#?
    I think sooner or later you have to assume that your co-workers have a
    working knowledge of the language.

    My view is that if something is somewhat onerous to remember (like
    exact precedence rules) then it helps to make it more explicit. If it's
    easy to foul up even with experience (like using single statement "if"s
    with no braces) then it helps to make it more explicit.

    If it's a simple language construct which is easy to explain once and
    then ask people to remember, I don't see what's wrong with it. Of
    course, you have to also have an environment where people are happy to
    ask if they don't understand something, and have enough people with
    good knowledge (or the ability to find something in a language spec) to
    help them if they get stuck.

    As a side issue, what does the VB code in your work environment look
    like? There's so much *language* to learn in VB in the first place, if
    everything has to be understandable to everyone, I don't see how it can
    work...

    --
    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

    • Bruce Wood

      #17
      Re: Easy Syntax Question

      Good points, all. I guess this is just baggage from other programming
      jobs, back when I was programming in C and everything was relatively
      straightforward . Back then I avoided the ternary operator, assignments
      inside conditions, and other unnecessary C-isms out of respect for the
      other programmers around me.

      Now that, as you point out, there are far bigger fish to fry in C#, my
      prejudice against the ternary operator is probably outdated. After all
      those years trying to write clearer code, though, it just looks ugly to
      me, so I guess it's devolved into an aesthetics thing. :-)

      Comment

      Working...