|
Ithaqua posted:Not according to what he said -- they're duplicating functionality. The common functionality needs to be implemented in the base class in a non-virtual method, which possibly calls some virtual/abstract methods that contain differing, implementation-specific code. quote:The horror is that the base has all of it's member functions implemented as no-ops
|
# ? Oct 26, 2011 01:14 |
|
|
# ? Apr 27, 2024 13:16 |
|
PrBacterio posted:I hadn't read the part about all of the derived classes being copy&pastes of one another which *does* sound like all that code ought to have gone in the base class instead. It's this. I'm fully aware of what an interface is, and I do think that these two classes should implement themselves in terms of A. The problem I have is that out of all of the member functions in A, only two of them have any business being overridden in a derived class. Instead, the entire class got copied, and the implementation was stripped completely out of A.
|
# ? Oct 26, 2011 01:39 |
w00tz0r posted:It's this. I'm fully aware of what an interface is, and I do think that these two classes should implement themselves in terms of A. The problem I have is that out of all of the member functions in A, only two of them have any business being overridden in a derived class. Instead, the entire class got copied, and the implementation was stripped completely out of A. If this is C++, I've seen people do that repeatedly, in order to mimic Java structure by creating a "pure" interface. Their normal course from there, though, is to create an abstract implementation of that interface for any common functionality.
|
|
# ? Oct 26, 2011 10:51 |
|
The person who wrote that horror needs to be hit over the head with a manual explaining the differences between Java's and C++'s OO models. The copy/pasting or calling an object-external 'doSomething' is common in Java because you can't do multiple inheritance. Think KeyboardHandler and MouseHandler being partial implementation of the same Handlers abstract class; need a KeyboardAndMouseHandler, better start copy pasting buddy. The least they could do is to make the virtual function pure in the abstract class, goddamn.
|
# ? Oct 26, 2011 15:00 |
|
code:
|
# ? Oct 26, 2011 20:37 |
|
baquerd posted:
It is... beautiful
|
# ? Oct 26, 2011 20:47 |
|
baquerd posted:
Bravo
|
# ? Oct 26, 2011 20:53 |
|
baquerd posted:
I feel like this should be in an art gallery somewhere.
|
# ? Oct 26, 2011 20:56 |
|
I recently had to look into some code that a contractor wrote last year that inexplicably takes much longer when processing multiple warehouses than a single warehouse.code:
|
# ? Oct 26, 2011 21:49 |
|
That reads like one of those dumb Xzibit memes: "Yo dawg I heard you liked ShippingMethods...", etc.
|
# ? Oct 26, 2011 21:53 |
|
loinburger posted:I wish he hadn't been fired so I could ask him what the hell he was thinking. Well, either he was saving it for "optimization overtime" later, or he wanted to make really sure that the shipping method was valid. By comparing it to itself.
|
# ? Oct 26, 2011 22:42 |
|
I like to give code like that the benefit of the doubt, and assume there was more code there at one point that made that at least somewhat logical, then that code was removed and it didn't occur to him to refactor. Then again, in some ways that's even worse.
|
# ? Oct 26, 2011 23:20 |
|
SlightlyMadman posted:I like to give code like that the benefit of the doubt, and assume there was more code there at one point that made that at least somewhat logical, then that code was removed and it didn't occur to him to refactor. Then again, in some ways that's even worse. This is the true reason for source control. Not for rollbacks, but for laughs after the fact.
|
# ? Oct 26, 2011 23:46 |
|
OriginalPseudonym posted:This is the true reason for source control. Not for rollbacks, but for laughs after the fact. "svn blame" is possibly the best thing to ever have happened in computer history.
|
# ? Oct 27, 2011 00:12 |
|
I'm not really sure what this was supposed to be used for. Written by some dude a year ago, who left where I work before I got there. This is all that was in the file. php:<? $gConfig = array(); require "../../../config/config.php"; $db_connection_str = "host=" . $gConfig['db']['event']['host'] . " dbname=" . $gConfig['db']['event']['name'] . " user=" . $gConfig['db']['event']['user'] . " password=" . $gConfig['db']['event']['password']; $db_connection = pg_pconnect($db_connection_str); $stmt = "select * from _event where event_id = " . $_POST['event_id']; $result = pg_query($db_connection, $stmt); if( pg_num_rows($result) > 0 ){ $handle = fopen("../site/config/config.txt", "w"); fwrite($handle, $_POST['event_id']); fclose($handle); $url = "index.php"; } else{ $url = "index.php?error=event_id_error&&event_id=" . $_POST['event_id']; } header( "Location: $url" ); ?>
|
# ? Oct 27, 2011 00:33 |
|
Optimus Prime Ribs posted:I kind of want to see what's in the event table. Either he has a really poorly named log file, or he's dynamically generating a config file for another script based on database output...?
|
# ? Oct 27, 2011 00:42 |
|
Well hello there thread, how ya been.code:
|
# ? Oct 27, 2011 01:32 |
|
loinburger posted:I recently had to look into some code that a contractor wrote last year that inexplicably takes much longer when processing multiple warehouses than a single warehouse. What industry are you in? I had to write almost identical code for my last job in ecommerce/drop shipping. (minus the horror of course)
|
# ? Oct 27, 2011 01:42 |
|
npe posted:Well hello there thread, how ya been. Load-bearing variable assignment, because having just one didn't work. Although this probably isn't one, this has always been the best way to fix a race condition, along with debug print statements.
|
# ? Oct 27, 2011 01:57 |
|
code:
|
# ? Oct 27, 2011 03:12 |
OriginalPseudonym posted:Load-bearing variable assignment, because having just one didn't work. Although this probably isn't one, this has always been the best way to fix a race condition, along with debug print statements. Nah, it isn't trying to do the same thing multiple time to get over race conditions or so. It actually removes up to three leading zeroes in pageNum.
|
|
# ? Oct 27, 2011 03:35 |
|
clockwork automaton posted:
what in sweet gently caress
|
# ? Oct 27, 2011 05:47 |
|
clockwork automaton posted:I don't like grading (I don't teach this class, I promise).
|
# ? Oct 27, 2011 06:49 |
|
Does any university offer a course like "Learn not to be a poo poo coder by looking at other people's poo poo code" Because I bet you could get infinite material from old programming assignments (anonymized, of course)
|
# ? Oct 27, 2011 07:32 |
|
Wheany posted:Does any university offer a course like "Learn not to be a poo poo coder by looking at other people's poo poo code" Eh, looking at terrible student code isn't going to accomplish anything. If you want to learn you need to seek out terrible code written by professionals.
|
# ? Oct 27, 2011 09:40 |
|
For nearly all programming assignments our students have to come defend their code in person. This gives us ample opportunity to tell them how and why they absolutely suck at coding.
|
# ? Oct 27, 2011 11:13 |
|
clockwork automaton posted:
TBH that looks like an excellent teaching opportunity.
|
# ? Oct 27, 2011 11:23 |
|
Scaramouche posted:What industry are you in? I had to write almost identical code for my last job in ecommerce/drop shipping. (minus the horror of course) Same industry. Another piece of code I had to rewrite from the same contractor was the box-packing algorithm - the way the contractor's code put items in boxes was "If the items' dimensions fit in the empty box, and there is sufficient unused volume in the box, then the item fits!" In other words, given a 12x12x12 box (volume 1728) and three 8x8x8 items (combined volume 1536), the algorithm would put all three items in the box, even though this is sort of impossible. When I rewrote the algorithm to prevent overlapping boxes, the QA guy on the project complained that the new algorithm used more box volume than the old algorithm. loin: That's because the old algorithm allowed boxes to overlap. QA Guy: Well, we never worried about overlapping boxes before. loin: I suggest we start worrying about it.
|
# ? Oct 27, 2011 13:52 |
|
clockwork automaton posted:
OK, i decided to decipher what this does as a brain teaser...was the title of the assignment "Print all continuous string of non-control ASCII characters with a length of 4 or more from a file" or something?
|
# ? Oct 27, 2011 14:25 |
|
Optimus Prime Ribs posted:I'm not really sure what this was supposed to be used for. Written by some dude a year ago, who left where I work before I got there. How quickly you forget! Clearly it's there to write out this config file: Optimus Prime Ribs posted:Found this in the backend for our CMS:
|
# ? Oct 27, 2011 14:25 |
|
code:
code:
|
# ? Oct 27, 2011 16:41 |
|
http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryExceptionquote:Hi,
|
# ? Oct 27, 2011 16:46 |
|
bear shark posted:http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryException I don't always edit code, but when I do, I have to use cat and tail.
|
# ? Oct 27, 2011 17:05 |
|
bear shark posted:http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryException How do you write 100,000 lines of code in a single file before you think to yourself "surely there's a better way to organize this"?
|
# ? Oct 27, 2011 17:06 |
|
shodanjr_gr posted:OK, i decided to decipher what this does as a brain teaser...was the title of the assignment "Print all continuous string of non-control ASCII characters with a length of 4 or more from a file" or something? Yes. Also I don't work directly with any of the students for this class (I am a TA for a different class and just a grader for this one), but I did leave comments for how this could be written to be more sane. I would actually like some class here to at least mention refactoring or at least teach them what makes good code good. This particular class teaches them that "goto" is bad, but doesn't really step any further than that.
|
# ? Oct 27, 2011 17:20 |
|
Ah yes, I can see it now..baquerd posted:
Inverse Icarus posted:
"Beauty and Rage", Museum of Modern Programming, 2011.
|
# ? Oct 27, 2011 17:32 |
|
clockwork automaton posted:Yes. Also I don't work directly with any of the students for this class (I am a TA for a different class and just a grader for this one), but I did leave comments for how this could be written to be more sane. I would actually like some class here to at least mention refactoring or at least teach them what makes good code good. This particular class teaches them that "goto" is bad, but doesn't really step any further than that. Well, at least that guy got it right :P. When I was a grader for a CSE 2xx course (Foundations of Computer Science) and the students had to turn in some basic code in (I believe) OCAML (and ONLY that), I had the joy of receiving assignments in anything from C, C++, BASIC to freaking pseudo code. The joys of grading...
|
# ? Oct 27, 2011 17:35 |
|
SlightlyMadman posted:How quickly you forget! Clearly it's there to write out this config file: Well I know what it's doing. I just don't know what purpose it serves. Maybe the dude really badly wanted to assign an event id to the text file using POST data, and do literally nothing else. Makes me wonder why he didn't just use a GET variable in the URL for the id.
|
# ? Oct 27, 2011 18:01 |
|
Optimus Prime Ribs posted:Well I know what it's doing. I just don't know what purpose it serves. In a week you'll have found the PHP script that's being run by cron that posts back to that config file.
|
# ? Oct 27, 2011 18:04 |
|
|
# ? Apr 27, 2024 13:16 |
|
OriginalPseudonym posted:In a week you'll have found the PHP script that's being run by cron that posts back to that config file. No, it loads that script that pulls the event id from config.txt, then writes it to the database.
|
# ? Oct 27, 2011 18:33 |