11 March 2016 - Forum Rules
Started by fellowroot, November 20, 2012, 05:37:32 AM
Quote from: BRPXQZME on November 21, 2012, 08:24:37 PMThis would be an infinite loop, wouldn't it? Operations in a condition check are A-OK as long as they make paradigmatic sense and aren't terribly expensive.
Quote from: BRPXQZME on November 21, 2012, 08:24:37 PMI'm also okay with one-letter variables being used for obvious and transient purposes. Saves typing time, confuses nobody.
Quote from: RedComet on November 22, 2012, 09:24:06 AMLittle late, but in my experience classes are only good for learning about algorithms and conceptual stuff. I've had one or two professors who wrote clean code that was readable while the rest prefer old-school cryptic variable names and jumbled messes. I've had to spend the majority of my time on my projects for my Web Programming class rewriting and massaging my professors shit heap of code to get it into a state where I can work with it easily without wanting to pull my hair out. My assembly language class is just as bad.
Quote from: RedComet on November 22, 2012, 09:24:06 AMThe other people in my classes haven't written code for 10 years to know what bad code is and my professors essentially encourage them. I dread having to work on a project after one of these people have worked on it.
Quote from: Garoth Moulinoski on November 26, 2012, 11:53:29 AMAs for adding the datatype before the variable name, for some names, it's probably obvious and in some ways can be the convention itself. Some people are also better at naming things than others. I feel that I can come back a year later, read my code, and understand that, yeah, $strTitle is supposed to be a string that holds a title to something.
Quote from: BRPXQZME on November 26, 2012, 04:44:12 PMbut then again those coders don't PHP.
QuoteKeep functions short.Declare your variables as close as possible to the place where you will use them.Don't use macros to create your own personal programming language.Don't use goto.Don't put closing braces more than one screen away from the matching opening brace.
Quote from: BRPXQZME on November 26, 2012, 05:13:12 PMThe reasoning Mr. Spolsky gives in that article I linked makes a lot more sense than just prefixing with types.
Quote from: BRPXQZME on November 26, 2012, 05:46:21 PMI know some people name their variables stuff like zxcv at first, then they search and replace the verbose version.
Quote from: Garoth Moulinoski on November 26, 2012, 11:53:29 AMHow bad was your assembly class? I mean, my professor used put comments on his ASM code and so would I (because that stuff gets cryptic after a while) but it's not like ASM is too pretty to begin with.
Quote from: RedComet on November 28, 2012, 08:35:23 PMMy professor's few comments were the kind that pointed out the obvious, e.g "LDA #$12 ; Loads 12H into A" and stuff like that instead of comments that actually explain what the code is doing.
Quote from: RedComet on November 28, 2012, 08:35:23 PMIt was made even worse by the fact that my professor couldn't speak comprehensible English if his life depended on it. Yay Engrish. I think I'm the only person who understood what was going on in there and that's only because of all the years I've spent writing assembly for my projects. See, kids, romhacking is a good thing!
QuoteLDA #$12 ; Loads 12H into A
Quote from: Bregalad on November 30, 2012, 04:21:14 PMMy god I can't belive professors can still use comments THAT bad. Why put a comment if it just repeats what is right before it ?
Quote from: furrykef on December 01, 2012, 09:25:31 AMIf it's a new construct the students are just learning or one they might have forgotten, it makes sense. But it should be made abundantly clear that this isn't how comments work in the real world.
Quote from: furrykef on December 01, 2012, 09:25:31 AMIncidentally, I got in minor trouble for not using such inane comments in the "real world" when I worked on a commercial DS game. One of the programmers was complaining to me that he couldn't understand my code because I didn't use enough comments. (I do try to write self-documenting code in favor of using comments, as I view comments as an admission of failure at making the code self-documenting. That said, I do comment much more than some people.) I said, OK, maybe my code isn't as clear as I thought. Show me an example of code you don't understand. So he showed me a line. I asked what the problem with the line was. He said he didn't even know what it means. It was a bitwise operation or something elementary like that -- I was setting or clearing bits. It was something that would have been instantly obvious to anybody with real experience with C or C++. Why I was manipulating those bits was obvious too; it wasn't something like "foo |= 0x12" with no explanation. So adding a comment there would have added nothing of value -- to somebody who already knows basic C++. But apparently expecting a programmer to know basic C++ is too much to ask for.
QuoteI do try to write self-documenting code in favor of using comments, as I view comments as an admission of failure at making the code self-documenting. That said, I do comment much more than some people.
Page created in 0.192 seconds with 20 queries.