5
kobenz
180d

purity might just be the most important thing when refactoring code you didn't write.

for real, if you purify everything in that code, future refactorings will go way smoother and reasoning even more so.

But it's no easy feat, sometimes you face cockroach code. cockroach code is code written nuke style. The fire and forget code that you shouldn't forget.

cockroach code's easy to spot. you can't know what cockroach code does without reading it's comments. roach code is fat, roach code retro feeds from different spots of macaroni. it does IO and everything else all bundled together.

roach code isn't easy to scratch out its async version. in fact, thats a property of roach code. If you can't make it async without a rewrite, you've got roach code.

Comments
  • 2
    Now I want a pet roach. I will attach a microprocessor to its back. I WILL roach code!
  • 0
    I clicked this cuz it caught my eye from initially seeing "purity" and wondering who the fk was bringing purity(assumed as sexual) on devRant of all places. ...then i see a bunch of mentions of cockroaches and adhd kept breaking me from reading the whole post.

    OP, you either are clueless as to your phrasing, or are brilliant and should be working for a big media producer... like a big newspaper or one of those giant click bait ad factories.
  • 0
    Side note:

    I am clueless as to when/what to comment... anyone wanna teach me?
  • 1
    @awesomeest nope, I dare not teach those that may be smarter than me. I can give you a link tho

    https://google.github.io/styleguide...
  • 1
    If I can’t avoid spaghetti I at least try to make variables and functions descriptive so they know intent

    @kobenz I was really bored and started to read the beginning of the typescript guide and holy shit there’s a section on MUTABLE EXPORTS

    export let x = “something”

    WHAT SCARES me is that this being a rule means someone actually tried something like this
  • 0
    @awesomeest “if this piece of code has to be read by someone else or by myself after a long period of time away from it, will that person or later me understand it”
  • 1
    @TeachMeCode i always understand code i wrote, fully... except if written during an amnesia episode.
  • 0
    @awesomeest yeah you’re a different case bc you’re so damn smart even crazy complex is abc to you so it’s harder to find what would stick out as non abc to someone who’s gotta read it

    Not that you don’t give a crap, obvious you do since you’re asking
  • 2
    @TeachMeCode all i know for sure is that acc to chatGPT my code is "complex", "advanced" and often legacy... but that's coming from an AI that, when i asked it to add comments, adds new redundant vars, changes my if/if/else blocks to if/elif/else, has no backbone to have a discussion backing itself up... yet often says it's wrong while repeating the wrong as new/right and has some weird fetish for making lambdas everywhere; i despise lambda.
  • 0
    @awesomeest aaaawwwe don’t get me STARTED on chat gpt I used to like it but damn anything more complex than a fucking boilerplate which even then it fucks up sometimes and it’s a DISASTER. And it contradicts itself all the time. I ask it if this is a good approach, it offers a “better solution”, I point out how similar it is to mine and it says shit like “very sorry for the oversight. It is indeed efficient. By *yadda* we ensure the code is maintainable”

    I used to think it was tight on theory but it slipped up on basic react and shit like writing code that access private vars from outside a class. Even working code was hacky and monkey patched to provide a bandaid solution to a 400lb lion bite
  • 0
    @awesomeest can’t even count how many approaches I had to reject from gpt bc of how awful and hacky they were. I went with my own 90 percent of the time. Not a flex, just pointing out that when gpt isn’t wrong it gives solutions that are just weak sauce
  • 1
    @jestdotty I can’t help but use it as such. That’s pretty much what it is
Add Comment