- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
C-pound and Java cannot be compared to languages like Python and Ruby because they're designed for the less smart corporate slaves.
Admin
A common example is vector::at:
vector<int> i(1);
i.at(0) = 5;
Admin
C-tic-tac-toe
Admin
C-grid or C-needlepoint-canbas would also work.
Admin
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.
Admin
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.
Admin
Yeah, right. Because a certain, limited kind of operator overloading is the most important feature any programming language has ever had.
You have apparently not the faintest idea what OO programming actually means.
Admin
I'm not a C++ programmer, but I started thinking "What if the function yielded a pointer..." so I was on the right track. :)
Admin
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.
Admin
"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.
Admin
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
Admin
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
Admin
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
Admin
That got added to C# in 2.0.
Admin
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.
Admin
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.
Admin
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?
Admin
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.
Admin
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.
Admin
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.
Admin
Hmm,
maybe i should read the entire thread before i post next time..
Sorry for the double
Admin
:D
It took me some time to get it, but I laughed so hard!
Admin
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.
Admin
Clearly the world's greatest coder could just solve the Halting Problem so that he never had this problem again! :-)
Admin
C-Pound??? You fool, it's C-Octothorpe.
Admin
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