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
withoutclass
Nov 6, 2007

Resist the siren call of rhinocerosness

College Slice

Gul Banana posted:

what is an ice box?

For us it was a landing pad for stuff a client wanted but we may not have budget for after adding all required stories, then pruning them to a level we thought we could accomplish with our budget and time. Basically an out of scope holding pen.

Adbot
ADBOT LOVES YOU

My Rhythmic Crotch
Jan 13, 2011

My favorite so far is a project dreamt up by a junior guy. It had about 15 dead code paths, each due to using == instead of .equals for string comparison. It also had a bunch of "zombie" classes, like MyClass and MyClass2. It was clear that MyClass2 was a rewrite of MyClass, but he'd left one or two calls to MyClass in there by mistake I guess, who knows. It was amazing the code actually did anything at all, much less what it was "supposed" to.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

My Rhythmic Crotch posted:

My favorite so far is a project dreamt up by a junior guy. It had about 15 dead code paths, each due to using == instead of .equals for string comparison.

To be fair though that's an easy mistake to make that can be explained by inexperience. I kept making that mistake at work because there I write Java but came from C#. stringOne == stringTwo is a comparison in C# but is a reference equals in Java.

jony neuemonic
Nov 13, 2009

vonnegutt posted:

I like testing. If it's for pre-existing (legacy) code, it helps me understand what's going on more than a read through does, because I'm checking my assumptions. If it's for my own code, it proves that I've done the thing I tried to do.

Yeah, I've been adding a pile of tests to the legacy code I inherited despite getting a lot of "That's not really part of the ticket..." because I have to verify that I understand this undocumented mess anyway so we may as well get some lasting benefit from it.

Pollyanna
Mar 5, 2005

Milk's on them.


The Leck posted:

Ding ding ding! And the lack of any tests/documentation mean that just leaving most of the mess alone is the (short term) safest course of action. Occasionally someone comes along and yanks out a section of code into its own class where it should be, but it inevitably causes subtle to catastrophic bugs in functionality that the well-meaning person working on it wasn't even aware of.

My approach to this is generally to break it down into individual (if large) chunks, shunt that code off to their own methods, and see if the broken-down methods reveal more about what the code is trying to do in a literate fashion.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

ToxicSlurpee posted:

To be fair though that's an easy mistake to make that can be explained by inexperience. I kept making that mistake at work because there I write Java but came from C#. stringOne == stringTwo is a comparison in C# but is a reference equals in Java.

Someone keep me honest here, but I thought the variance in behavior(compared to Java) is because *it doesn't matter* in C# due to the fact that identical strings are aliased under the hood? A quick peek at Linqpad suggests this to be true - ==, Equals(), and Object.ReferenceEquals() will all return true for two strings with the same value.

redleader
Aug 18, 2005

Engage according to operational parameters

Cuntpunch posted:

Someone keep me honest here, but I thought the variance in behavior(compared to Java) is because *it doesn't matter* in C# due to the fact that identical strings are aliased under the hood? A quick peek at Linqpad suggests this to be true - ==, Equals(), and Object.ReferenceEquals() will all return true for two strings with the same value.

Not quite - it's very possible to have two strings that are equal using == but are different instances. The behaviour you're seeing in Linqpad is due to string interning.

Mezzanine
Aug 23, 2009

Volmarias posted:

Android PackageManagerService.java

20,935 loc

There's some fun stuff in AOSP

code:
private @Nullable String getRequiredButNotReallyRequiredVerifierLPr()
I love stuff like this :allears:

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

Cuntpunch posted:

Someone keep me honest here, but I thought the variance in behavior(compared to Java) is because *it doesn't matter* in C# due to the fact that identical strings are aliased under the hood? A quick peek at Linqpad suggests this to be true - ==, Equals(), and Object.ReferenceEquals() will all return true for two strings with the same value.

In c# strings are a primitive type. In Java they are not. In Java == is a reference comparison for string objects. That's the big difference; this is why == works that way for ints in both langauge.

csammis
Aug 26, 2003

Mental Institution

ToxicSlurpee posted:

In c# strings are a primitive type. In Java they are not. In Java == is a reference comparison for string objects. That's the big difference; this is why == works that way for ints in both langauge.

C# strings are not a primitive type.

C#'s "trick" is that it has operator overloading. System.String provides an == overload that does value comparison instead of reference comparison. Reference types which don't provide an == overload will do reference comparison and value types will do value comparison.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

csammis posted:

C# strings are not a primitive type.

C#'s "trick" is that it has operator overloading. System.String provides an == overload that does value comparison instead of reference comparison. Reference types which don't provide an == overload will do reference comparison and value types will do value comparison.

OK no you're right; I should have clarified that they behave like one. Strings are kind of bizarre from a programming standpoint.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

jony neuemonic posted:

Yeah, I've been adding a pile of tests to the legacy code I inherited despite getting a lot of "That's not really part of the ticket..." because I have to verify that I understand this undocumented mess anyway so we may as well get some lasting benefit from it.

A good argument for this is that it is a part of the ticket. Because an implicit part of every ticket is, "... while preserving the rest of the expected behavior in the system." Tests are a great way to do that and as you said they make everything easier when you have to revisit that section of the code.

It's tough to stand firm when you're under management pressure to get a fix out the door now now now don't worry about making it perfect also let's skip over some of our deployment steps the client is calling every day oh god. I like to invoke past incidents to get them to back off. Like the time we had a stubborn bug in one section of our system. A really smart dev thought he had a solution, so he coded it up a change and did some basic manual testing and rolled it out as a hotfix. Phones started blowing up, oops one of our major clients (who used a different configuration than the client who had the original bug used) suddenly couldn't use the system. Okay roll back and dive back into the code.

Repeat several times, until the dev got fed up and put the kibosh on more hotfixes until he was able to refactor and write better tests. The original logic was so arcane and so deeply rooted in so many parts of the system that nobody understood it and any change had the butterfly->hurricane effect. It's still pretty bad, but at least there are SOME tests around it.

SixPabst
Oct 24, 2006

KoRMaK posted:

I kicked a bunch of stuff back to the junior on the team that didn't pass code review.

I do the same thing every week when i see him walking around the office and basically goofing off, "hey, could you do me a favor and make sure all the branches you wrote are production ready?"

Always says yes


I get the branches and its not dry, the test coverage is poor and its taken way too long to get even to this point.

He seemed bummed out that half his stuff went back, but this stuff is sure as poo poo not getting into production, my dude. Start implementing best practices more often.


The frustrating part is that I keep asking him if his stuff is all gonna pass review and he always says yes but then I see it and its like, dude you made a Rails 101 mistake on the first page wtf is your deal.

You wanna be my QA?

Regarding tests, we have a ton of mock stuff but it's all based on real, obfuscated data (I work for a payroll company) and works really well for us. We are starting to use SpecFlow and some Jenkins stuff for front-end and it's drastically reduces the number of "ok this commit broke features x y and z".

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.
A lot of developers have problems internalizing the crazy idea that testing gets a lot faster when you actually get, you know, good at it.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Vulture Culture posted:

A lot of developers have problems internalizing the crazy idea that testing gets a lot faster when you actually get, you know, good at it.

A lot of developers have probably also worked with nothing but giant balls of yarn as their dependency graphs for their whole career. "Writing tests takes too long and they take too long to run, because I have to set up the state of the database JUST SO and I have to get real data <here> and <here> so that the third party API calls will return the right messages." Just writing testable code is a skill people don't realize they don't have.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
Setting up a good mock database or even an entire distributed system for your tests can be a bit daunting, but for Java developers I've found that the Accumulo codebase has examples of how to perform integration tests that have gazillions of heavyweight dependencies. They wrote a small Hadoop cluster that can be programmatically initialized and configured from within integration tests that's pretty repeatable - that sounds crazy but once you read through the code you realize that it's not that bad when you actually understand the scope of testing and validation that needs to be done routinely and from there you can determine how to separate out your components to be easier to test parts in isolation. I can understand not having good tests if you don't have the time. Even without good examples of testable codebases haven't people heard of mock objects and design principles like the Law of Demeter or separations of concerns and such?

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





i write tons of tests that aren't strictly necessary because the first thing i do before writing code is write tests that exercise the interface. even if my tests are plainly useless (like the 'assert(type(foo.bar), String)` example) they at least force me to consider how the code is going to be used and require that i actually have thought about the preconditions necessary to use the interface. this also encourages writing nice clean implementations with a minimum of dependencies or side effects

i work with a bunch of 'test after' people and their poo poo is consistently broken and ridiculous to use

KoRMaK
Jul 31, 2012



im so confused about writing tests first

having stuff that is "plainly useless" seems like its gonna dillute the signal with a lot of noise. do other peoiple see it?

CPColin
Sep 9, 2003

Big ol' smile.
We had somebody come in, advocate test-driven design left and right, and write a caching class that has lots of interesting "quirks." And no tests.

Sulphagnist
Oct 10, 2006

WARNING! INTRUDERS DETECTED

Vulture Culture posted:

A lot of developers have problems internalizing the crazy idea that testing gets a lot faster when you actually get, you know, good at it.

It was pretty fun when I sat down with a developer (I'm a subject-matter expert officially but I end up doing a fair amount of QA testing for reasons) and started going through a routine test case in our expert system that I've been doing regularly for two years by now, and their jaw dropped when I started tabbing through the fields, using all the shortcuts I'd learned, etc. I'm not a "real" tester but apparently I can test faster than our actual testers. I guess it helps that I've used the system for ages, that'd be why I'm the SME. And it's also easy to test fast when you wrote that particular test case yourself in the first place. It's muscle memory at this point.

sarehu
Apr 20, 2007

(call/cc call/cc)

Antti posted:

It was pretty fun when I sat down with a developer (I'm a subject-matter expert officially but I end up doing a fair amount of QA testing for reasons) and started going through a routine test case in our expert system that I've been doing regularly for two years by now, and their jaw dropped when I started tabbing through the fields, using all the shortcuts I'd learned, etc. I'm not a "real" tester but apparently I can test faster than our actual testers. I guess it helps that I've used the system for ages, that'd be why I'm the SME. And it's also easy to test fast when you wrote that particular test case yourself in the first place. It's muscle memory at this point.

What.

Are you doing this manually?

Che Delilas
Nov 23, 2009
FREE TIBET WEED

KoRMaK posted:

im so confused about writing tests first

having stuff that is "plainly useless" seems like its gonna dillute the signal with a lot of noise. do other peoiple see it?

The only signal we care about in this case is "does the test pass?" and otherwise we aren't going to notice it. The benefits for him is as he described, though there's definitely an argument that can be made for leaving out the ones that are always going to pass as long as the class compiles successfully. Still, it doesn't really do any harm to the system.

Even the seemingly trivial stuff can be useful, because if you make a change and a "trivial" test starts failing, you know you done hosed up.

Sulphagnist
Oct 10, 2006

WARNING! INTRUDERS DETECTED

sarehu posted:

What.

Are you doing this manually?

We have automated most test cases. I don't know the nuts and bolts of why we haven't automated all of them because I'm the SME and not directly involved (and wouldn't probably understand the explanation either). Well there's actually one test case where you need to physically print out a document and the lines need to be just right.

I do feature testing, some QA testing and exploratory acceptance testing manually whenever we do a major release because an epic pile of poo poo will roll downhill right at us if the deployed system isn't viable. I was actually just talking to a colleague last week about how while there's an existing plan to roll back a release we have never actually done it or even tried it.

The wonders of working with highly specialized legacy business software. I'm only lurking this thread because we use half-assed scrum for development and my employer had me take product owner training recently, but with code I'm a complete novice. So I may use terms inappropriately or just the wrong terms outright.

Sulphagnist fucked around with this message at 07:48 on Aug 29, 2016

FlapYoJacks
Feb 12, 2009
Finally getting around to fixing the git portion of our ancient code base. 4 gigs down to 125 megs. :allears:

With a combination of a tiny python script, git bfg, and git lfs, magic happened here today.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





KoRMaK posted:

im so confused about writing tests first

having stuff that is "plainly useless" seems like its gonna dillute the signal with a lot of noise. do other peoiple see it?

the tests are checked in, sure. usually i separate boring 'did i remember to implement this?' tests from trickier 'does this do what i think it does?' tests into different files so most people probably never look at the 'useless' tests except maybe as examples of how to use the library/component

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

the talent deficit posted:

i write tons of tests that aren't strictly necessary because the first thing i do before writing code is write tests that exercise the interface. even if my tests are plainly useless (like the 'assert(type(foo.bar), String)` example) they at least force me to consider how the code is going to be used and require that i actually have thought about the preconditions necessary to use the interface. this also encourages writing nice clean implementations with a minimum of dependencies or side effects

i work with a bunch of 'test after' people and their poo poo is consistently broken and ridiculous to use

I'm firmly in the test after group, but I also write all my interfaces down on paper and then furiously draw arrows and scribble until it makes sense. I think the issue is that most people don't spend a couple minutes thinking through their design before they just start writing piles of garbage.

Pollyanna
Mar 5, 2005

Milk's on them.


We have "unit" tests, which I'm actively working on fixing up, and we also have regression tests that are completely separate from the main project and that run against the staging server's database. As in, Capybara tests that log into the QA server and interact with a live database. :saddowns: I asked them how they'd handle more than one person running the regression tests at a time, and they didn't have a good answer.

At least one person on my team doesn't really understand when to be comprehensive in testing and when to just let things go. They're always really paranoid about things breaking and they manually pull ever single one of our PR branches and run through the full list of regression tests (manually!) to make sure nothing broke. :pwn: On the one hand, I feel really bad for them because that's a massive waste of time, and on the other, I feel like they shouldn't be doing that at all and have misunderstood the point of testing, which is to make things go faster - not slower. They've got like 5 or 6 PRs still waiting around because of how long it takes for them to approve it.

I can't bring this entire team up to speed on testing and decent developer practices on my own, but I sure as hell have to at least be pushing for it myself cause there's no guarantee anyone else will.

Riven
Apr 22, 2002
"Test until fear turns to boredom."

Pollyanna
Mar 5, 2005

Milk's on them.


Riven posted:

"Test until fear turns to boredom."

"...but avoid ending up with fear and boredom."

Munkeymon
Aug 14, 2003

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



Antti posted:

Well there's actually one test case where you need to physically print out a document and the lines need to be just right.

Wouldn't that depend somewhat on the printer?

Sedro
Dec 31, 2008

Antti posted:

Well there's actually one test case where you need to physically print out a document and the lines need to be just right.

Run it through ghostscript and compare the output to a reference image

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

Munkeymon posted:

Wouldn't that depend somewhat on the printer?

If it's that important, should you not regularly test the printer?

jony neuemonic
Nov 13, 2009

Che Delilas posted:

A good argument for this is that it is a part of the ticket. Because an implicit part of every ticket is, "... while preserving the rest of the expected behavior in the system." Tests are a great way to do that and as you said they make everything easier when you have to revisit that section of the code.

Management has my back, thankfully. This has been coming from other team members. I'm hoping that once we have to loop back to a component and the tests save us some headaches they'll come around.

Munkeymon
Aug 14, 2003

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



leper khan posted:

If it's that important, should you not regularly test the printer?

Well yeah, but that's something you can do with a static image without doing a bunch of monkey work in some LOB monstrosity. Hell, Windows has a standard test page that's never more than ~5 clicks away.

Sulphagnist
Oct 10, 2006

WARNING! INTRUDERS DETECTED

Sedro posted:

Run it through ghostscript and compare the output to a reference image

I will parrot this word for word and see what happens!

I can't go into detail because it's such a highly specific thing that anyone working at the same place will recognize me from it.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

sarehu posted:

What.

Are you doing this manually?
Controversial opinion incoming: everyone should regularly be doing some amount of manual testing.

Storysmith
Dec 31, 2006

Vulture Culture posted:

Controversial opinion incoming: everyone should regularly be doing some amount of manual testing.

As someone who QAed things where the devs insisted tests passed but the feature itself (or unrelated features you'd see along the way, like "logging in") was hilariously broken, I'm in agreement.

MisterZimbu
Mar 13, 2006
What I like about testing:

- When doing TDD and writing all the tests first, you fire up the application for the first time ever after like a week of development, and 90% of it works perfectly
- Look at all those pretty checkmarks i must be doing something right :D

What sucks about testing:

- I'm 100% convinced that there isn't a good way to do tests against a real database
- Architecting, writing, maintaining, and organizing tests
- When an actual business requirement changes and you have to dig through all of your old tests and figure out which ones need to be modified

MisterZimbu fucked around with this message at 19:55 on Aug 29, 2016

FlapYoJacks
Feb 12, 2009

Vulture Culture posted:

Controversial opinion incoming: everyone should regularly be doing some amount of manual testing.

This isn't controversial at all. There are some tests that can't be done by way of automation.

Adbot
ADBOT LOVES YOU

baquerd
Jul 2, 2007

by FactsAreUseless

ratbert90 posted:

This isn't controversial at all. There are some tests that can't be done by way of automation.

Depends on the app. A simple, stand-alone RESTful microservice can be 100% automated testing and deployment.

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