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
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Fortunately I didn't list "posting in the right thread" on my resume.

Adbot
ADBOT LOVES YOU

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
Yeah I'm definitely getting the gently caress out of this place.

So like globals are bad in PHP, yeah, since it's really unsafe mutable state. But normally you only really have to worry about stuff happening in your top-level file, since that's usually where your globals get pulled from.

php:
<?
function close_invoice_proc(...)
{
    global $checknum_storage;
    ...
    $checknum_storage = array();
    ...
    $controlnum = maintain_checknums($row);
    ...
    updateFinalResults($database, $userid, $output, $checknum_storage);
    ....
}
?>
No problem, right? Odd that we are passing an empty parameter to that function that doesn't get used after, but whatever. "Wait, what do you mean it has a value there? I checked the file that includes this one, it's empty too..."

See that innocuous-seeming function call in the middle?

php:
<?
function maintain_checknums($row)
{
    global $checknum_storage;
    ...
    // do stuff to $checknum_storage
}
?>
Welcome to hell.

xzzy
Mar 5, 2009

That is one hell of a booby trap. That has to be malice, right?

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

xzzy posted:

That is one hell of a booby trap. That has to be malice, right?

It looks like mathperson code. Here's some mathperson code from my company (variable names changed to protect the innocent)
code:
;(dev name) this is the only comment in the file

dxg
  s zd = l
  s:isJ ^zdw(zd,l) = n
  q
That subroutine has 4 assumed variables. None of them are defined in (or even used at all in) any of the subroutines that directly call this one. I traced 2 more hops out from each of those and still didn't find these variables. This function is basically unupdatable because it's assuming variables that we basically just can't find where they're being defined to say with enough confidence whether changes to it will break things. We'd basically just have to delete the routine and then to end-to-end testing on the whole product to find everything that stopped working. This code has been there since the 90s and it just kinda hangs out because nobody's even really sure wtf it does at this point, just that it definitely breaks something if you touch it.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

xzzy posted:

That is one hell of a booby trap. That has to be malice, right?

LeftistMuslimObama posted:

It looks like mathperson code.

Nope, just massive idiocy. I've sat down with the guy who wrote this (and other stuff that was slightly less bad) to explain why globals are bad. I tried to explain that if you add mutable state you get data that you can't trust, and his response was "I know you can't trust it, that's why when I write my functions I check the values first."

:psyduck:

php:
<?
global $database, $checknum_storage, $current_date_time, $current_date;
extract($row);
if (!isset($mastercustcode_custcode)) {
    $mastercustcode_custcode = $custcode;
}
if (!isset($current_date_time)) {
    $current_date_time = date('H:i:s', strtotime(date('Y/m/d H:i:s')));
}
if (!isset($current_date)) {
    $current_date = date('m/d/Y', strtotime(date('Y/m/d H:i:s')));
}
?>
Yeah, he wasn't kidding.

xzzy
Mar 5, 2009

I wonder how many times he writes that validation code before he realizes he could save a lot of typing by breaking it off into its own function. That relies on globals, of course.

QuarkJets
Sep 8, 2008

LeftistMuslimObama posted:

It looks like mathperson code. Here's some mathperson code from my company (variable names changed to protect the innocent)
code:
;(dev name) this is the only comment in the file

dxg
  s zd = l
  s:isJ ^zdw(zd,l) = n
  q
That subroutine has 4 assumed variables. None of them are defined in (or even used at all in) any of the subroutines that directly call this one. I traced 2 more hops out from each of those and still didn't find these variables. This function is basically unupdatable because it's assuming variables that we basically just can't find where they're being defined to say with enough confidence whether changes to it will break things. We'd basically just have to delete the routine and then to end-to-end testing on the whole product to find everything that stopped working. This code has been there since the 90s and it just kinda hangs out because nobody's even really sure wtf it does at this point, just that it definitely breaks something if you touch it.

I have to deal with this kind of poo poo pretty frequently where I work. It seems like all of the really good Fortran libraries were written by nice people who commented their highly-optimized code, and then everyone else decided to just scrawl their name at the top and write code that's as obfuscated as possible.

I once had to gently caress around with a Fortran function that took as input 17 variables, all named a single letter, with no comments or documentation, and the original author died over a decade ago.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

xzzy posted:

I wonder how many times he writes that validation code before he realizes he could save a lot of typing by breaking it off into its own function. That relies on globals, of course.

Yeah he just stopped writing validation code completely instead. :shepicide:

I realized a while ago that the reason he writes all of these crazy globals is that he keeps ending up with functions that have a dozen parameters or more. This frustrates him (since he calls these functions everywhere, and he'd have to keep writing these parameters all the time), but instead of doing anything sane to fix it, he just hides all the variables instead.

Edit: The extra-fun problem is that because his functions do everything at once, refactoring this is extraordinarily hard. I wish it was as simple as just adding these globals to the function signature and fix the calls, but half the time that doesn't work - some of the variables are already used, or he intermingles local and global state, making it gently caress near impossible to understand if what you are adding is going to break everything.

IT BEGINS fucked around with this message at 20:00 on Apr 29, 2015

Karate Bastard
Jul 31, 2007
Probation
Can't post for 15 hours!
Soiled Meat
I expected a detour into Turing machine land populated solely by globally manipulating validator functions acting as bumpers in a game of multiball pinball (this is multithreaded, right?) where the function pointers are the ballz and the main thread just stands there madly tilting and screaming to no discernable effect.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

IT BEGINS posted:

Yeah he just stopped writing validation code completely instead. :shepicide:

I realized a while ago that the reason he writes all of these crazy globals is that he keeps ending up with functions that have a dozen parameters or more. This frustrates him (since he calls these functions everywhere, and he'd have to keep writing these parameters all the time), but instead of doing anything sane to fix it, he just hides all the variables instead.

Edit: The extra-fun problem is that because his functions do everything at once, refactoring this is extraordinarily hard. I wish it was as simple as just adding these globals to the function signature and fix the calls, but half the time that doesn't work - some of the variables are already used, or he intermingles local and global state, making it gently caress near impossible to understand if what you are adding is going to break everything.

Does no one in a management position at this place have any insight into the lack of quality control and the consequences over time in terms of retaining good devs and being able to continue development at whatever pace they keep at the moment? It sounds like they are unaware of how badly they're setting themselves up to get screwed by this.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Hammerite posted:

Does no one in a management position at this place have any insight into the lack of quality control and the consequences over time in terms of retaining good devs and being able to continue development at whatever pace they keep at the moment? It sounds like they are unaware of how badly they're setting themselves up to get screwed by this.

If the situation is that bad and management isn't already addressing it, odds are they're too dumb to judge what is going on and will interpret any action taken by IT BEGINS to be negative and blame him/her. The team will also take any such action as an attack and work to undermine him/her on a personal and professional level. It's a lose-lose-lose situation, that's why those of us with experience say to bail and find another job.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

Ender.uNF posted:

If the situation is that bad and management isn't already addressing it, odds are they're too dumb to judge what is going on and will interpret any action taken by IT BEGINS to be negative and blame him/her. The team will also take any such action as an attack and work to undermine him/her on a personal and professional level. It's a lose-lose-lose situation, that's why those of us with experience say to bail and find another job.

Luckily I'm on good terms with management and I'm making my concerns heard. The problem is it doesn't really go anywhere. Our non-technical manager listens to our concerns but our 'CTO' is the owner and there's a ton of push-back to getting this stuff fixed. Also a lot of this stuff was written by his son so yaaaaaaay.

Yeah I'm bailing ASAP. Thanks to everyone in this thread, by the way, for making me finally realize I'm on a sinking ship.

IT BEGINS fucked around with this message at 00:46 on Apr 30, 2015

Coffee Mugshot
Jun 26, 2010

by Lowtax

IT BEGINS posted:

'CTO' is the owner and... a lot of this stuff was written by his son.

Yeah I'm bailing ASAP. Thanks to everyone in this thread, by the way, for making me finally realize I'm on a sinking ship.

Thanks for your service to this thread

apseudonym
Feb 25, 2011

IT BEGINS posted:

Luckily I'm on good terms with management and I'm making my concerns heard. The problem is it doesn't really go anywhere. Our non-technical manager listens to our concerns but our 'CTO' is the owner and there's a ton of push-back to getting this stuff fixed. Also a lot of this stuff was written by his son so yaaaaaaay.

Yeah I'm bailing ASAP. Thanks to everyone in this thread, by the way, for making me finally realize I'm on a sinking ship.

:stare: Jesus dude, that's awful.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

IT BEGINS posted:

Yeah I'm bailing ASAP. Thanks to everyone in this thread, by the way, for making me finally realize I'm on a sinking ship.

A goon finally started climbing out of their well :3:

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

apseudonym posted:

:stare: Jesus dude, that's awful.

Yeah it's pretty poo poo. I mean it took until TYOOL 2015 to convince said CTO that classes are important to use. That using extract() at the start of every function is a bad idea. That using global only hides parameters and only makes the code worse (he's still convinced that global $database is fine, even though I have given him several specific examples where it cost us hours of work hunting down bugs). There's also still basically no understanding of separation of concerns, or programming patterns. I spent several hours last week explaining that the PHP templates that we feed our reporting system shouldn't be tracked in a separate repository because they are a part of our core piece of software. One of the first responses was 'just add that directory to the include path'.

Also, more genius stuff:

php:
<?
function round1 ($string) {
return round($string,1);
}
function round2 ($string) {
return round($string,2);
}
function round3 ($string) {
setlocale(LC_MONETARY, 'en_US');

return money_format('%.3n', $string);
}
function round4 ($string) {
    setlocale(LC_MONETARY, 'en_US');

return money_format('%.4n', $string);
}
function round5 ($string) {
    setlocale(LC_MONETARY, 'en_US');
return money_format('%.5n', $string);
}
?>

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

As a mental health advocate, I recommend you start interviewing everywhere that will answer the phone.

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.
I saw a SQL query today with six CTEs. Three of which were named sum1, sum2, and sum3.

brap
Aug 23, 2004

Grimey Drawer
Get a new job that doesn't involve PHP.

ATM Machine
Aug 20, 2007

I paid $5 for this
Get a new job that doesn't involve people.

Pollyanna
Mar 5, 2005

Milk's on them.


I am the coding horror. Our app was pointing to the API beta server instead of production for a few hours, and it turns out that a change I had made to one of our RightScale scripts ended up applying to literally every server that used it, not just the server I changed it on. :gonk: I changed a similar script back before making a copy of it to mess around on, but apparently I had missed the other one that caused the problem. I've only been here two months, yet I managed to gently caress things up in that little time.

I blame Rightscale more than I blame myself, though. It's loving awful.

Storysmith
Dec 31, 2006

Pollyanna posted:

I am the coding horror. Our app was pointing to the API beta server instead of production for a few hours, and it turns out that a change I had made to one of our RightScale scripts ended up applying to literally every server that used it, not just the server I changed it on. :gonk: I changed a similar script back before making a copy of it to mess around on, but apparently I had missed the other one that caused the problem. I've only been here two months, yet I managed to gently caress things up in that little time.

I blame Rightscale more than I blame myself, though. It's loving awful.

If you're in development or operations long enough you'll make mistakes. Sometimes those will cause a downtime. If you didn't ever gently caress up, I'd be curious as to whether you were working at all. This thread is littered with the results of learning, in addition to the gross incompetence. The Real Horror is when these people are still making these mistakes after being called out on them.

The important thing is learning from it and making changes to prevent it from happening in the future. We're still human, after all.

(ask me about soap4r's handling of Content-Type: Chunked on Ruby 2 sometime, or accidentally running a restart command in a shell on prod instead of staging)

We try to be careful and operate with diligence and professionalism. That's all you can really do. If you sit there and deny that you did it, or worse, hamstring the folks trying to fix it, then we've got issues.

One of the questions we ask our mid-to-senior DBA candidates is "tell us about a production downtime you caused," and the fastest way to get a yellow flag is to immediately defensively respond "I've never caused a downtime." Unless you're Indiana Jones, you haven't navigated Oracle's ridiculous obstacle course of esoteric NIH and bugs unscathed.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Storysmith posted:

(ask me about soap4r's handling of Content-Type: Chunked on Ruby 2 sometime, or accidentally running a restart command in a shell on prod instead of staging)

Some geological ages ago I got in the habit of using ANSI in my prompts to make production hosts be white-on-red, and I'm sure it's saved weeks of downtime in aggregate.

qntm
Jun 17, 2009

IT BEGINS posted:


Speaking as someone with no specific investment in your mental health but who enjoys reading code that's worse than my own, you need to stay in your current job for as long as possible.

evensevenone
May 12, 2001
Glass is a solid.

Subjunctive posted:

Some geological ages ago I got in the habit of using ANSI in my prompts to make production hosts be white-on-red, and I'm sure it's saved weeks of downtime in aggregate.

People still log in by hand to production hosts?

Doctor w-rw-rw-
Jun 24, 2008
Argh, getting tired of the following:

  • Bad commit messages. "Formatting" -> functional changes, but named as such as the developer also ran the formatter for that commit (and not for any of the other ones). Fixing things with the description of the thing it's fixing: "does weird things"
  • Really bad commit etiquette. At least now I can reasonably expect that each commit compiles, as opposed to just every pull request.
  • Repeatedly subclassing classes I generalize to tweak one or two things for specific experiences.
  • Performing layout on view loading instead of on view layout. At least now performing view loading during view layout is banned.
  • Proliferation of bidirectional, stateful relationships between objects. Two-way strong references, too.

Argh, it's not that hard.

  • Pay attention to merges and check that you didn't screw up the merge.
  • git pull --rebase, FFS.
  • Compile each commit.
  • Use the formatter before committing. It's free, nondestructive, and not that hard. It's been months, jeez.
  • Maybe validate your approach with the author before writing a hack then investing in a big refactor on top of said hack.
  • Actually, you know, think about object ownership, for once.

God drat.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

evensevenone posted:

People still log in by hand to production hosts?

"Some geological ages ago", but yes, people do.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Doctor w-rw-rw- posted:

Repeatedly subclassing classes I generalize to tweak one or two things for specific experiences.

This is exactly what the open/closed principle says you should do (the open/closed principle is dumb).

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Subjunctive posted:

Some geological ages ago I got in the habit of using ANSI in my prompts to make production hosts be white-on-red, and I'm sure it's saved weeks of downtime in aggregate.

This is a very simple and important technique. It saves enough problems that we actually started requiring our customers to configure their terminal emulators this way.

xzzy
Mar 5, 2009

Upgrade everyone's terminals to support UTF-8 and designing prompts becomes a whole lot more fun.

When I become root, the prompt becomes a hamburger.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



xzzy posted:

Upgrade everyone's terminals to support UTF-8 and designing prompts becomes a whole lot more fun.

When I become root, the prompt becomes a hamburger.

Not pile of poo? Missed opportunity IMO.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Actually we're kind of a horror because we don't make them just change prompts. The background of the entire terminal is red.

Space Kablooey
May 6, 2009


Apparently, my supervisor forgot that sqlite is single-user.

megalodong
Mar 11, 2008

IT BEGINS posted:

our 'CTO' is the owner and there's a ton of push-back to getting this stuff fixed. Also a lot of this stuff was written by his son so yaaaaaaay.

hahahaha it all makes sense now.

Pollyanna
Mar 5, 2005

Milk's on them.


megalodong posted:

hahahaha it all makes sense now.

No loving way. How long is the company gonna last at this rate? A week?

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

Pollyanna posted:

No loving way. How long is the company gonna last at this rate? A week?

It's been around for over 15 years at this point, so as insane as that poo poo is I don't think it's going to suddenly go belly-up.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

LeftistMuslimObama posted:

Actually we're kind of a horror because we don't make them just change prompts. The background of the entire terminal is red.

That's the right thing, if you can reliably control the configuration of the terminal program.

Pollyanna
Mar 5, 2005

Milk's on them.


Subjunctive posted:

That's the right thing, if you can reliably control the configuration of the terminal program.

If you can change the terminal to match the Mega Man X intro I'll totally work there.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Subjunctive posted:

That's the right thing, if you can reliably control the configuration of the terminal program.

Yeah, we make everyone buy Attachmate Reflection so that we have a consistent api through which to of terminal programming.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Returning false from my script is success you say? Throw an exception you say?

code:
if (-not $poolOk)
{
    throw $unicode_tableflip_emoticon
}
Edited because the forums are apparently also a horror.

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