#ShitcodeWednesday Ep.1

Marina Lohova
n3rdiii blog
Published in
3 min readDec 23, 2016

In today’s first(!) episode of your favorite Internet show ‘ShitCode Wednesday’ we’ll take a look at one fine piece of shit code carefully crafted by some Developer That I Used To Know (cue Gotye feat. Kimbra)

Spotlight on the shit code*:

* all code posted without modifications as discovered by the author in the shit code dungeons of America.

def get_instagram_profile_image
@client = Instagram::Client.new(
:client_id => ENV["INSTAGRAM_CLIENT_ID"],
:client_secret => ENV["INSTAGRAM_CLIENT_SECRET"]
)
if params['platform_user_id'].blank?
ip = InfluencerPricing.new
username = Account.find(params['account_id']).current_username
user_id = ip.instagram_user_id(username, @client)
else
user_id = params["platform_user_id"]
end
profile = @client.user(user_id) rescue {}
img = profile['profile_picture']
render json: { img:img }
end

What is wrong with it, you say.

Are you being too harsh on the Developer That You Used To Know, Marina?

Are you being a judgmental byatch and/or a vindictive f*ck, born in USSR and raised by the wolves in the woods near the Baikonur cosmodrome?

Yes, and no.

Our developer is trying to obtain the link to the Instagram profile picture of the Influencer*. I’m okay with that.

* in the world of social media marketing Users are called Influencers.

def get_instagram_profile_image
@client = Instagram::Client.new(
:client_id => ENV["INSTAGRAM_CLIENT_ID"],
:client_secret => ENV["INSTAGRAM_CLIENT_SECRET"]
)

But then this for some reason involves the call to the Influencer Pricing model?

if params['platform_user_id'].blank?
ip = InfluencerPricing.new
username = Account.find(params['account_id']).current_username
user_id = ip.instagram_user_id(username, @client)

Wait a fucking minute!

How on Earth does the influencer’s Instagram profile picture relate to the Benjamin Franklins paid for his or her social media post?

Are you fucking kidding me?

Let me repeat that

Are you fucking kidding me?

Oh

I c what’s going on here

Developer That I Used To Know needed Instagram User ID of the Influencer, that by the unique decision of his boss and best bud, Senior Developer That I Used To Know, was stored in the Influencer Pricing model associated with the Influencer’s account.

And instead of doing what every Good Developer would do, which is to create a migration to remove the column from the Influencer Pricing table and add it to the Influencers table where it belongs, Developer That I Used To Know either didn’t question this at all, or conveniently overlooked the fact by virtue of his innate laziness.

‘Hey, they’re paying me 6 figures for this, OK?’

Hope you had fun and got your shit code fix today. It’s more bitter than your morning cold brew at Starbucks, and the best part — shit code is a 100% renewable planet resource.

A ‘renewable resource’ is an organic natural resource which can replenish to overcome usage and consumption, either through biological reproduction or other naturally recurring processes in a finite amount of time

Unlike oil or gold, Planet Earth will never run out of the ignorant, indifferent and clueless individuals who constantly replenish the volume of shit code on the planet, just like I will never stop fighting against their ignorance, educating you, Dear Reader, how to be better at what you fucking dedicate most of your time to as an IT professional.

Hope you had fun, and

Happy Coding!

Subscribe to read more awesome articles about web development. If you like what you just read check other fun pieces in this publication too:
#Shitcode Wednesday Ep.2
How to Freeze Your Enemy’s ReactJS App
Or tweet me at @ftert.

--

--