Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

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. :sigh: 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.

Adbot
ADBOT LOVES YOU

TheresaJayne
Jul 1, 2011

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 :allears:

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"

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

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! :v:

BigRedDot
Mar 6, 2008

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:
n = 5
while n != 0:
    print n
    n -= 1
else:
    print "welp"

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

TheresaJayne posted:

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"

I consider "things being misspelled or egregiously grammatically incorrect" to be grounds for a code review failure.

sturgeon general
Jun 27, 2005

Smells like sushi.

Suspicious Dish posted:

In other words, they reinvented TCP on top of TCP.

I hate that people learn the word "packet" when it comes to networking. YOU DO NOT NEED TO CARE ABOUT PACKETS. The abstraction layer TCP gives you is a bidirectional stream of bytes. grr.... this isn't the first time I've seen this, either.

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.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

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.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

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? :allears:


BigRedDot posted:

Not quite the same thing, but how about a while-else?

code:
n = 5
while n != 0:
    print n
    n -= 1
else:
    print "welp"

I'm rather surprised that even works, but why? Isn't it identical to
code:
n = 5
while n != 0:
    print n
    n -= 1
print "welp"
Unless there's some subtlety I'm missing, a quick test shows that the print welp is unconditional - if it at least only triggered when the initial loop was false it'd have some semantic value.

nielsm
Jun 1, 2009



Harik posted:

I'm rather surprised that even works, but why? Isn't it identical to
code:
n = 5
while n != 0:
    print n
    n -= 1
print "welp"
Unless there's some subtlety I'm missing, a quick test shows that the print welp is unconditional - if it at least only triggered when the initial loop was false it'd have some semantic value.

Best guess: What if you break out of the loop?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





nielsm posted:

Best guess: What if you break out of the loop?

"welp"

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

nielsm posted:

Best guess: What if you break out of the loop?

Yup, that's it:
code:
def foo(n):
	while n != 0:
		print n
		n -= 1
		if n == 0:
			break
	else:
		print "welp"


foo(0)
foo(2)
returns:
code:
welp
2
1
So it has some kind of meaning, I guess. It's non-obvious enough that I'd consider it a coding horror on sight.

Hughlander
May 11, 2005

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.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
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:
a, b := 54, 24;
do
  b > 0 : a, b := b, a % b
od;
print a
There was something about this formulation- perhaps how the syntax and semantics make loops more like a natural counterpart to conditionals- which struck me as particularly elegant. Maybe the beginners are onto something?

Nickopops
Jan 8, 2006
You must be this funky to ride.
.

Nickopops fucked around with this message at 09:37 on Nov 1, 2019

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Nickopops posted:

I saw plenty of students do a series of 40 if statements

How else would you do it?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
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.

MrBadidea
Apr 1, 2009

Suspicious Dish posted:

How else would you do it?

Switch statement? Unless there was some obvious pattern to the values, of course.

Rottbott
Jul 27, 2006
DMC

Suspicious Dish posted:

How else would you do it?
Lookup table.

zokie
Feb 13, 2006

Out of many, Sweden
code:
[pkLONGASSTABLENAMEId]
,[Name]
,[Code]
,[fkANOTHERLONGASSTABLENAMEIdNormal]
,[fkANOTHERLONGASSTABLENAMEIdSpecial]
,[fkANOTHERLONGASSTABLENAMEIdSpecial2]
,[fkANOTHERLONGASSTABLENAMEIdSpecial4]
,[fkANOTHERLONGASSTABLENAMEIdSpecial9]
,[fkANOTHERLONGASSTABLENAMEIdSpecial11]
,[fkANOTHERLONGASSTABLENAMEIdSpecial13]
,[fkANOTHERLONGASSTABLENAMEIdSpecial17]
,[fkANOTHERLONGASSTABLENAMEIdSpecial1223]
,[fkANOTHERLONGASSTABLENAMEIdSpecial22]
,[CreateDate]
,[CreateBy]
,[ChangeDate]
,[ChangeBy]
I don't know whether to kill myself or my boss...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
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."

zokie
Feb 13, 2006

Out of many, Sweden
Yes, all tables are prefixed with tbl and all procedures with sp. Why do you ask?

Nickopops
Jan 8, 2006
You must be this funky to ride.
.

Nickopops fucked around with this message at 09:37 on Nov 1, 2019

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yeah, for a bunch of maths students, I wasn't expecting a lookup table to be taught.

EntranceJew
Nov 5, 2009

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

Mr. Crow
May 22, 2008

Snap City mayor for life
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:
            //wait at least 2.5 minutes
            System.Threading.Thread.Sleep((150 * 1000));
In every one.

:cry:

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

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....

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:
            //wait at least 2.5 minutes
            System.Threading.Thread.Sleep((150 * 1000));
In every one.

:cry:

Let me guess: it's a timeout test, and the timeout value is something that's hard-coded.

Mr. Crow
May 22, 2008

Snap City mayor for life

Ithaqua posted:

Let me guess: it's a timeout test, and the timeout value is something that's hard-coded.

Of course. :whatup:

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
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).

Toyota loosely followed the widely adopted MISRA-C coding rules but Barr’s group found 80,000 rule violations. Toyota's own internal standards make use of only 11 MISRA-C rules, and five of those were violated in the actual code. MISRA-C:1998, in effect when the code was originally written, has 93 required and 34 advisory rules. Toyota nailed six of them.

Barr also discovered inadequate and untracked peer code reviews and the absence of any bug-tracking system at Toyota.
http://www.edn.com/design/automotive/4423428/Toyota-s-killer-firmware--Bad-design-and-its-consequences

:staredog:

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

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's a problem with the throttle firmware.

The paragraph that jumped out at me as the worst:

http://www.edn.com/design/automotive/4423428/Toyota-s-killer-firmware--Bad-design-and-its-consequences

:staredog:

It gets better.

quote:

A litany of other faults were found in the code, including buffer overflow, unsafe casting, and race conditions between tasks.

:catstare: This sounds like code horror hall of fame right here.

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance

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.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

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.

libcxx
Mar 15, 2013
thread_local post<shit> shit_post("lol if u");
Programmers can unionize. Why that will never happen is a giant can of worms.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
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

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
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.

Polio Vax Scene
Apr 5, 2009



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.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE

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

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

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.

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.

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.

EntranceJew
Nov 5, 2009

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 can't imagine this stuff is only applicable to software.

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.

Coffee Mugshot
Jun 26, 2010

by Lowtax

BigRedDot posted:

Not quite the same thing, but how about a while-else?

code:
n = 5
while n != 0:
    print n
    n -= 1
else:
    print "welp"

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.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

pokeyman posted:

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.

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".

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply