Stack Overflow
-
" Then, we'll agree to dissagree In my book, something that is really a method should look like a method, not like a member variable. " Not at all, detail hiding is a basic OOP principle.
PIEBALDconsult wrote:
detail hiding is a basic OOP principle.
:) Sure, as long as the "details" are not hidden so well that you mix them up and end up with a stack overflow.
-
I had a problem with a web application killing the dev server built in to VS2005 with stack overflow errors and I couldn't find the problem. I went so far as finding every for, foreach, and while loop and putting a counter in them that would throw an exception with the method name in the message if it looped over 1000 times (which none of the loops should do in this app). The problem all came down to one capitalization error that I didn't see even though I went step by step through execution with the debugger...
public string Name
{
get { return this.Name; }
}
private string name;Obviously the "this.Name" in the property should be "this.name". I felt like a moron when it was over.
Been there, done that. :) It's strange how people immediately blame the use of properties, or the case sensetivity of the language. It's like everyone is running around with a protest sign, just looking for a good spot where they can stand and wave it... ;) I have used the wrong name just like this a few times, and every time it was because I was using intellisense and chose the wrong item. Is the conclusion then that intellisense should be banned? Of course not. If everything in a programming environment that could possible be used in the wrong way should be removed, then we'd be back at writing code on punch cards...
--- b { font-weight: normal; }
-
David Kentley wrote:
I have yet to hear a compelling argument against my stance.
Which one?
David Kentley wrote:
case sensitivity in any language or OS was a colossal mistake.
Disagree. Readability. Nothing worse than reading VB where the author changes case but is referring to the same entity. Well there are plenty of things worse than that like Iraq but you get the idea.
David Kentley wrote:
having variable/property names vary only by capitalization is also making a big mistake
Yes any name. Even by one character is not advisable. CMyClass and CMyClassa
led mike
led mike wrote:
Disagree. Readability. Nothing worse than reading VB where the author changes case but is referring to the same entity.
I believe the only reason this is a problem is because you are used to case sensitivity in other languages. I agree that it would be bad style to change capitalization all over, and maybe some pseudo case sensitivity would be ok (i.e. the compiler would complain if a variable defined as theVariable was referenced as TheVariable, but wouldn't allow both names to be declared).
led mike wrote:
Well there are plenty of things worse than that like Iraq but you get the idea.
Well, just think, if Steve Jobs ran Iraq it would be called iRaq.
-
led mike wrote:
Disagree. Readability. Nothing worse than reading VB where the author changes case but is referring to the same entity.
I believe the only reason this is a problem is because you are used to case sensitivity in other languages. I agree that it would be bad style to change capitalization all over, and maybe some pseudo case sensitivity would be ok (i.e. the compiler would complain if a variable defined as theVariable was referenced as TheVariable, but wouldn't allow both names to be declared).
led mike wrote:
Well there are plenty of things worse than that like Iraq but you get the idea.
Well, just think, if Steve Jobs ran Iraq it would be called iRaq.
David Kentley wrote:
I believe the only reason this is a problem is because you are used to case sensitivity in other languages.
Not the only reason. It is also considered bad writing to mix cases. Ask an English Major. This must be at least partially a "readability" issue and we are not even talking "code" at that point. Also all caps are difficult to read because we process the character hights and read faster. All caps slow down that process by eliminating hight variation. This indicates that consistency is optimal to readability. tRy ReadIng soMthiNg lIKe thIS aLLDaY LOnG aND sEe hOW yoU LiKE IT! With something as specific as "code" I think the problem is increased. Therefore I am sticking to the "readability" issue as supporting case-sensitive languages.
led mike
-
Been there, done that. :) It's strange how people immediately blame the use of properties, or the case sensetivity of the language. It's like everyone is running around with a protest sign, just looking for a good spot where they can stand and wave it... ;) I have used the wrong name just like this a few times, and every time it was because I was using intellisense and chose the wrong item. Is the conclusion then that intellisense should be banned? Of course not. If everything in a programming environment that could possible be used in the wrong way should be removed, then we'd be back at writing code on punch cards...
--- b { font-weight: normal; }
Guffa wrote:
then we'd be back at writing code on punch cards...
Actually, we didn't write anything. We used typewriters of sorts, that really did punch holes in the cards. Beat the crap out of playing with all those toggle buttons, though. :-D
Chris Meech I am Canadian. [heard in a local bar] Nobody likes jerks. [espeir] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]
-
Guffa wrote:
then we'd be back at writing code on punch cards...
Actually, we didn't write anything. We used typewriters of sorts, that really did punch holes in the cards. Beat the crap out of playing with all those toggle buttons, though. :-D
Chris Meech I am Canadian. [heard in a local bar] Nobody likes jerks. [espeir] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]
-
David Kentley wrote:
I believe the only reason this is a problem is because you are used to case sensitivity in other languages.
Not the only reason. It is also considered bad writing to mix cases. Ask an English Major. This must be at least partially a "readability" issue and we are not even talking "code" at that point. Also all caps are difficult to read because we process the character hights and read faster. All caps slow down that process by eliminating hight variation. This indicates that consistency is optimal to readability. tRy ReadIng soMthiNg lIKe thIS aLLDaY LOnG aND sEe hOW yoU LiKE IT! With something as specific as "code" I think the problem is increased. Therefore I am sticking to the "readability" issue as supporting case-sensitive languages.
led mike
" It is also considered bad writing to mix cases. Ask an English Major. " Ah, but what about German? " Therefore I am sticking to the "readability" issue as supporting case-sensitive languages. " May be good style, but no reason for the language to enforce it.
-
" It is also considered bad writing to mix cases. Ask an English Major. " Ah, but what about German? " Therefore I am sticking to the "readability" issue as supporting case-sensitive languages. " May be good style, but no reason for the language to enforce it.
PIEBALDconsult wrote:
Ah, but what about German?
In German, only the first word of a sentence, nouns and names are given upper case (might be a few other cases (no pun intended)). The Upper Cases Are Not All Over The SentenceS. :)
PIEBALDconsult wrote:
May be good style, but no reason for the language to enforce it.
If the language doesn't, some project manager will through coding standards. What I'd like are non-ascii characters in programming languages. That would be far more usable than case insensitiveness.
-- A Stern Warning of Things to Come
-
Guffa wrote:
then we'd be back at writing code on punch cards...
Actually, we didn't write anything. We used typewriters of sorts, that really did punch holes in the cards. Beat the crap out of playing with all those toggle buttons, though. :-D
Chris Meech I am Canadian. [heard in a local bar] Nobody likes jerks. [espeir] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]
You know what a fun project would be? Build a card reader and a virtual machine, which you'd program with those cards...
-- In Hypno-Vision
-
David Kentley wrote:
I believe the only reason this is a problem is because you are used to case sensitivity in other languages.
Not the only reason. It is also considered bad writing to mix cases. Ask an English Major. This must be at least partially a "readability" issue and we are not even talking "code" at that point. Also all caps are difficult to read because we process the character hights and read faster. All caps slow down that process by eliminating hight variation. This indicates that consistency is optimal to readability. tRy ReadIng soMthiNg lIKe thIS aLLDaY LOnG aND sEe hOW yoU LiKE IT! With something as specific as "code" I think the problem is increased. Therefore I am sticking to the "readability" issue as supporting case-sensitive languages.
led mike
See Straw Man Argument[^] under the topic "Logical Falacies."
Matt Gerrans
-
PIEBALDconsult wrote:
detail hiding is a basic OOP principle.
:) Sure, as long as the "details" are not hidden so well that you mix them up and end up with a stack overflow.
Maybe you should just avoid all languages that allow any sort of recursion. :laugh:
Matt Gerrans
-
Properties are wonderful. I think Mr. Kentley has it right -- case sensitive languages are the problem.
Matt Gerrans
>>case sensitive languages are the problem No, sloppy coders are the problem. properties does not kill apps, people do.. ;-)
-
Maybe you should just avoid all languages that allow any sort of recursion. :laugh:
Matt Gerrans
Matt Gerrans wrote:
Maybe you should just avoid all languages that allow any sort of recursion.
No, I just avoid methods that look like data members ;P
-
>>case sensitive languages are the problem No, sloppy coders are the problem. properties does not kill apps, people do.. ;-)
They can have my properties when they pry them from my cold dead hands.
-
Matt Gerrans wrote:
Maybe you should just avoid all languages that allow any sort of recursion.
No, I just avoid methods that look like data members ;P
I'll admit I've used case-sensitivity to distinguish fields from the properties that represent them. I've never had this recursion problem and it doesn't seem like a big issue. Seems like it should be easy to track down. I don't even think it is necessary to have some silly convention like junking up field names with an "_" or "m_" prefix (or even a "look_out_this_here_is_a_member_variable_and_the_other_one_is_a_property_reference_so_do_be_careful_" prefix). I had more troubles with unexpected recursion when overloading the comparision operator. That's where you discover a strange dichotomy between reference variables and operator overloading, in that operator overloading kind of lets you treat variables like they are values when they are really references. It works out okay in C++ because you really can do that, but in C# it is trickier.
Matt Gerrans
-
This is one of the reasons that I use underscore to prefix fields. They make it so much easier to spot.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world." Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that." Deja View - the feeling that you've seen this post before.
I was not bitten by the same bug, but I started doing it a couple of months back. Reason? They're easier to spot. :)
Cheers, Vikram.
"Life isn't fair, and the world is full of unscrupulous characters. There are things worth fighting for, killing for and dying for, but it's a really small list. Chalk it up to experience, let it go, and move on to the next positive experience in your life." - Christopher Duncan.
-
Properties are wonderful. I think Mr. Kentley has it right -- case sensitive languages are the problem.
Matt Gerrans
Properties (with appropriate gettors and settors) are excellent assets to the language. I would say case-sensitivity is also required. The good glue is a a good consistent programming standard (aka) coding standard which would make a cleaner reading of the code, finer debugging, elegant troubleshooting and expedited resolution to the problem.
Vasudevan Deepak Kumar Personal Homepage namespace LavanyaDeepak
Personal Weblog
The World of Deepak and Lavanya
Views and Reviews -
Properties (with appropriate gettors and settors) are excellent assets to the language. I would say case-sensitivity is also required. The good glue is a a good consistent programming standard (aka) coding standard which would make a cleaner reading of the code, finer debugging, elegant troubleshooting and expedited resolution to the problem.
Vasudevan Deepak Kumar Personal Homepage namespace LavanyaDeepak
Personal Weblog
The World of Deepak and Lavanya
Views and ReviewsVasudevan Deepak Kumar wrote:
Properties (with appropriate gettors and settors) are excellent assets to the language.
How so?
-
Vasudevan Deepak Kumar wrote:
Properties (with appropriate gettors and settors) are excellent assets to the language.
How so?
Expressiveness.
-
Pete O'Hanlon wrote:
use underscore to prefix fields
Wow, I thought I was the only one left doing that. :cool:
led mike
Hehe, I'm still using m_ prefix in my code, for member variables. I got a fellow coworker who goes further and uses l_ prefix for local variables and p_ prefix for parameters... :doh:
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine. Blog Personal Site