Cross pollinating blurblog and thefempire.org
672 stories
·
37 followers

CodeSOD: A/F Testing

1 Comment

A/B testing is a strange beast, to me. I understand the motivations, but to me, it smacks of "I don't know what the requirements should be, so I'll just randomly show users different versions of my software until something 'sticks'". Still, it's a standard practice in modern UI design.

What isn't standard is this little blob of code sent to us anonymously. It was found in a bit of code responsible for A/B testing.

    var getModalGreen = function() {
      d = Math.random() * 100;
      if ((d -= 99.5) < 0) return 1;
      return 2;
    };

You might suspect that this code controls the color of a modal dialog on the page. You'd be wrong. It controls which state of the A/B test this run should use, which has nothing to do with the color green or modal dialogs. Perhaps it started that way, but it isn't used that way. Documentation in code can quickly become outdated as the code changes, and this apparently extends to self documenting code.

The key logic of this is that 0.5% of the time, we want to go down the 2 path. You or I might do a check like Math.random() < 0.005. Perhaps, for "clarity" we might multiply the values by 100, maybe. What we wouldn't do is subtract 99.5. What we definitely wouldn't do is subtract using the assignment operator.

You'll note that d isn't declared with a var or let keyword. JavaScript doesn't particularly care, but it does mean that if the containing scope declared a d variable, this would be touching that variable.

In fact, there did just so happen to be a global variable d, and many functions dropped values there, for no reason.

This A/B test gets a solid D-.

[Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more.
Read the whole story
srsly
14 days ago
reply
It's hard to guess the infrastructure from the snippet, but also: You Don't Show The User The Other Test On Refresh. This looks like it does.

At the very least you should keep the test consistent during the session. This can be done with Javascript, but that would involve persisting data between page loads, which is really the job of the backend.
Atlanta, Georgia
Share this story
Delete

What Biased Policing Can Do

10 Shares

It upended Matthew’s life — just because he was trying to see a movie while homeless and black

by Katie Wheeler


What Biased Policing Can Do was originally published in The Nib on Medium, where people are continuing the conversation by highlighting and responding to this story.

Read the whole story
Technicalleigh
14 days ago
reply
SF Bay area, CA (formerly ATL)
srsly
17 days ago
reply
Atlanta, Georgia
diannemharris
25 days ago
reply
sirshannon
26 days ago
reply
Share this story
Delete

Saturday Morning Breakfast Cereal - Coffee

1 Comment and 11 Shares


Click here to go see the bonus panel!

Hovertext:
I feel like I'm in a regular habit of straight-up insulting a majority of my readers.

New comic!
Today's News:
Read the whole story
popular
36 days ago
reply
srsly
36 days ago
reply
Atlanta, Georgia
Share this story
Delete
1 public comment
lrwrp
35 days ago
reply
How I feel about my wife's coffee habit.
??, NC

Exponential Backup

3 Shares

The first day of a new job is always an adjustment. There's a fine line between explaining that you're unused to a procedure and constantly saying "At my old company...". After all, nobody wants to be that guy, right? So you proceed with caution, trying to learn before giving advice.

But some things warrant the extra mile. When Samantha started her tenure at a mid-sized firm, it all started out fine. She got a computer right away, which is a nice plus. She met the team, got settled into a desk, and was given a list of passwords and important URLs to get situated. The usual stuff.

After changing her Windows password, she decided to start by browsing the source code repository. This company used Subversion, so she went and downloaded the whole repo so she could see the structure. It took a while, so she got up and got some coffee; when she got back, it had finished, and she was able to see the total size: 300 GB. That's... weird. Really weird. Weirder still, when she glanced over the commit history, it only dated back a year or so.

What could be taking so much space? Were they storing some huge binaries tucked away someplace that the code depended on? She didn't want to make waves, but this just seemed so... inefficiently huge. Now curious, she opened the repo, browsing the folder structure.

Subversion bases everything on folder structure; there is only really one "branch" in Git's thinking, but you can check out any subfolder without taking the whole repository. Inside of each project directory was a layout that is common to SVN repos: a folder called "branches", a folder called "tags", and a folder called "trunk" (Subversion's primary branch). In the branches directory there were folders called "fix" and "feature", and in each of those there were copies of the source code stored under the names of the branches. Under normal work, she'd start her checkout from one of those branch folders, thus only pulling down the code for her branch, and merge into the "trunk" copy when she was all done.

But there was one folder she didn't anticipate: "backups". Backups? But... this is version control. We can revert to an earlier version any time we want. What are the backups for? I must be misunderstanding. She opened one and was promptly horrified to find a series of zip files, dated monthly, all at revision 1.

Now morbidly curious, Samantha opened one of these zips. The top level folder inside the zip was the name of the project; under that, she found branches, tags, trunk. No way. They can't have-- She clicked in, and there it was, plain as day: another backups folder. And inside? Every backup older than the one she'd clicked. Each backup included, presumably, every backup prior to that, meaning that in the backup for October, the backup from January was included nine times, the backup from February eight times, and so on and so forth. Within two years, a floppy disk worth of code would fill a terabyte drive.

Samantha asked her boss, "What will you do when the repo gets too big to be downloaded onto your hard drive?

His response was quick and entirely serious: "Well, we back it up, then we make a new one."

[Advertisement] ProGet supports your applications, Docker containers, and third-party packages, allowing you to enforce quality standards across all components. Download and see how!
Read the whole story
diannemharris
40 days ago
reply
srsly
40 days ago
reply
Atlanta, Georgia
Share this story
Delete

one brother has gotten several games and the other brother knows, in his tall lanky beautiful heart, that the world isn't ready for him yet

2 Comments and 4 Shares
archive - contact - sexy exciting merchandise - search - about
April 13th, 2018next

April 13th, 2018: FRIENDS, I PARTICIPATED IN A MEME

– Ryan

Read the whole story
srsly
66 days ago
reply
One brother lies and the other tells the truth, and when they're done answering your questions a demon comes into the room to torture them for a thousand years SO THINK CAREFULLY ABOUT HOW INVESTED YOU ARE IN THIS RIDDLE.
Atlanta, Georgia
Share this story
Delete
1 public comment
daanzu_alt_text_bot
66 days ago
reply
[rss title] one brother has gotten several games and the other brother knows, in his tall lanky beautiful heart, that the world isn't ready for him yet

[img title] waugh

[mailto subject] one bro is tired of talking about his teeth, THANKS

Campaign Fundraising Emails

3 Comments and 9 Shares
The establishment doesn't take us seriously. You know who else they didn't take seriously? Hitler. I'll be like him, but a GOOD guy instead of...
Read the whole story
satadru
140 days ago
reply
The one who shall gather the smoke of the deadwood burning,
Or behold the flowing years from the Sea returning shall have my vote... and my axe, etc, etc.
New York, NY
wreichard
136 days ago
The crown prince of nigeria would be a better president.
srsly
140 days ago
reply
I wish the alt-text bot still worked!

The establishment doesn't take us seriously. You know who else they didn't take seriously? Hitler. I'll be like him, but a GOOD guy instead of...
Atlanta, Georgia
Vixy
140 days ago
Yeah, what happened to it?
rjstegbauer
137 days ago
The ALT-TEXT should have said, "but a GOOD WINNING guy instead!"
Share this story
Delete
1 public comment
drchuck
140 days ago
reply
Why would you run attack ads against Tom Hanks?
Long Island, NY
sommerfeld
140 days ago
The intent was to target Tom Harkin but due to an oversight autocorrect was trained with a corpus consisting entirely of movie star names.
Next Page of Stories