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
CPColin
Sep 9, 2003

Big ol' smile.

Cancelbot posted:

I completely agree. There's just years of institutional crap I need to clean up where people just hop onto production SQL for "quick fixes".

Thinking about this and the strategy of putting data-access logic in stored procedures so it can be changed without doing a new deploy of the code made me decide what my counter will be, the next time somebody advocates that strategy at me: "What's wrong with our deploy process that makes us so reluctant to go through it? And what can we do to fix that?"

Part of my motivation here is that I just added some fallback behavior for the code that handles the application configuration, which I was instructed to update to match what the team currently wants to do: store the configuration in a shared location, instead of in App.config. A noble effort! Get all those connection strings and server names into one place, so we can change them all at once. What's the central location, you ask? A database, of course! Where does the connection string for that database go? In App.config, duh!

Nailed it.

Adbot
ADBOT LOVES YOU

Virigoth
Apr 28, 2009

Corona rules everything around me
C.R.E.A.M. get the virus
In the ICU y'all......



Clanpot Shake posted:

Doing my first ever production deploy tonight which entails changing the primary and foreign keys on ~100 million rows and changing the application services to use the new thing. Fingers crossed.

What happens if it stops at 43% changed? Asking for a friend.

Clanpot Shake
Aug 10, 2006
shake shake!

Virigoth posted:

What happens if it stops at 43% changed? Asking for a friend.

We restore the database to the backup we took before we started.

The Fool
Oct 16, 2003


I hope you test that backup

Ither
Jan 30, 2010

When do you guys feel that method chaining gets excessive?

Like the following is fine

code:
foo.getBar().getBuzz()
But this makes my eye twitch

code:
foo.getBar().getBuzz().getFizz().getStudent()
And this makes me want to scream

code:
foo.getBar().getBuzz().getFizz().getStudent()
foo.getBar().getBuzz().getFizz().getTeacher()
foo.getBar().getBuzz().getFizz().setLocation(location)
It looks awful and its a pain to debug.

freeasinbeer
Mar 26, 2015

by Fluffdaddy

Clanpot Shake posted:

We restore the database to the backup we took before we started.

Edit nvm.

vonnegutt
Aug 7, 2006
Hobocamp.

Ither posted:

code:
foo.getBar().getBuzz().getFizz().getStudent()
foo.getBar().getBuzz().getFizz().getTeacher()
foo.getBar().getBuzz().getFizz().setLocation(location)
It looks awful and its a pain to debug.

Each of those chained methods should return a unique error if it fails. If that's the case I see no problem with chaining.

CPColin
Sep 9, 2003

Big ol' smile.
Knowing Java, they're all going to be NullPointerExceptions!

freeasinbeer
Mar 26, 2015

by Fluffdaddy

The Fool posted:

I hope you test that backup

I bet it’s the cloud, so it’s probably fine.

Clanpot Shake
Aug 10, 2006
shake shake!

Punkbob posted:

I bet it’s the cloud, so it’s probably fine.

It's okay, it is the cloud.

MrMoo
Sep 14, 2000

CPColin posted:

Knowing Java, they're all going to be NullPointerExceptions!

The excellent developers at Reuters do this, or an exception with the error code embedded somewhere in a text string of dubious usefulness. Frequently the errors are reported asynchronously in a log file and the execution path silently craps out :350:

Virigoth
Apr 28, 2009

Corona rules everything around me
C.R.E.A.M. get the virus
In the ICU y'all......



Clanpot Shake posted:

It's okay, it is the cloud.

Since you said this is your first prod deploy here are some things to think about :
Is your Ops guy going to be on the call with you during the work window if it goes sideways? It'd be good to get your infra/ops side of the house involved if you can.
Do you have a backup DB up and running that you can fail back to and keep your outage window smaller so you don't gently caress up your SLA and have a smaller mean time to repair if it does go pear shaped?
Double check your commands you have pre-typed out for the change you copied from your test run (you do have them all prepped right?) for typos and duplicates. You don't want to be like the AWS S3 guy who had a typo and took down half the internet.
Have your form of drug/booze nearby for when it's complete so you can celebrate accordingly.

Clanpot Shake
Aug 10, 2006
shake shake!

Virigoth posted:

Since you said this is your first prod deploy here are some things to think about :
Is your Ops guy going to be on the call with you during the work window if it goes sideways? It'd be good to get your infra/ops side of the house involved if you can.
Do you have a backup DB up and running that you can fail back to and keep your outage window smaller so you don't gently caress up your SLA and have a smaller mean time to repair if it does go pear shaped?
Double check your commands you have pre-typed out for the change you copied from your test run (you do have them all prepped right?) for typos and duplicates. You don't want to be like the AWS S3 guy who had a typo and took down half the internet.
Have your form of drug/booze nearby for when it's complete so you can celebrate accordingly.

I'm actually not flying solo on this, which is nice, I just authored all of it. We've tested the migration and restore repeatedly in lower environments so I'm pretty confident it will work either way. It's also nothing nearly important as S3 as our site only really needs to be up during continental US hours. But yes I have everything written in a text file.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

MrMoo posted:

The excellent developers at Reuters do this, or an exception with the error code embedded somewhere in a text string of dubious usefulness. Frequently the errors are reported asynchronously in a log file and the execution path silently craps out :350:

My company's product uses this classic pattern:

1) Every function implementation is wrapped in a top-level try-catch
2) Every problem, error, and non-success state throws an exception
3) The catch block from (1) logs the error to a single giant database table
4) The catch block re-throws the exception (or throws a brand new, different exception, and no there's no rules for this)

I hate this to an irrational degree, I think. I'm not a fan of using exceptions for non-exceptional behavior. I know this is debatable, but my view of an exception is that it should be use for exceptional circumstances. A user entering a special character that the system can't handle, a request timeout, things like that. "Invalid password" is not exception-worthy in my book.

The real problem in this code is probably the fact that very often, an error will get transformed so much by the time it reaches somebody's eyes that it's likely to be misleading or outright incorrect. When your errors are exceptions that get re-thrown, every catch block up the chain is an opportunity to lose data.

Typing this out, maybe it's not a bad pattern in and of itself. Maybe the problem is just that our code is the wild west and there's no consistency or guidelines on how to user or handle exceptions. Anybody agree or disagree with any of this?

Che Delilas fucked around with this message at 02:54 on Dec 5, 2017

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003

Virigoth posted:

What happens if it stops at 43% changed? Asking for a friend.

you type "rollback" instead of "commit"

Clanpot Shake
Aug 10, 2006
shake shake!

DELETE CASCADE posted:

you type "rollback" instead of "commit"

We're running everything outside of a transaction because the overhead of a transaction makes it too slow. :toot:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

CPColin posted:

Knowing Java, they're all going to be NullPointerExceptions!

I had to think about that for a minute because some languages are a bit better about chains like that than others. I think Python would tell you it couldn't find the getFizz() method for NoneType, which would take you right to getBuzz() returning null. I wanted to think C# did something similar but I think I was crossing the signals in my head there.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Objective C and some others just don't execute function calls on nil objects, which I found to be one nice aspect of the language. So, foo.getFoo().getBar().getBaz().doThing() will just do nothing past getBar if getBar returns nil.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Volmarias posted:

Objective C and some others just don't execute function calls on nil objects, which I found to be one nice aspect of the language. So, foo.getFoo().getBar().getBaz().doThing() will just do nothing past getBar if getBar returns nil.

Seems like that trades one problem for another. Instead of ambiguous pants-making GBS threads on that line of code, you get ambiguous pants-making GBS threads later based on the assumption a thing was done that wasn't.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

Seems like that trades one problem for another. Instead of ambiguous pants-making GBS threads on that line of code, you get ambiguous pants-making GBS threads later based on the assumption a thing was done that wasn't.

At least it won’t surface those pants to the user though.

Modern C# has the ?. operator which does basically the same thing. It’s good, and hopefully soon I’ll be able to use it.

pigdog
Apr 23, 2004

by Smythe

Ither posted:

When do you guys feel that method chaining gets excessive?

Like the following is fine

code:
foo.getBar().getBuzz()
But this makes my eye twitch

code:
foo.getBar().getBuzz().getFizz().getStudent()
And this makes me want to scream

code:
foo.getBar().getBuzz().getFizz().getStudent()
foo.getBar().getBuzz().getFizz().getTeacher()
foo.getBar().getBuzz().getFizz().setLocation(location)
It looks awful and its a pain to debug.

Law of Demeter. Does foo.getStudent() or at least foo.getFizz() make any logical sense? If so, add the chain behind it.

ChickenWing
Jul 22, 2010

:v:

CPColin posted:

Knowing Java, they're all going to be NullPointerExceptions!

Methods chained that far trigger me because there is no way in hell one of those isn't going to be null on purpose at some point. Plus that's not meeting the java standard for verbosity, it should be more like

code:
if(null == foo) {
  log.error("no foo");
  throw new NoFooException("no foo");
}
Bar bar = foo.getBar();
// check bar for null value and throw exception if it is not present
if(null == bar) {
  log.error("Foo was missing a value for bar, which was required")
  throw new MissingRequiredBarInObjectShouldNotBeNullException("Foo must always have a bar object otherwise it violates null safety checks, see Confluence page [url]https://confluence.contoso.com/null-safe-foo-bar-checks[/url]");
}
Buzz buzz = bar.getBuzz();
if(bar == null) {
  throw new RuntimeException();
}
Student student = buzz.getStudent();
(naturally each of these null checks was written by a different person when testers triggered the relevant NPE)

geeves
Sep 16, 2004

Ither posted:

When do you guys feel that method chaining gets excessive?

Like the following is fine

code:
foo.getBar().getBuzz()
But this makes my eye twitch

code:
foo.getBar().getBuzz().getFizz().getStudent()
And this makes me want to scream

code:
foo.getBar().getBuzz().getFizz().getStudent()
foo.getBar().getBuzz().getFizz().getTeacher()
foo.getBar().getBuzz().getFizz().setLocation(location)
It looks awful and its a pain to debug.

It is and in bad hibernate setups - of which there are many - it’s mapped object hell just like this.

When we finally moved to gradle, we started getting a handful of NPEs right in the middle of a chain that never showed up before.

Instead of fixing the 20 or so odd places, it was decided that we just wouldn’t move that app to gradle. :psyduck:

Hughlander
May 11, 2005

geeves posted:

It is and in bad hibernate setups - of which there are many - it’s mapped object hell just like this.

When we finally moved to gradle, we started getting a handful of NPEs right in the middle of a chain that never showed up before.

Instead of fixing the 20 or so odd places, it was decided that we just wouldn’t move that app to gradle. :psyduck:

Wtf? Was there some combo of dependency hell that did this to non pinned versions? Or what?

CPColin
Sep 9, 2003

Big ol' smile.
I look forward to the next time I newly encounter a Java codebase and get to start all over again with adding @NonNull and @Nullable everywhere!

Taffer
Oct 15, 2010


All you people whining about Java need to jump on the kotlin train :colbert:

CPColin
Sep 9, 2003

Big ol' smile.
Rule of thumb: avoid programming languages that brag on their home page about not needing semicolons.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

CPColin posted:

Rule of thumb: avoid programming languages that brag on their home page about not needing semicolons.
Yes, I've also never understood why semicolons are so terribly bad. It reminds me of the insanity regarding the automatic semicolon insertion in Javascript.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
You guys ever do that thing where you spend hours coming up with an extremely efficient algorithm for your data structure, only to learn that you’ll never have more than a couple dozen pieces of data, and the ugliest algorithm in the world would execute in approximately the same time?

That happens to me a lot.

Bongo Bill
Jan 17, 2012

Some habits that can help protect against that:

  • Either know or ask the order of magnitude of the size of the data set
  • Start with whatever algorithm is simplest to implement at the time, and only improve it if and when your instrumentation reveals that its poor performance is a problem
  • Call it practice for your next job

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Yeah always write the shittier version first if that can be done cleaner. You can use it as a testbench against the optimized version.

Rocko Bonaparte fucked around with this message at 22:15 on Dec 5, 2017

ChickenWing
Jul 22, 2010

:v:

I was told to, as a rule, never pre-optimize. Especially in my line of work (fintech lol :suicide: ) the payoff is rarely worth the effort.

That doesn't always stop me though :sun: sometimes it's super nice to spend 45 mins thinking and come up with an O(n) solution to someone else's triple nested loop

spiritual bypass
Feb 19, 2008

Grimey Drawer
Why would you ever rob yourself of the opportunity to write total garbage the first time and then come back and say "look how much I improved this bad legacy code"

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
I spent so long in college learning about time v space trade-offs in programming, but software development is all about development speed v correctness of new features. This little fact is something that didn’t really sink in until just recently when I read the Google SRE book.

Do other professions have this weird chasm between school and work? Is this like how lawyers (according to My Cousin Vinny) learn theory in school, and expect their firms to train them in practice?

raminasi
Jan 25, 2005

a last drink with no ice

lifg posted:

I spent so long in college learning about time v space trade-offs in programming, but software development is all about development speed v correctness of new features. This little fact is something that didn’t really sink in until just recently when I read the Google SRE book.

Do other professions have this weird chasm between school and work? Is this like how lawyers (according to My Cousin Vinny) learn theory in school, and expect their firms to train them in practice?

Medicine? Especially if you’re an NP.

comedyblissoption
Mar 15, 2006

lifg posted:

I spent so long in college learning about time v space trade-offs in programming, but software development is all about development speed v correctness of new features. This little fact is something that didn’t really sink in until just recently when I read the Google SRE book.

Do other professions have this weird chasm between school and work? Is this like how lawyers (according to My Cousin Vinny) learn theory in school, and expect their firms to train them in practice?
Learning about data structures and time vs space trade-offs improves your development speed and correctness. You'll know immediately why you should use a stdlib dictionary instead of a nested for loop of huge time complexity and spend 1 second thinking about it and move on.

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat

lifg posted:

Do other professions have this weird chasm between school and work? Is this like how lawyers (according to My Cousin Vinny) learn theory in school, and expect their firms to train them in practice?

I have a BFA in graphic design and it varies a lot from school to school but yeah classes were very much theory based with the expectation that internships and entry junior designer roles would fill out the practical side of things

Hughlander
May 11, 2005

lifg posted:

I spent so long in college learning about time v space trade-offs in programming, but software development is all about development speed v correctness of new features. This little fact is something that didn’t really sink in until just recently when I read the Google SRE book.

Do other professions have this weird chasm between school and work? Is this like how lawyers (according to My Cousin Vinny) learn theory in school, and expect their firms to train them in practice?

Yes. Think particularly historical (Pre-1990) white collar jobs. You get your degree from school to show you can learn poo poo and then you get trained by the company you spend the next 40 years working for. The fact that you have a degree in Anthropology is meaningless to be a manager of widget makers.

geeves
Sep 16, 2004

Hughlander posted:

Wtf? Was there some combo of dependency hell that did this to non pinned versions? Or what?

That’s what I track down when I have time or have to when we have to upgrade struts.

Just discovered that struts2-convention has been included that conflicts a lot with asm. I don’t know how I’ve missed it before but we don’t use it at all yet it’s been in our code for years.

so I’m hoping this takes care of this issue that decided to show up when we switched from maven to gradle over the last week. I should know tomorrow morning

Adbot
ADBOT LOVES YOU

geeves
Sep 16, 2004

^^^^ Didn't meant to DP, but yep a dependency conflict that only appears with certain java versions and tomcat 8 was asm and struts.

The aha moment was working on something different and updating from struts 2.3.34 to 2.5.14 in the coming weeks - catalina.out basically exploded on start up which made it much easier to track down.

Taffer posted:

All you people whining about Java need to jump on the kotlin train :colbert:

Our new API is written in Kotlin :dance:

geeves fucked around with this message at 16:05 on Dec 6, 2017

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