There are at least 4 physical positions in this system, not including any of the virtual positions.
The variable name is so vague as to be meaningless, and worst case misleading.
Edit:
Protip for Programmers
What is obvious right now in the heat of the moment will not be obvious in a few week's time when you/someone else revisits the code.
Either comment the code, or make it so that there's no ambiguity in your variable/function names.
Personal Opinion: A difference between a good developer and a crappy code monkey is the bolded - you write code not just to solve the immediate problem, but also think about maintenance and how it will interact with other code/people.
So name all your variables after things with deep emotional connotations. Friends, family, religious figures, characters from popular fiction.
This is what I just found. This also has many associated multiple levels of fail - ignoring the obvious WTFs there:
1.) This was inside a header file for an unrelated class. What the header file for a class is doing controlling network output is a mystery.
2.) A "Find in Files" indicates that nothing else references this. Why is this even here in the first place?*
3.) Placed without decoration in a namespace shared between multiple classes. Whhhhy? Why would you hurt another developer and stop them using those names like this?
Thankfully, due to #2, I can just nuke it from orbit.
*sigh*
This day is going to be so good when it's over.
* Yes, it was probably used at one stage. And now it's just leftovers. Should have been removed when the functions that were using it were removed.
EDIT #2:
Hey, guess what I just found by going down a few lines:
There are at least 4 physical positions in this system, not including any of the virtual positions.
The variable name is so vague as to be meaningless, and worst case misleading.
Edit:
Protip for Programmers
What is obvious right now in the heat of the moment will not be obvious in a few week's time when you/someone else revisits the code.
Either comment the code, or make it so that there's no ambiguity in your variable/function names.
Personal Opinion: A difference between a good developer and a crappy code monkey is the bolded - you write code not just to solve the immediate problem, but also think about maintenance and how it will interact with other code/people.
So name all your variables after things with deep emotional connotations. Friends, family, religious figures, characters from popular fiction.
How have you managed to not burn it all to the ground for this long? Five minutes of this shit would've done it for me, no exaggeration.
To my shame, I have actually blown up at the dev in question. =/
My attempts at peer programming failed spectacularly because I couldn't handle it.
Wait. One single person is responsible for the mess you've been posting? It's not just the accumulated stupidity of a legacy code base through the ages?
If that's true, then I think what you mean is that your peer's attempt at programming failed spectacularly.
+2
The AnonymousUh, uh, uhhhhhh...Uh, uh.Registered Userregular
How have you managed to not burn it all to the ground for this long? Five minutes of this shit would've done it for me, no exaggeration.
To my shame, I have actually blown up at the dev in question. =/
My attempts at peer programming failed spectacularly because I couldn't handle it.
Did they apologise?
No, because they think that they're a special little embedded developer snowflake who can break the rules because they know better.
=/
Edit:
I am currently burning this particular class to the ground and redoing it from the ground up due to several failures and making the code practically unmaintainable/extensible.
1.) It's very much not thread-safe, despite me mentioning this to him over the last few months. According to the comments, he thinks that a big circular buffer will save him. Based on the reported bugs, I beg to differ.
2.) There's copious amounts of copy/paste/change one line.
3.) There's use of static variables in member functions (not to be confused with static member variables). This hits the previous two points.
4.) Exciting and amazing use of old school C style (not really even modern C style) string handling calls. I swear I think some of these C functions are obsolete...? Potential buffer overflows ahoy, either way.
5.) Just general crap coding (mismatched indents, the ummm... "anti-separation of concerns" design pattern)
There are at least 4 physical positions in this system, not including any of the virtual positions.
The variable name is so vague as to be meaningless, and worst case misleading.
Edit:
Protip for Programmers
What is obvious right now in the heat of the moment will not be obvious in a few week's time when you/someone else revisits the code.
Either comment the code, or make it so that there's no ambiguity in your variable/function names.
Personal Opinion: A difference between a good developer and a crappy code monkey is the bolded - you write code not just to solve the immediate problem, but also think about maintenance and how it will interact with other code/people.
So name all your variables after things with deep emotional connotations. Friends, family, religious figures, characters from popular fiction.
Choose variable names with irrelevant emotional connotation. e.g.:
marypoppins = (superman + starship) / god;
This confuses the reader because they have difficulty disassociating the emotional connotations of the words from the logic they're trying to think about.
How have you managed to not burn it all to the ground for this long? Five minutes of this shit would've done it for me, no exaggeration.
To my shame, I have actually blown up at the dev in question. =/
My attempts at peer programming failed spectacularly because I couldn't handle it.
Did they apologise?
No, because they think that they're a special little embedded developer snowflake who can break the rules because they know better.
=/
Edit:
I am currently burning this particular class to the ground and redoing it from the ground up due to several failures and making the code practically unmaintainable/extensible.
1.) It's very much not thread-safe, despite me mentioning this to him over the last few months. According to the comments, he thinks that a big circular buffer will save him. Based on the reported bugs, I beg to differ.
2.) There's copious amounts of copy/paste/change one line.
3.) There's use of static variables in member functions (not to be confused with static member variables). This hits the previous two points.
4.) Exciting and amazing use of old school C style (not really even modern C style) string handling calls. I swear I think some of these C functions are obsolete...? Potential buffer overflows ahoy, either way.
5.) Just general crap coding (mismatched indents, the ummm... "anti-separation of concerns" design pattern)
@bowen will likely be here soon to give you some sage advice.
I do, and it's something I recommend all programmers read at some point, and take to heart. Not even in a tongue in cheek way either. It does an excellent job of not only showing what not to do, but it shows why doing things like that is so destructive.
I don't know if I've gushed about DbContext.Database.Log yet, but in case not...
I have a web API like thing that does stuff then spits out JSON. When it dies, it can be a little cryptic. So I put this together so I could get debug info out without throwing exceptions or wading through guts:
public static Result SaveDB(DbContext db, bool logSuccess=false)
{
var log = new List<string>();
var old = db.Database.Log;
db.Database.Log = log.Add;
try
{
db.SaveChanges();
}
catch (Exception ex)
{
return Fail( Message: ex.Message, Data: log);
}
finally
{
db.Database.Log = old;
}
return Win(Data: logSuccess ? log : null);
}
I was going to delete this instead of posting, but I just accidentally deleted the file I'd created it in instead of committing it and came back here to retrieve it from draft, so I figure I shouldn't fight divine providence.
How have you managed to not burn it all to the ground for this long? Five minutes of this shit would've done it for me, no exaggeration.
To my shame, I have actually blown up at the dev in question. =/
My attempts at peer programming failed spectacularly because I couldn't handle it.
Did they apologise?
No, because they think that they're a special little embedded developer snowflake who can break the rules because they know better.
=/
Edit:
I am currently burning this particular class to the ground and redoing it from the ground up due to several failures and making the code practically unmaintainable/extensible.
1.) It's very much not thread-safe, despite me mentioning this to him over the last few months. According to the comments, he thinks that a big circular buffer will save him. Based on the reported bugs, I beg to differ.
2.) There's copious amounts of copy/paste/change one line.
3.) There's use of static variables in member functions (not to be confused with static member variables). This hits the previous two points.
4.) Exciting and amazing use of old school C style (not really even modern C style) string handling calls. I swear I think some of these C functions are obsolete...? Potential buffer overflows ahoy, either way.
5.) Just general crap coding (mismatched indents, the ummm... "anti-separation of concerns" design pattern)
@bowen will likely be here soon to give you some sage advice.
Do not listen to a single word of it.
Take a shit, place it in your hand, smear it on his face.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Wouldn't using a mutex make your class mostly thread safe? Why would you use a large place in memory and circular buffers for that?
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
+1
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
Complete newbie question
Is there any reasonably good resources to learn Java online? Or is a textbook going to be the best bet? I'm in Australia, so a lot of seemingly fantastic American textbooks will be a pain to get over here, and I was hoping to find something online, but so far everything I've turned up with Google has been not so useful.
Most of them have seemed like great Java tutorials for an experienced programmer of other languages, but fallen flat for an actual programming novice, which is what I am.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
edited April 2015
A quick perusal of that one shows that it seems to have the same problem the others did - namely, it doesn't explain a lot of what it is doing.
For example, the first program it has you write after Hello World is an example to demonstrate enums
The concept of enums seems simple enough, it's a restricted variable
but here is the code they use.
Example:
class FreshJuice {
enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }
FreshJuiceSize size;
}
public class FreshJuiceTest {
public static void main(String args[]){
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice. FreshJuiceSize.MEDIUM ;
System.out.println("Size: " + juice.size);
}
}
zero explanation for any of that. I understand that enum FreshJuiceSize{ SMALL, MEDIUM, LARGE } declares the variable's restrictions
and I understand the println line
but I don't really understand what they are doing with "FreshJuiceSize size;" and
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice. FreshJuiceSize.MEDIUM ;
and they don't explain any of it. I'm assuming that the line referring to medium is where they declare what the variable actually is for the purpose of the printout
Dhalphir on
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
edited April 2015
And I know that someone in here can probably explain what they mean by the above code, but that's not the point - if the tutorial itself doesn't explain things to a complete beginner as it goes along, it's not much of a tutorial, as I'd have to constantly keep stopping and doing separate research to determine what is what
And I know that someone in here can probably explain what they mean by the above code, but that's not the point - if the tutorial itself doesn't explain things to a complete beginner as it goes along, it's not much of a tutorial, as I'd have to constantly keep stopping and doing separate research to determine what is what
This is going to happen regardless and will happen with about 90% of all programming tutorials unfortunately. There will be a lot of "how in the fuck...?" moments when learning your first language.
Also programming books from 2003 may not be too relevant for Java 1.7+
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
I generally struggle to learn via videos. I read much much faster than I can listen, and I get incredibly impatient with videos. But I will have a look and see what I can find Thanks
Yeah, it's a downside of object oriented programming. There's a lot of structure around how things work that you could spend a long time figuring out.
Instead, most tutorials are going to start with a lot of handwaving. They'll go back and explain why things are the way they are later.
public static void main(String args[]){
is my favorite instance of this.
When I learned Java, my teacher just said to accept that this is the code that means "start my program here", but then in a few months, we knew everything about that line and why it made the program start.
Is there any reasonably good resources to learn Java online? Or is a textbook going to be the best bet? I'm in Australia, so a lot of seemingly fantastic American textbooks will be a pain to get over here, and I was hoping to find something online, but so far everything I've turned up with Google has been not so useful.
Most of them have seemed like great Java tutorials for an experienced programmer of other languages, but fallen flat for an actual programming novice, which is what I am.
I don't think there's a good resource to learn how to program in Java online (as opposed to learning the Java programming language itself). My recommendation is this book:
Which is what I have used in the classroom before—it's simply excellent, and it is focused on learning how to program rather than learn Java minutiae.
@Dhalphir If you can't find a copy easy (you can buy an ebook version), PM me, and I'll see what I can do...
@TwitchTV, @Youtube: master-level zerg ladder/customs, commentary, and random miscellany.
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
edited April 2015
Sorry, I should have clarified that I didn't want to learn how to "program online".
I want to learn how to program...online, ie, put a tutorial of something up on a secondary monitor while I code in a primary monitor. That ebook looks pretty good.
I'll add you as a friend on Steam Kambing, I can't believe I haven't already.
Dhalphir on
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
The ebook version of that doesn't appear to be accessible for Australian users.
Also keep in mind @Dhalphir I'm not saying anything here as a knock against you but I've been doing this for around 8+ years and I STILL have to google "how in the fuck does this work" and come into this thread and ask dumb questions all the time. I think explaining everything line by line on what it does will overwhelm you.
Take things as they come and if you have no idea what it does then either: open a new tab and google "java enum tutorial", or assume what's going on is "automagical" and revisit at a later time.
+2
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
edited April 2015
so basically, if they're explaining enums or anything else and show an example program which includes lots of stuff that isn't explained, don't be afraid to copy the code word for word from their lesson and trust that they'll explain it eventually?
so basically, if they're explaining enums or anything else and show an example program which includes lots of stuff that isn't explained, don't be afraid to copy the code word for word from their lesson and trust that they'll explain it eventually?
They should be explaining what enums are, though, if it's being brought up in a code example. Even if it's "we'll talk about this more in chapter 5".
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
so basically, if they're explaining enums or anything else and show an example program which includes lots of stuff that isn't explained, don't be afraid to copy the code word for word from their lesson and trust that they'll explain it eventually?
Or crack open an IDE and type it in yourself and see what happens and if it works. Then step through the code. I can't really say what that tutorial is doing though. If they don't eventually explain the structure of an enum on an enum tutorial then I'd say it's a bad tutorial.
so basically, if they're explaining enums or anything else and show an example program which includes lots of stuff that isn't explained, don't be afraid to copy the code word for word from their lesson and trust that they'll explain it eventually?
Yes, particularly for a total beginner. Lots of languages, and java especially, have a certain hump you have to get over in order to understand enough to make a workable program. Most tutorial writers will give you workable code chunks without expecting you to understand everything in them. Most people prefer to have an actual working example rather than go step by step through every single building block before you can actually run code.
Even if it'd deprecated, it still works. Because Java :rotate:
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
Dhalphirdon't you open that trapdooryou're a fool if you dareRegistered Userregular
Thanks for all your help guys. I found what looks like a decent set of tutorials by thenewboston on Youtube, which seem pretty decent and are centered around using Eclipse, which is way easier than the previous tutorial which had me using Notepad++ and the command line. I'm also going to chat to Kambing about finding a way to get a copy of that textbook too.
last question.
I'm assuming since nobody pounced on my choice of Java as a first programming language that it's a pretty reasonable choice? I mainly selected it because it seems pretty versatile as a language - able to wear many hats, and similar enough to most other common languages that branching out later wouldn't be too difficult.
Posts
So name all your variables after things with deep emotional connotations. Friends, family, religious figures, characters from popular fiction.
To my shame, I have actually blown up at the dev in question. =/
My attempts at peer programming failed spectacularly because I couldn't handle it.
Wait. One single person is responsible for the mess you've been posting? It's not just the accumulated stupidity of a legacy code base through the ages?
If that's true, then I think what you mean is that your peer's attempt at programming failed spectacularly.
No, because they think that they're a special little embedded developer snowflake who can break the rules because they know better.
=/
Edit:
I am currently burning this particular class to the ground and redoing it from the ground up due to several failures and making the code practically unmaintainable/extensible.
1.) It's very much not thread-safe, despite me mentioning this to him over the last few months. According to the comments, he thinks that a big circular buffer will save him. Based on the reported bugs, I beg to differ.
2.) There's copious amounts of copy/paste/change one line.
3.) There's use of static variables in member functions (not to be confused with static member variables). This hits the previous two points.
4.) Exciting and amazing use of old school C style (not really even modern C style) string handling calls. I swear I think some of these C functions are obsolete...? Potential buffer overflows ahoy, either way.
5.) Just general crap coding (mismatched indents, the ummm... "anti-separation of concerns" design pattern)
Imposter, IMO.
A real embedded developer wouldn't touch C++. If they can't crank out 68K asm or Forth, you need to tell them to GTFO.
To be fair, this shit is embarrassing things you'd expect from a course group let-down.
I mean, I hear, I never had a bad group myself. But I definitely have not seen anyone paid for the work you're describing.
I see that you too follow The Guide
Do not listen to a single word of it.
I have a web API like thing that does stuff then spits out JSON. When it dies, it can be a little cryptic. So I put this together so I could get debug info out without throwing exceptions or wading through guts:
public static Result SaveDB(DbContext db, bool logSuccess=false) { var log = new List<string>(); var old = db.Database.Log; db.Database.Log = log.Add; try { db.SaveChanges(); } catch (Exception ex) { return Fail( Message: ex.Message, Data: log); } finally { db.Database.Log = old; } return Win(Data: logSuccess ? log : null); }I was going to delete this instead of posting, but I just accidentally deleted the file I'd created it in instead of committing it and came back here to retrieve it from draft, so I figure I shouldn't fight divine providence.
Take a shit, place it in your hand, smear it on his face.
Is there any reasonably good resources to learn Java online? Or is a textbook going to be the best bet? I'm in Australia, so a lot of seemingly fantastic American textbooks will be a pain to get over here, and I was hoping to find something online, but so far everything I've turned up with Google has been not so useful.
Most of them have seemed like great Java tutorials for an experienced programmer of other languages, but fallen flat for an actual programming novice, which is what I am.
Maybe that one @Dhalphir ?
For example, the first program it has you write after Hello World is an example to demonstrate enums
The concept of enums seems simple enough, it's a restricted variable
but here is the code they use.
Example: class FreshJuice { enum FreshJuiceSize{ SMALL, MEDIUM, LARGE } FreshJuiceSize size; } public class FreshJuiceTest { public static void main(String args[]){ FreshJuice juice = new FreshJuice(); juice.size = FreshJuice. FreshJuiceSize.MEDIUM ; System.out.println("Size: " + juice.size); } }zero explanation for any of that. I understand that enum FreshJuiceSize{ SMALL, MEDIUM, LARGE } declares the variable's restrictions
and I understand the println line
but I don't really understand what they are doing with "FreshJuiceSize size;" and
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice. FreshJuiceSize.MEDIUM ;
and they don't explain any of it. I'm assuming that the line referring to medium is where they declare what the variable actually is for the purpose of the printout
Deitel & Deitel make some good "beginner" books. You'll get a lot of people that harp on them, but I found them pretty decent.
http://www.amazon.com/exec/obidos/ASIN/0131426486/deitelassociatin
Then follow it up with
http://www.amazon.com/exec/obidos/ASIN/0133807800/deitelassociatin
You might be able to start with that bottom one, though. Check them out.
This is going to happen regardless and will happen with about 90% of all programming tutorials unfortunately. There will be a lot of "how in the fuck...?" moments when learning your first language.
Yeah, it's a downside of object oriented programming. There's a lot of structure around how things work that you could spend a long time figuring out.
Instead, most tutorials are going to start with a lot of handwaving. They'll go back and explain why things are the way they are later.
public static void main(String args[]){is my favorite instance of this.
When I learned Java, my teacher just said to accept that this is the code that means "start my program here", but then in a few months, we knew everything about that line and why it made the program start.
I don't think there's a good resource to learn how to program in Java online (as opposed to learning the Java programming language itself). My recommendation is this book:
http://www.buildingjavaprograms.com/
Which is what I have used in the classroom before—it's simply excellent, and it is focused on learning how to program rather than learn Java minutiae.
@Dhalphir If you can't find a copy easy (you can buy an ebook version), PM me, and I'll see what I can do...
I want to learn how to program...online, ie, put a tutorial of something up on a secondary monitor while I code in a primary monitor. That ebook looks pretty good.
I'll add you as a friend on Steam Kambing, I can't believe I haven't already.
Take things as they come and if you have no idea what it does then either: open a new tab and google "java enum tutorial", or assume what's going on is "automagical" and revisit at a later time.
The core of Java 1.7 is almost no different than Java 1.4.
Not appreciably, anyways, the language differences might be enjoyed by someone like you and me, not by someone learning.
Would you be upset if I recommended a C++ book written by Stroustrup that talks about c++98 over c++11 ?
But an int32 is an int32 and an if/else is an if/else!
They should be explaining what enums are, though, if it's being brought up in a code example. Even if it's "we'll talk about this more in chapter 5".
Or crack open an IDE and type it in yourself and see what happens and if it works. Then step through the code. I can't really say what that tutorial is doing though. If they don't eventually explain the structure of an enum on an enum tutorial then I'd say it's a bad tutorial.
Only if things being taught are deprecated in the future releases and I have the later versions installed on my machine.
Yes, particularly for a total beginner. Lots of languages, and java especially, have a certain hump you have to get over in order to understand enough to make a workable program. Most tutorial writers will give you workable code chunks without expecting you to understand everything in them. Most people prefer to have an actual working example rather than go step by step through every single building block before you can actually run code.
The only thing I can think of that might be a big deal would be generics. That was a pretty big change.
http://docs.oracle.com/javase/7/docs/api/deprecated-list.html
Nothing worthwhile.
Even if it'd deprecated, it still works. Because Java :rotate:
last question.
I'm assuming since nobody pounced on my choice of Java as a first programming language that it's a pretty reasonable choice? I mainly selected it because it seems pretty versatile as a language - able to wear many hats, and similar enough to most other common languages that branching out later wouldn't be too difficult.
Ah, Sun. Those were the days.