DEV Community

Scott Reno
Scott Reno

Posted on

How To Be A Cowboy Coder

Disclaimer... I didn't write this but I thought it was great. Original found here.

Introduction
You want to pump out code fast without all those pesky best practices slowing you down. Who cares if your code is impossible to maintain and modify later? You're a COWBOY CODER! This guide will teach you how to write sloppy, unprofessional code that ignores widely-accepted standards, making your codebase an incomprehensible mess! Follow these tips and your future self will thank you with days of frustration and head-scratching as they try to build on or fix your masterpiece. Yeehaw!

  1. Avoid Object Oriented Programming
    All those classes, encapsulation, inheritance stuff - totally unnecessary! Just write giant 1000+ line scripts with everything mixed together. Functions? Where we're going, we don't need no stinkin' functions! Who has time to context switch between different files and classes? Real programmers can keep everything in their head at once. So, toss out all that OOP nonsense. The bigger the file, the better!

  2. Copy and Paste Everywhere
    Need the same code in multiple places? Just copy and paste it! Refactoring is for losers. If you've got an algorithm or bit of logic you need to reuse, just duplicate that bad boy everywhere you need it. Who cares if you have to update it in 15 different places when requirements change? Not you - you'll just hack it and move on to the next thing! Duplication is your friend!

  3. Globals and Side Effects Everywhere
    Variables, functions, state - just toss 'em in the global namespace! Who needs encapsulation when you can just directly mutate whatever you want from anywhere in the code? While you're at it, functions should have all kinds of side effects. Don't document them though - make your teammate guess what that function call does!

  4. Nested Everything
    Nested loops, nested ifs, nested functions - nest to your heart's content! Who cares if the code is indented 50 levels deep? Just throw a comment somewhere saying "Here be dragons" and call it a day. Spaghetti code is beautiful in its own way.

  5. Magic Numbers and Hardcoded Everything
    Litter your code with magic numbers and hardcoded strings - they really add that human touch. Who needs constants or config files? Hardcode URLs, API keys, resource limits - go wild! Keep those release engineers on their toes!

  6. Spaghetti Dependency Management
    Feel free to import anything from anywhere. Mix and match relative imports, circular dependencies, whatever you want! from ../../utils import helpers, constants, db - beautiful! Who cares where it comes from as long as it works...until it suddenly breaks for no apparent reason.

  7. Write Every Line as It Comes to You
    Don't waste time planning or designing anything up front. Just start hacking! Stream of consciousness coding is the way to go. Just write each line and idea as it pops into your head. Who cares about architecture - you've got CODE to write!

  8. Documentation is Overrated
    Real programmers don't comment their code or write documentation. If nobody can understand that brilliant algorithm you spent days on, that's their problem! You're an artist and your masterpiece should speak for itself.

  9. Testing is a Crutch
    Don't waste time writing tests for your code. If it works on your machine, just ship it! Who cares if untested code breaks the build or crashes in production - you'll burn that bridge when you get to it. You're a coding cowboy - unleash that beautiful untested beast!

  10. Commit Early, Commit Often
    Branching, pull requests, code review - ain't nobody got time for that! Just commit directly to the main branch as often as possible. Don't worry about typos or half-finished work - just blast it into the repo and keep moving. Git history cleanliness is overrated!

  11. Manual Deployments to Production
    Set up continuous integration and delivery? No way! Click click click deploy to production manually whenever you feel like it. 3am on a Sunday? Perfect time! Wake your team up with exciting new bugs and regressions whenever you deploy.

  12. Don't Handle Errors
    Error handling is boring. Just let your code crash and burn - it adds excitement! Don't wrap risky sections in try/catch blocks - let those exceptions bubble up to the user. What's the worst that could happen?

  13. Security is for Chumps
    Who needs authentication or authorization? Leave all your APIs wide open, logins optional. Store passwords in plain text, better yet - hardcoded in the source! SQL injection vulnerabilities? Sounds like a feature!

  14. Dread the Maintenance Phase
    The most important part of coding is the NEXT feature. Just hack together something that barely works and move on to the next thing. Who cares if your unmaintainable mess gives the next developer nightmares? Not your problem anymore!

Conclusion
Follow these top tips, and you'll be writing gloriously UNMAINTAINABLE code in no time! When you inevitably leave your job, your team will fondly remember you as they desperately rewrite the pile of spaghetti code you left behind. Ride off into the sunset, you brilliant, beautiful code cowboy! Happy hacking!

Top comments (0)