Programming isn't hard...
-
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."
-
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 used to name all my functions in alphabetical order with the letters of the alphabet i.e. A(), B(), C(), D() etc. in the order of creation. But for some strange reason my boss went really mental about it questioning my professionalism and sanity and screaming the he is gonna do anatomically impossible things with me and the keyboard if I don’t start naming the functions with a meaningful words. So now I'm naming them: Alpha(), Bravo(), Charlie(), Delta(), Echo(), Foxtrot() etc. After that I’m closing them in regions named “A2C”, “D2O” and “P2Z”. It’s pretty, readable and intuitive. I hope my boss will be happy know.
There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.
-
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). -
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>{}
This is Dijkstra's opinion, not mine! But I think he would tell you that mathematicians get by with X, Y, theta, pi, etc., and that programming is just a species of mathematics. After all, Einstein didn't discover that realEnergy = realMass * [ (squareRootOfTheSpeedOfLight)² ] Rather, he was just fine with E=mc², and (amazingly, if all you know is programming) people still embraced his findings.
-
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."
OriginalGriff wrote:
Star Fleet don't seem to have any truck with H&S legislation, or they wouldn't fill all the computer consoles with semtex...
Yeah, I always wondered why it was that they could manage matter-energy conversion, subspace communication, and warp drive... But couldn't seem to figure out how to make a surge protector or... *gasp*... a FUSE!
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
What kind of object is it? ...if it's to remain abstract... then
obj
seems good enough for me.I just went for
item
. And yes, it is to remain abstract. It is an Interface Method that has a T (as in generic) as a parameter. That is the reason I did not want to go forobj
. Because the parameter is of type T, which is more specific than an Object.It's an OO world.
public class Naerling : Lazy<Person>{}
-
This is Dijkstra's opinion, not mine! But I think he would tell you that mathematicians get by with X, Y, theta, pi, etc., and that programming is just a species of mathematics. After all, Einstein didn't discover that realEnergy = realMass * [ (squareRootOfTheSpeedOfLight)² ] Rather, he was just fine with E=mc², and (amazingly, if all you know is programming) people still embraced his findings.
Dijkstra didn't have to debug an option valuation model written in C++ by a math PhD... True story... Almost every variable in the Black-Scholes calculation was one or two letters long, and none of them had any relevance to what they represented. Don't get me wrong... It (mostly) worked, and it was fast, but... Ow, my eyes!
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 am currently in the fourth phase of naming. Phase I: Short undescriptive names; great for college kids and prima donas Phase II: Names of nouns that are easy to remember but have no bearing on code Phase III: Logical naming based on context, type, and use Phase IV: Whatever you feel like because you are in charge. Don't worry, naming gets easier with time.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
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)._beauw_ wrote:
The declaration at the end of this snippet implies that the name
max_subscript
is actually an inaccurate description.I would agree, but that isn't a fault of the naming convention. Rather, it is a fault of the coder: max_subscript is wrong, and doesn't describe what the constant is used for: max_elements_count would have been better (or max_whatevertheheckthearrayholds_count even better still) For me, the problem is I grew up with Fortran, where a line of code was 80 characters, and variables were a max of six characters. Generally names were impenetrable, short and unrelated to the use. So, when I can I use "proper" names for things, because it means I can read the code in six months time and stand a vague chance of working out how it works. :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."
-
Dijkstra didn't have to debug an option valuation model written in C++ by a math PhD... True story... Almost every variable in the Black-Scholes calculation was one or two letters long, and none of them had any relevance to what they represented. Don't get me wrong... It (mostly) worked, and it was fast, but... Ow, my eyes!
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)When Black and Scholes were figuring out how to value options, though, they probably were using one- and two-letter variable names, and they ended up winning the Nobel Prize. Maybe the difference is that people don't have to "maintain" mathematics. There was a movie where Leo DiCaprio (or maybe Matt Damon?) was a maintenance man who did mathematics... but that's a different story. :-D
-
When Black and Scholes were figuring out how to value options, though, they probably were using one- and two-letter variable names, and they ended up winning the Nobel Prize. Maybe the difference is that people don't have to "maintain" mathematics. There was a movie where Leo DiCaprio (or maybe Matt Damon?) was a maintenance man who did mathematics... but that's a different story. :-D
_beauw_ wrote:
There was a movie where Leo DiCaprio (or maybe Matt Damon?) was a maintenance man who did mathematics...
I believe you are refering to Good Will Hunting[^] and it stared Matt Damon.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
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>{}
-
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)Ian Shlasko wrote:
Tenagra t = new Tenagra(); t.Add(new Darmok()); t.Add(new Jilad()); t.Add(new TheBeast()); t.EpicBattle(); t.MoveItemsTo(new Ocean());
Congratulations, this is the nerdiest thing I have read this month, on many levels. And considering the crap I read, that was an achievement.
-
Ian Shlasko wrote:
Tenagra t = new Tenagra(); t.Add(new Darmok()); t.Add(new Jilad()); t.Add(new TheBeast()); t.EpicBattle(); t.MoveItemsTo(new Ocean());
Congratulations, this is the nerdiest thing I have read this month, on many levels. And considering the crap I read, that was an achievement.
I blame Netflix, for having the entire Star Trek franchise available for streaming :)
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>{}
Naerling wrote:
Thinking of names for your classes and variables,
I don't use anything under 80 characters in length. I try to name it and describe it all in one name. I also have a tendency to give it a feminine or masculine slant depending on what kind of work these objects are doing...names usually ending in either "ita" or "ito".
Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) -
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'm going to drive up to Dublin and hurt you now. I'll see you in an hour.
Software Zen:
delete this;
-
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.
This is a particularly stupid tip and would never work. Apart from the fact that it would require superhuman mental gymnastics, once you have more than 42 variables, in order to maintain alphabetic ordering, it is yet another invidious ploy by the militant fundamentalist wing of the ASL (Anti-Southpaw League). Please remember that The Lounge is no place for these religious outpourings.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
-
I'm going to drive up to Dublin and hurt you now. I'll see you in an hour.
Software Zen:
delete this;
-
_beauw_ wrote:
There was a movie where Leo DiCaprio (or maybe Matt Damon?) was a maintenance man who did mathematics...
I believe you are refering to Good Will Hunting[^] and it stared Matt Damon.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
This is a particularly stupid tip and would never work. Apart from the fact that it would require superhuman mental gymnastics, once you have more than 42 variables, in order to maintain alphabetic ordering, it is yet another invidious ploy by the militant fundamentalist wing of the ASL (Anti-Southpaw League). Please remember that The Lounge is no place for these religious outpourings.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
The obvious solution is to use a YTREWQ keyboard.
Somebody in an online forum wrote:
INTJs never really joke. They make a point. The joke is just a gift wrapper.