|
What's with the scare quotes?
|
|
|
|
|
Ron Beyer wrote: At least we know what the 'compiler' is doing when you declare a variable
Sure, we need certainties, after all!
Veni, vidi, vici.
|
|
|
|
|
Ron Beyer wrote: At least we know what the 'compiler' is doing when you declare a variable
Actually, it's not even accurate, technically. The compiler doesn't allocate "some memory", it reserves space on the stack when the function is called. Yes, the stack is of course memory, but it's not the same kind of memory one uses when allocating / deallocating.
Marc
|
|
|
|
|
Lovely
Not only way over the top, but where comments would be useful, those comments aren't.
I would only put 1 comment in there - //254 means we are about to process a command, so read one & process it.
Plus a comment to add a description of each entry in the switch statement to translate the number into something sensible. This removes clutter, and also the need to look up op-codes in the event of brain-fade.
Regards, Stewart
|
|
|
|
|
All of those can be solved with compiler constants, for example:
#define CMDSTART 254
#define READCMD 1
#define WRITECMD 2
etc... Which also eliminates "magic numbers" and makes the program more maintainable.
|
|
|
|
|
So... I guess, there's a comment like
(yes|no|maybe)*
|
|
|
|
|
Amusingly, that doesn't really tell us much - the compiler doesn't "allocate" memory, the stack is allocated when the program starts - this simply updates stack pointers.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Over-zealous on the documentation part but missed out some basic coding standards like below:
1) Magic Strings/Numbers in code.
2) It would be better to have the value of serial_getch() assigned in a variable and then used in switch instead of calling it directly as a function in the switch construct.
|
|
|
|
|
Probably he had a boss who complained about insufficient comments - like my boss often does when reviewing my code complains about missing annotations (just review annotations, the code was already commented properly). So I did more or less the same like our guy here - and my boss was happy. He didn't get that it was supposed to be ironic...
|
|
|
|
|
No horror here if it was posted to someone who's not into programming. E.g. "==" operator is not obvious and may provoke questions what does it mean. Also, telling about "allocating" memory is more understandable that introducing to how stack and pointers work.
Greetings - Jacek
|
|
|
|
|
|
And the one at the bottom of the page about exiting is a spelling mistake.
|
|
|
|
|
how ... you done that? Can it be reproduced and how I am curious
dev
|
|
|
|
|
|
According to the original post, you need to go to lunch while VS is frozen.
Greetings - Jacek
|
|
|
|
|
I think VS was busy
It's an OO world.
public class Sander : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Now we know that VS has it's own way to "take care of business". I heard that it never happens if you have both VS and Eclipse installed.
Greetings - Jacek
|
|
|
|
|
Good code or bad code? Runs during a form constructor (testUser is a class bool).
public class a : Form
{
bool testUser;
a()
{
testUser = Array.IndexOf(new string[] { "mrock", "kasante" }, Environment.UserName.ToLower()) != -1;
}
}
I think my SQL experience influenced me slightly on this one.
|
|
|
|
|
Looks OK for a test code. And it's easy to extend. It would be bad if it was in a released code.
Greetings - Jacek
|
|
|
|
|
It's not in test code - it just sets a bool to determine whether features still being tested are available or not.
|
|
|
|
|
SortaCore wrote: It's not in test code (...) features still being tested
With a "test code" I (imprecisely) meant a "code being tested" -- which is the case.
Greetings - Jacek
|
|
|
|
|
No, it's used in release code, not as part of testing code - it specifies whether to allow the user to use beta functionality, basically.
Sorry if I wasn't clear.
|
|
|
|
|
As stated, it's OK.
You could use a case-insensitive HashSet -- I would make it static in case the set of testers becomes large. And perhaps use the # if DEBUG directive.
If you find yourself copying this code to many forms, you could put it in a library method.
|
|
|
|
|
SortaCore wrote: testUser = Array.IndexOf(new string[] { "mrock", "kasante" }, Environment.UserName.ToLower()) != -1;
If you want to get a little tighter about it:
testUser = Array.Exists(new [] { "a", "b" }, t => t=="a");
First of all, you don't need string[] because the compiler can infer the array type.
Second, using "Exists" makes it clearer to the reader what you're doing, especially since you're not interested in the index, you just want to know of the value exists.
Lastly, the use of the predicate t => t == 'a' means you could do some fancier things if you wanted later on -- it's a more general purpose solution. (Where 'a' would actually be in your case Environment.UserName.ToLower()
Marc
|
|
|
|
|
We all understand what a "class" is and what an "instance" is. These terms have nice rigorous definitions. We are having a debate in school with one of the professors. Of course we have to follow there definition in that class but we are wondering what the real answer is. It seems like there are 3 possible answers.
1. An Object and Class mean the same thing.
2. An Object and Instance mean the same thing.
3. An Object is both a Class and Instance. Object is more of a higher order term that includes both.
After doing some web research it seems that over time the name has changed. Just referring to common usage. It started out in the 80's as the first choice. In the 90's things got confusing so they added the word class so they could deal with hierarchies of classes. After the turn of the century is looks like it moved mostly to the 2nd definition. Still it kind of still oscillates between 2 and 3. Some of us think we should not even use the word object because of the confusion and only use class and instance.
We are wondering what the rest of the world thinks now.
So many years of programming I have forgotten more languages than I know.
modified 14-Nov-13 14:53pm.
|
|
|
|