• ger bil (unregistered) in reply to masklinn
    masklinn:
    WTF, C#'s properties are one of the most useless implementations of these.

    (and you should check Ruby's implementation and usage of properties to see what a proper implementation of properties and a language built upon them looks like)

    Well its still heck of a lot better than retarding everything with setThis getThat.. :)

    C-pound and Java cannot be compared to languages like Python and Ruby because they're designed for the less smart corporate slaves.

  • Evan (unregistered) in reply to Maurits

    A common example is vector::at:

    vector<int> i(1);
    i.at(0)  = 5;

  • (cs) in reply to creaothceann

    Anonymous:
    brazzy:
    sao:
    And who do you think you are, we ALL know its C-HASH. # == HASH. i like hash.


    Bah. For me, it's C-Dingsda or, in English, C-Thingamabob.

    Let's call it C-XXO. ^_^

    C-tic-tac-toe

  • (cs) in reply to Rank Amateur
    Rank Amateur:

    Anonymous:
    brazzy:
    sao:
    And who do you think you are, we ALL know its C-HASH. # == HASH. i like hash.


    Bah. For me, it's C-Dingsda or, in English, C-Thingamabob.

    Let's call it C-XXO. ^_^

    C-tic-tac-toe



    C-grid or C-needlepoint-canbas would also work.
  • (cs) in reply to rogthefrog

    That would be "C-needlepoint-canvas", of course, but

    THE REAL WTF HERE IS THIS FORUM SOFTWARE THAT DOESN'T LET YOU EDIT POSTS

    Whew. I had to get it off my chest. It's been so long without that kind of post.

  • (cs) in reply to Xepol
    Xepol:
    Ultimately, for me the WTF is why people keep perpetuating case-sensitive languages.  You've been taught all your life that A and a are the same symbol.


    YEAH RIGHT! THERE'S NO DIFFERENCE AT ALL AND I REALLY DON'T SEE WHY SO MANY PEOPLE SEEM TO BE HUNG UP ABOUT IT.
  • (cs) in reply to KG
    Anonymous:
    One of the most massive benefits of the .net languages, which sets them far apart of java or other languages, is exactly the ability you call stupid.... real, native, properties.


    Yeah, right. Because a certain, limited kind of operator overloading is the most important  feature any programming language has ever had.

    Anonymous:

    Just becuase no one was able to implement it properly in the past, doesn't make it bad.  It's actually quite practical, given that OO programming is based entirely around properties, shouldn't we have them?


    You have apparently not the faintest idea what OO programming actually means.

  • (cs) in reply to Maurits
    Maurits:
    Raven:
    Well.. I'm no C++ expert but he might be right about this thing would never happen in C++.
    What compiler would (or should) accept something like:

    somefunction() = variable;



    See "Using a Function Call as an Lvalue"
    http://www.devx.com/tips/Tip/29288?trk=DXRSS_recentTips


    I'm not a C++ programmer, but I started thinking "What if the function yielded a pointer..." so I was on the right track. :)
  • Nimrand (unregistered) in reply to larsrc

    larsrc:

    I tend to agree here, but of course that is a language design decision.  I have changed from liking to disliking operator overloading, especially of the very basic operators like '='.  While abstracting out complexity, hiding it so utterly that you can't tell how long basic operations will take (constant, O(n^K), infinite recursion) is an invitation for subtle bugs and misdesigns.  IMHO, '=' should assign the value and nothing else, if you want to do fancy things in the setters and getters, use proper methods so recursion like this is visible.

    Actually, property getters/settings are supposed to be constant operations, or at least close.  You can use properties to do simple validations of data, to calculate properties derived from multiple fields, perform logging or debugging services, or set flags to indicate something needs to be updated when a certain method is called.  But, if you are doing anything very complicated that could take a significant amount of processing time, especially if called multiple times, a method should be used instead to indicate to the consumer of the class using that getter or setter could be expensive.  This is exactly what Microsoft recommends in their class design guidelines for .NET.  Of couse, no one has to follow those rules, but, almost any language feature can be broken.

  • (cs) in reply to brazzy

    "OO is based entirely around properties"?

    No, OO is based entirely around object behaviour. Whatever the language, OO is about message passing. Getters and setters should only ever be concessions to pragmatism.

  • Patrioct (unregistered) in reply to Hans Hammer

    Anonymous:
    Maybe this guy should have tried debugging his work before opening his mouth.  (It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt. -- Mark Twain)

    It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt.

     you fucker.. abe lincon said that shit, not mr twain

     

  • (cs) in reply to Patrioct
    Anonymous:

    It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt.

     you fucker.. abe lincon said that shit, not mr twain


    Any credible sources to back that up, moron? Because all that I have found indeed attribute it to Twain:

    http://en.thinkexist.com/quotation/it_is_better_to_keep_your_mouth_closed_and_let/215886.html
    http://www.quotationspage.com/quote/369.html
    http://www.mtwain.com/l_quotes.html

  • (cs) in reply to Maurits
    Maurits:
    Raven:
    Well.. I'm no C++ expert but he might be right about this thing would never happen in C++.
    What compiler would (or should) accept something like:

    somefunction() = variable;



    See "Using a Function Call as an Lvalue"
    http://www.devx.com/tips/Tip/29288?trk=DXRSS_recentTips


    Also, some dialects of BASIC allow the substring functions to be L-values though the dialects do not have pointers.  e.g.
    <font size="2">   a$="123456789"
       mid$(a$,5,3)="ABC"
       print a$
    </font>outputs
    <font size="2">   1234ABC89</font>

    Sincerely,

    Gene Wirchenko

  • Bill Wert (unregistered) in reply to RevMike

    RevMike:
    Anonymous:
    One of the most massive benefits of the .net languages, which sets them far apart of java or other languages, is exactly the ability you call stupid.... real, native, properties.

    Just becuase no one was able to implement it properly in the past, doesn't make it bad.  It's actually quite practical, given that OO programming is based entirely around properties, shouldn't we have them?


    Yeah.  I want the ability to set the visibility of a property differently for read and write operations.  I should be able to make a value public read but private (or protected, or package) write.  Then I won't need all those silly getters but still can protect the change of a value with a method call.

     

    That got added to C# in 2.0.

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    A bit of redundancy there: aren't all "best" coders self-proclaimed.


    No. <font color="brown">Tomek Czajka</font> may actually be the best, competetively at least.  Ranked #3 on TopCoder[/url and #2 on [url=http://spoj.sphere.pl/users/tomek/]SPOJ.
  • (cs) in reply to Sparr
    Sparr:
    Gene Wirchenko:
    A bit of redundancy there: aren't all "best" coders self-proclaimed.


    No. <font color="brown">Tomek Czajka</font> may actually be the best, competetively at least.  Ranked #3 on TopCoder[/url and #2 on [url=http://spoj.sphere.pl/users/tomek/]SPOJ.


    Before we declare someone the "best coder", we should determine the requirements.
    Competitive coding is a nice sport and intellectual challenge, but the results have to be interpreted within the context. Just like Michael Schumacher was the fastest guy on the race track, but maybe not the best taxi driver.
  • (cs) in reply to brazzy
    brazzy:
    Anonymous:

    It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt.

     you fucker.. abe lincon said that shit, not mr twain


    Any credible sources to back that up, moron? Because all that I have found indeed attribute it to Twain:

    http://en.thinkexist.com/quotation/it_is_better_to_keep_your_mouth_closed_and_let/215886.html
    http://www.quotationspage.com/quote/369.html
    http://www.mtwain.com/l_quotes.html



    As a rule, many comments attributed to Mark Twain or Ben Franklin were actually said by someone else first.   However because those figures are so ingrained in out culture (US anyway), and they would say that type of thing (and perhaps did repeat it); that even credible sources often get it it wrong.    Clearing the waters at this time is extremely difficult, or even impossible.  

    I would not be surprised if he was correct, and yet unable to find a credible source.   He could of course be wrong, Mark Twain did make many remarks of that sort, or the saying might be older yet.

    The real question is: is this important enough to spend significant time researching?
  • Nancy (unregistered) in reply to Ytram

    Ytram:
    [quote user="Anonymous"
    Depends.  If you want subclasses to be able to access/override the member directly, then it should be protected.  If not, then private.

    Uhm, that's the whole point of the property.  If the variable changes in the derived class you dont have a good way to debug why. 

  • smelliot (unregistered)

    about a half second in the debugger and your Jr dev figures this out. The smarter ones will hit this twice and instantly recognize it from then on.

    The dumber ones sit there wondering wtf a stack overflow is... poor guys.

  • (cs) in reply to christoofar

    Underscores are not done in C#, just like field prefixes.

    Check this:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcapitalizationstyles.asp

    It is used in C++ though.

  • (cs) in reply to koedoot

    Hmm,

    maybe i should read the entire thread before i post next time..

    Sorry for the double

  • lifeforms (unregistered)

    :D

    It took me some time to get it, but I laughed so hard!

  • (cs) in reply to KG
    Anonymous:
    One of the most massive benefits of the .net languages, which sets them far apart of java or other languages, is exactly the ability you call stupid.... real, native, properties.

    Just becuase no one was able to implement it properly in the past, doesn't make it bad.  It's actually quite practical, given that OO programming is based entirely around properties, shouldn't we have them?


    Despite what some people (not just Microsoft, but they're the most egregious about it) might claim, no. Accessor and mutators are a workaround used to avoid certain weaknesses of strict OOP.

    The whole point of OO design is to treat the objects as if they were actual, real world items - it's all about simulation, in other words. As far as the client programmer is concerned, the instance variables don't exist - they are implementation details that only the object needs to know about. Properly speaking, the only interface for an object is in message passing - which is to say, asking it to do something.

    The problem is, this can make doing certain things with program objects - especially the more abstract ones, such as collections - difficult. Getters and setters are a way to get around this without breaking paradigm completely. However, it still is not strictly speaking OO, as in most of the cases it represents an action that the object shouldn't need to do or be able to do.

    To give a concrete example, if you needed to know a person's pulse, you can't just ask them for it and expect them to simply look it up in their instances. Either you or they need to sit down and take their pulse, or listen to their heartbeat with a stethoscope, and count the beats for a certain length of time. You certainly can't expect the to be able to 'set' their pulse rate on request, unless their a yogi or a scanner from the old Cordwainer Smith stories. It simply isn't realistic to expect that. Yet that is in effect the sort of thing that accessors and mutators are: they can observe things and change things that are reasonable to be able to view and change. They exist because it is nonetheless often necessary to do so in real-world programming.

    IMAO, if you are using a lot of accessor and mutators that don't represent plausible actions on the part of the objects - ones which could be given a different name, such as replacing setSpeed() with accelerate() - then you probably shouldn't be using OO as your primary paradigm. Every paradigm has a rather limited range of areas in which it is useful (except procedural, which is equally mediocre for all things), and trying to apply one to all problems is counter-productive.
  • kjw (unregistered) in reply to Schol-R-LEA

    Clearly the world's greatest coder could just solve the Halting Problem so that he never had this problem again! :-)

  • Real Programmer (unregistered) in reply to frosty
    frosty:
    haveworld:
    Waiting for someone to comment on what's wrong with the code.

    So am I.  I don't know .Net or C-Pound.

    C-Pound??? You fool, it's C-Octothorpe.

  • Real Programmer (unregistered) in reply to hank miller
    hank miller:
    brazzy:
    Anonymous:
    It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt.  you fucker.. abe lincon said that shit, not mr twain

    Any credible sources to back that up, moron? Because all that I have found indeed attribute it to Twain:

    http://en.thinkexist.com/quotation/it_is_better_to_keep_your_mouth_closed_and_let/215886.html http://www.quotationspage.com/quote/369.html http://www.mtwain.com/l_quotes.html

    As a rule, many comments attributed to Mark Twain or Ben Franklin were actually said by someone else first.   However because those figures are so ingrained in out culture (US anyway), and they would say that type of thing (and perhaps did repeat it); that even credible sources often get it it wrong.    Clearing the waters at this time is extremely difficult, or even impossible.  

    I would not be surprised if he was correct, and yet unable to find a credible source.   He could of course be wrong, Mark Twain did make many remarks of that sort, or the saying might be older yet.

    The real question is: is this important enough to spend significant time researching?

    I have an older reference:

    Proverbs 17:28 Even a fool, when he keeps silent, is considered wise;When he closes his lips, he is considered prudent

Leave a comment on “Buggy.NET”

Log In or post as a guest

Replying to comment #:

« Return to Article