|
Internet Janitor posted:One of the strangest behaviors I have observed in lab courses is a behavior I call "soup programming", in which students read a problem description, add several loops, conditionals and variables to a procedure body and then proceed to spend half an hour rearranging those elements to try to get the result to compile, as if programming were a matter of selecting the correct ingredients and stirring. Usually when I help students who are doing this I tell them to step away from the keyboard and try to explain the problem and their approach to solving it verbally- if you can't explain something to a person you can't explain it to a computer. I found that students like that often would take that same approach to math and physics problems too. I turned down a couple of offers to become a CS tutor because I knew that kind of person would do nothing but frustrate me.
|
# ? Oct 28, 2013 18:06 |
|
|
# ? Apr 27, 2024 12:26 |
|
PrBacterio posted:Oh the fun you would have with the code base at my place of work. If even that (comparatively) insignificant little spelling mistake is enough to set you off I'd like to see your reaction to the kind of stuff I deal with every day Its usual when you have indian coders, For instance we have a class for mandatory fields in the CSS called .mondatory {} and the error messages reported on the webservices "Username and Password not match"
|
# ? Oct 28, 2013 21:35 |
|
Plorkyeran posted:The "if loop" idea sort of makes sense to me - while repeats 0 to N times, do ... while repeats 1 to N times, and if repeats 0 to 1 times. It's not a very useful way of thinking about things, but I'm not sure it's entirely wrong. When you look under the hood, they're all just conditional jumps!
|
# ? Oct 28, 2013 21:47 |
|
Plorkyeran posted:The "if loop" idea sort of makes sense to me - while repeats 0 to N times, do ... while repeats 1 to N times, and if repeats 0 to 1 times. It's not a very useful way of thinking about things, but I'm not sure it's entirely wrong. Not quite the same thing, but how about a while-else? code:
|
# ? Oct 28, 2013 21:59 |
|
TheresaJayne posted:Its usual when you have indian coders, I consider "things being misspelled or egregiously grammatically incorrect" to be grounds for a code review failure.
|
# ? Oct 28, 2013 22:05 |
|
Suspicious Dish posted:In other words, they reinvented TCP on top of TCP. Having worked at the same company this doesn't surprise me one bit, considering their IT strategy was "never hire full-time staff, get short-term contractors from degree mills with a tenuous grasp of programming concepts". There's the story I mentioned earlier where some contractor cached the HTML of a site header for every unique visitor to a PHP site, except they saved it to a MySQL table, resulting in 2+ GB taking up the DB server (and subsequently that "temporary" data was backed up nightly up to 7 times). I guess the silver lining is they didn't use memcache/PDO and cause the servers' OOM killer to engage or something. The other biggest coding horrors I had to deal with was just working with PHP and IE7 compat in general, along with coworkers oblivious to source control (hello .php.1 .php.bak files in production!!) and still using the mysql_ functions.
|
# ? Oct 28, 2013 22:17 |
|
erotic dad posted:(hello .php.1 .php.bak files in production!!) I have a co-worker who does that, and it's baffling. We're already using source control, there's literally no reason to do what he does. He also leaves giant chunks of code commented out. Having big comment-chunks is fine when you're actively developing, but for the love of god, clean it up before you check the code in.
|
# ? Oct 28, 2013 23:48 |
|
Ithaqua posted:I consider "things being misspelled or egregiously grammatically incorrect" to be grounds for a code review failure. Outsourced modules to lowest-bidder offshore contractors go through code review? BigRedDot posted:Not quite the same thing, but how about a while-else? I'm rather surprised that even works, but why? Isn't it identical to code:
|
# ? Oct 29, 2013 01:37 |
Harik posted:I'm rather surprised that even works, but why? Isn't it identical to Best guess: What if you break out of the loop?
|
|
# ? Oct 29, 2013 01:42 |
|
nielsm posted:Best guess: What if you break out of the loop? "welp"
|
# ? Oct 29, 2013 01:47 |
|
nielsm posted:Best guess: What if you break out of the loop? Yup, that's it: code:
code:
|
# ? Oct 29, 2013 02:01 |
|
I find it amusing to read about the 'if loops' right after I spent some time today at work preprocessor macros around the do { } while(0) paradigm.
|
# ? Oct 29, 2013 02:53 |
|
In Dijkstra's A Discipline of Programming, he presents a procedural, nondeterministic programming language referred to elsewhere as the "Guarded Command Language", which has two control-flow constructs- if and do. Both contain a body composed of one or more boolean expressions (guards), each associated with a block. An if will execute one guarded block (matching no blocks is considered an error), and a do will continue executing blocks until no guards are satisfied. You might implement Euclid's algorithm like so:code:
|
# ? Oct 29, 2013 03:14 |
|
.
Nickopops fucked around with this message at 09:37 on Nov 1, 2019 |
# ? Oct 29, 2013 05:24 |
|
Nickopops posted:I saw plenty of students do a series of 40 if statements How else would you do it?
|
# ? Oct 29, 2013 05:46 |
|
It sounds a lot like an introduction to data structures (specifically maps). You know, you introduce the problem, let them solve it the hard way, and then they have context for why this new concept you're introducing is actually useful.
|
# ? Oct 29, 2013 06:09 |
|
Suspicious Dish posted:How else would you do it? Switch statement? Unless there was some obvious pattern to the values, of course.
|
# ? Oct 29, 2013 06:53 |
|
Suspicious Dish posted:How else would you do it?
|
# ? Oct 29, 2013 10:00 |
|
code:
|
# ? Oct 29, 2013 10:12 |
|
It this some kind of Hungarian Notation lover's idea of database schemas? "Need a primary key? Easy! Just prefix your column name 'pk-'. No more mucking about with all that SQL stuff."
|
# ? Oct 29, 2013 10:55 |
|
Yes, all tables are prefixed with tbl and all procedures with sp. Why do you ask?
|
# ? Oct 29, 2013 11:50 |
|
.
Nickopops fucked around with this message at 09:37 on Nov 1, 2019 |
# ? Oct 29, 2013 12:20 |
|
Yeah, for a bunch of maths students, I wasn't expecting a lookup table to be taught.
|
# ? Oct 29, 2013 14:39 |
|
It turns out that the fix was made by another person trying to quell the terrible codebase. I cannot fault him too much.
EntranceJew fucked around with this message at 20:57 on Oct 29, 2013 |
# ? Oct 29, 2013 17:07 |
|
So I'm finishing up a task and run the unit tests in the project quickly to make sure I'm not breaking anything and get distracted by something else. Come back a few minutes later to check on it and see that it's still running. What the.... 10 minutes later they finally finish. Do some investigation and find out someone just checked in a new class and with that class some tests, 4 of which took exactly 2:30. Well this is odd, lets see what's going on. code:
|
# ? Oct 29, 2013 18:22 |
|
Mr. Crow posted:So I'm finishing up a task and run the unit tests in the project quickly to make sure I'm not breaking anything and get distracted by something else. Come back a few minutes later to check on it and see that it's still running. What the.... Let me guess: it's a timeout test, and the timeout value is something that's hard-coded.
|
# ? Oct 29, 2013 18:24 |
|
Ithaqua posted:Let me guess: it's a timeout test, and the timeout value is something that's hard-coded. Of course.
|
# ? Oct 29, 2013 18:59 |
|
So the verdict is back on the Toyota runaway acceleration problem. I remember saying at the time, "It's a problem with the throttle firmware". It's a problem with the throttle firmware. The paragraph that jumped out at me as the worst: quote:The Camry ETCS code was found to have 11,000 global variables. Barr described the code as “spaghetti.” Using the Cyclomatic Complexity metric, 67 functions were rated untestable (meaning they scored more than 50). The throttle angle function scored more than 100 (unmaintainable).
|
# ? Oct 29, 2013 22:01 |
|
Paul MaudDib posted:So the verdict is back on the Toyota runaway acceleration problem. I remember saying at the time, "It's a problem with the throttle firmware". It gets better. quote:A litany of other faults were found in the code, including buffer overflow, unsafe casting, and race conditions between tasks. This sounds like code horror hall of fame right here.
|
# ? Oct 29, 2013 22:52 |
|
quote:A litany of other faults were found in the code, including buffer overflow, unsafe casting, and race conditions between tasks. The more things change, the more they stay the same. Think of the twisted, gnarled mess of a codebase you have to deal with. Think of your willfully-ignorant, recalcitrant coworkers that couldn't code their way out of a paper bag. Think of how your attempts to gently bend the arc of the project ever so slightly towards sanity and maintainability have been ignored, rebuffed, or met with outright anger and scorn. Now imagine that instead of being a lovely web app or a throwaway science experiment, your code is responsible for people's safety and well-being on a daily basis. I don't think I'd be able to sleep at night.
|
# ? Oct 30, 2013 00:47 |
|
HORATIO HORNBLOWER posted:The more things change, the more they stay the same. Think of the twisted, gnarled mess of a codebase you have to deal with. Think of your willfully-ignorant, recalcitrant coworkers that couldn't code their way out of a paper bag. Think of how your attempts to gently bend the arc of the project ever so slightly towards sanity and maintainability have been ignored, rebuffed, or met with outright anger and scorn. Now imagine that instead of being a lovely web app or a throwaway science experiment, your code is responsible for people's safety and well-being on a daily basis. I don't think I'd be able to sleep at night. Oh, and we needed it done yesterday. If one of Toyota's structural engineers said "we need another month to make sure this doesn't fall apart" they'd say "oh poo poo, ok, fix it". But software? Nope, looks like it works, ship it! Honestly I'm not sure I could keep that job in good conscience. "Boss, I need an extra month to fix this up or I'm out." I'd eat my words so loving fast. Why don't more programmers stand up for some refactoring time? Just make it part of the process. Stick an if (!refactored) abort(); at the top of main(). Call it necessary for your job. Take some ownership. Am I talking bullshit here? Or can programmers actually take control of this? We know it's a bad idea, but we sign off on it.
|
# ? Oct 30, 2013 01:09 |
|
Programmers can unionize. Why that will never happen is a giant can of worms.
|
# ? Oct 30, 2013 01:12 |
|
Slashdot really dislikes the idea (libertarians) but I think lawsuits based on reckless development will probably help there. It's a life-critical system, and Toyota blew off the prevailing standard at the time. 7 years to comply with the tests is not unreasonable, and I'm sure bug trackers existed by 2005. Hopefully they will recall the controllers. There ought to be some equivalent of Professional Engineers for software systems. Someone authorized to sign off (or not) on the accuracy of the design and process with their name, perhaps with differing levels of credentials. A union is certainly a historic model for that. Would Three-Phase sign off on this system? Paul MaudDib fucked around with this message at 01:58 on Oct 30, 2013 |
# ? Oct 30, 2013 01:23 |
|
I sort of wonder if other engineering disciplines fight the same challenges: a mix of carelessness, bad engineers, and tight budgets mean that a ceiling falls somewhere. I can't imagine this stuff is only applicable to software.
|
# ? Oct 30, 2013 02:08 |
libcxx posted:Programmers can unionize. Why that will never happen is a giant can of worms. Because, as is now apparent, anyone can replace you - and even in a company as big as Toyota, where your job is as important as making sure cars dont loving drive off without input from their driver.
|
|
# ? Oct 30, 2013 02:12 |
|
Manslaughter posted:Because, as is now apparent, anyone can replace you - and even in a company as big as Toyota, where your job is as important as making sure cars dont loving drive off without input from their driver. Actually there's a magic key combo, the trick is to release the brake for a bit which restarts or un-deadlocks the gas pedal task. Cars of the future... Paul MaudDib fucked around with this message at 02:19 on Oct 30, 2013 |
# ? Oct 30, 2013 02:15 |
|
pokeyman posted:Why don't more programmers stand up for some refactoring time? Just make it part of the process. Stick an if (!refactored) abort(); at the top of main(). Call it necessary for your job. Take some ownership. In the Agile shops I've worked in, we've just built refactoring/unit testing time right into estimates. Management didn't know (or care) what the actual tasks were -- they cared that they were getting their user stories completed and they really cared that customers were experiencing horrible bugs less frequently.
|
# ? Oct 30, 2013 02:23 |
|
Suspicious Dish posted:I sort of wonder if other engineering disciplines fight the same challenges: a mix of carelessness, bad engineers, and tight budgets mean that a ceiling falls somewhere. I know a guy that manually checks blueprints that the architects hand him because if he built to their specifications, the buildings would have collapsed in on themselves seven times over and violated a slew of construction codes. It happens more than you should feel safe about.
|
# ? Oct 30, 2013 02:29 |
|
BigRedDot posted:Not quite the same thing, but how about a while-else? http://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops. The only problem I have with for-else in python is that some templating engines use for-else to check if the loop condition isn't true on the very first iteration. Like what Twig does: http://twig.sensiolabs.org/doc/tags/for.html#the-else-clause. So when I switch from writing Twig templates to Jinja templates, I always have weird display errors.
|
# ? Oct 30, 2013 02:31 |
|
|
# ? Apr 27, 2024 12:26 |
|
pokeyman posted:Oh, and we needed it done yesterday. I have no evidence for this, but my gut feeling is that the vast majority of people out there who can write code barely understand what they're doing, much less understand what good code is. In other words, 90% of them don't give a poo poo. Programmer A who knows his poo poo says "This project will take 18 months". Programmer B who doesn't know his poo poo says "Pfft, this will take 6 months tops". Management goes with Programmer B. Most of the time the software works for some definition of "works".
|
# ? Oct 30, 2013 03:28 |