Programming isn't hard...
-
Naerling wrote:
Thinking of names for your classes and variables, THAT's hard... :doh:
Frustration #1 of the evening... :sigh:I solve this by using a single
Object
variable calledtheKey
across my entire project. I assign all local references to this variable and cast to the required derived type before calling a method or property. On occasions I may need two or even three such variables (I suffix 1,2,3 to gettheKey1
and so on). Problem solved. :-\Regards, Nish
My technology blog: voidnish.wordpress.com
Wow, you should post that as a tip/trick or even write an article about that! That just solved all my problems (and created them for future readers of my code)! ;p
It's an OO world.
public class Naerling : Lazy<Person>{}
-
Naerling wrote:
Thinking of names for your classes and variables, THAT's hard... :doh:
Frustration #1 of the evening... :sigh:I solve this by using a single
Object
variable calledtheKey
across my entire project. I assign all local references to this variable and cast to the required derived type before calling a method or property. On occasions I may need two or even three such variables (I suffix 1,2,3 to gettheKey1
and so on). Problem solved. :-\Regards, Nish
My technology blog: voidnish.wordpress.com
I assume that in accordance with good OOP / C# programming practice it is both static and in a Singleton Pattern?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
-
You might get something out of this classic[^].
You mean my code should be gibberish and no one should ever be able to read past the first line? X|
It's an OO world.
public class Naerling : Lazy<Person>{}
-
Tenagra t = new Tenagra();
t.Add(new Darmok());
t.Add(new Jilad());
t.Add(new TheBeast());
t.EpicBattle();
t.MoveItemsTo(new Ocean());Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Is that a quote from the Guardians Saga? I do note however, that when you have moved all these items into the new ocean, you then discard the reference and effectively leave them adrift waiting for the Dark Lord G'Bge Cll'ctr to come and find them...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
-
I assume that in accordance with good OOP / C# programming practice it is both static and in a Singleton Pattern?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
OriginalGriff wrote:
I assume that in accordance with good OOP / C# programming practice it is both static and in a Singleton Pattern?
Yes, that goes without saying. Always follow good practices I guess :-D
Regards, Nish
My technology blog: voidnish.wordpress.com
-
You mean my code should be gibberish and no one should ever be able to read past the first line? X|
It's an OO world.
public class Naerling : Lazy<Person>{}
Hey, be nice... Some of us made it to the second line :-D
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Thinking of names for your classes and variables, THAT's hard... :doh: Frustration #1 of the evening... :sigh:
It's an OO world.
public class Naerling : Lazy<Person>{}
i name every CWaitCursor i create the same thing: bob. true story.
-
Naerling wrote:
Thinking of names for your classes and variables, THAT's hard... :doh:
Frustration #1 of the evening... :sigh:I solve this by using a single
Object
variable calledtheKey
across my entire project. I assign all local references to this variable and cast to the required derived type before calling a method or property. On occasions I may need two or even three such variables (I suffix 1,2,3 to gettheKey1
and so on). Problem solved. :-\Regards, Nish
My technology blog: voidnish.wordpress.com
I prefer to call all my variables a1, a2, a3, a4, and so on. Also, once I get to a6, I use another letter (say, b1)... that way, I only ever have to use my left hand and can keep my right hand on the mouse. It's a very efficient technique I wish everybody else would adopt. Until then, I just refactor all the code I see with overly long variable names like "count" (that's a particularly bad name because some of the characters require the right hand to type). I sleep easily at night, comfortable in the knowledge that all my refactoring has made the world a better place. :-\
Somebody in an online forum wrote:
INTJs never really joke. They make a point. The joke is just a gift wrapper.
-
Not really - just use names that say what they are. If you are trying to think up polite ways to call them after your ex-girlfriends, then yes, I can see where you might have difficulty. But if a class is meant to handle user information, then I would probably call it "UserInfo" rather than "RurikoPityHerVisaRanOutAndSheHadToGoBackToJapan" or "MarionWentAllWierdAndBecameBornAgain". Similarly with open file dialog references - I generally call them "ofd" for the short time they are in existance. :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
Allright, here it goes. I have an Object of any type that needs to have something done with/upon it. What is this Object called? Simply
obj
seems to easy.objToDoSomethingWith
is to long.handledObj
sounds as if something has already been done with it.handlingObj
is just weird.objToHandle
, well that might cause confusion. I could replaceobj
withitem
, but that does not solve anything. Perhaps I should not be thinking about this at the end of the day. Or perhaps I should just go withobj
... Oritem
. Choices, choices... :sigh:It's an OO world.
public class Naerling : Lazy<Person>{}
-
Is that a quote from the Guardians Saga? I do note however, that when you have moved all these items into the new ocean, you then discard the reference and effectively leave them adrift waiting for the Dark Lord G'Bge Cll'ctr to come and find them...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
Uh, no.... Not a Trekkie[^], are you?
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Thinking of names for your classes and variables, THAT's hard... :doh: Frustration #1 of the evening... :sigh:
It's an OO world.
public class Naerling : Lazy<Person>{}
(Hands you 100 001 baby names book) this should help. :) Append] this kinda goes along with the C# numeration and collections example where by the authur used "MyCult" as an example (great idea by the way).
///////////////// -Negative, I am a meat popsicle.
-
Is that a quote from the Guardians Saga? I do note however, that when you have moved all these items into the new ocean, you then discard the reference and effectively leave them adrift waiting for the Dark Lord G'Bge Cll'ctr to come and find them...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
OriginalGriff wrote:
Is that a quote from the Guardians Saga?
Nope. Star Trek: The Next Generation [^] reference.
-
Hey, be nice... Some of us made it to the second line :-D
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Yes, but how long did it take? And this is not even code. If reading this in code would take you as long as reading this in plain text the code would not even compile anymore on the computers that, by that time, have become modern ;p
It's an OO world.
public class Naerling : Lazy<Person>{}
-
Uh, no.... Not a Trekkie[^], are you?
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Sometimes - but Wesley Crusher scarred me so badly I couldn't watch TNG so the references didn't mean anything.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
-
i name every CWaitCursor i create the same thing: bob. true story.
b
obj
? :)It's an OO world.
public class Naerling : Lazy<Person>{}
-
Sometimes - but Wesley Crusher scarred me so badly I couldn't watch TNG so the references didn't mean anything.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
Oh, come on... The character may have been a bit silly, but Wil Wheaton is cool... Gotta respect any Hollywood actor who's an active member of Slashdot.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Yes, but how long did it take? And this is not even code. If reading this in code would take you as long as reading this in plain text the code would not even compile anymore on the computers that, by that time, have become modern ;p
It's an OO world.
public class Naerling : Lazy<Person>{}
Um, a few seconds... It was something about bags... After a few lines, I realized it wasn't worth continuing :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Allright, here it goes. I have an Object of any type that needs to have something done with/upon it. What is this Object called? Simply
obj
seems to easy.objToDoSomethingWith
is to long.handledObj
sounds as if something has already been done with it.handlingObj
is just weird.objToHandle
, well that might cause confusion. I could replaceobj
withitem
, but that does not solve anything. Perhaps I should not be thinking about this at the end of the day. Or perhaps I should just go withobj
... Oritem
. Choices, choices... :sigh:It's an OO world.
public class Naerling : Lazy<Person>{}
What kind of object is it? ...if it's to remain abstract... then
obj
seems good enough for me. -
Oh, come on... The character may have been a bit silly, but Wil Wheaton is cool... Gotta respect any Hollywood actor who's an active member of Slashdot.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)The character should have been fed to rabid Tribbles at birth. Or Lieutenant Yar if health and safety rules forbid rabid Tribbles on Star Fleet vessels. Unlikely, I admit - Star Fleet don't seem to have any truck with H&S legislation, or they wouldn't fill all the computer consoles with semtex...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
-
I'd forgotten just how impenetrably Dijkstra wrote: I needed a good long run up to read him when I was a student. And several large drinks afterwards. Mind you, at least he didn't make you fall asleep like Knuth did... But that could have been the large drinks!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
Yeah, it's true. The theme of many of Dijkstra's arguments was that natural language is a poor vehicle for discussing problems in computation, and his writing style seems at times to be intended to prove this assertion! I have read through his "Meaningful Identifiers" paper, though, and in summary, his basic point seems to be that attempting to give variables descriptive natural language names is a trap. A natural language name can never truly express what a variable is, fundamentally, or what it does, only provide hints. Because these natural language names are subjective and ambiguous, a danger occurs when people (e.g. maintenance programmers) attempt to extract meaning from them instead of just reading the code, e.g.
#define max_subscript 4
//...
int some_array[max_subscript];
The declaration at the end of this snippet implies that the name
max_subscript
is actually an inaccurate description. The real maximum subscript is 3. But in order to detect this, one must 1) be familiar with C syntax and 2) actually see and consider this declaration (versus simply seeing the incorrectly named constant used elsewhere). As a result, we would be better off ifmax_subscript
were simply calledM
(oriLikeFishTacos
,brett_favre
, etc.) Dijkstra's argument seems sound, but in practice I do give my identifiers meaningful natural-language names, because people expect this. It's not difficult to extend Dijkstra's argument about identifier names to comments as well... consider the following:void a_function()
{
int * a = new int; //Allocate "a" on the stack//...
}//All that stuff we allocated on the stack gets cleaned up automatically here
Again, this is a simplistic example (that
int
isn't on the stack and it won't get cleaned up automatically). Hopefully, though, the message is clear: we'd actually be better off without those supposedly helpful comments. As an experienced programmer, I have suffered through a few scenarios where an inaccurate comment actually did slow me down. However, I must be careful to point out that none of these extreme positions reflect my own personal programming practice... (although I do think that developers should at least acquaint themselves with Dijkstra's argument).