1

i always get sucked into this "cute code" hell whenever i am working with a b2c codebase, and especially with kotlin code.

here's a scenario:

task : build a debounce logic for an input view where each user input is currently triggerring an api call.

my steps
1. read what debouncing is.
2. see if any code is available on the internet
=> found a code piece on the internet with some level of abstraction ( basically a simple final class that implements the input event callback and encapsulates the debounce logic)
3) copy it, run it , it wokrs

------

for any sane coder, these steps are hardly 10-30 mins and they can move on with life. but its your truly that made this task into a 6hour research only to come up at similar solution. my curiosity led me to stupid places

1) why this class is final? what if someone else wanna use it but with a different behaviour? lets try open(non final class) .

2) why even use a class? it extends an interface, lets try to wrap the logic in interface itself (kotlin supports interfaces that don't require implementation)

3) umm , the interface works but it looks ugly, with all its global overridden variables. what about we make it extension?

4) yeah the extension approach is also not very good, lets go back to open class.

5) but extend is super nice to look! lets keep the extension and open class too

6) can we optimise the implementation? why it uses an additional handler? what if we provided everything in constructor? how about builder pattern?

FUCK MY BRAIN! there are so much fucking options that i forgot that i spent 4 hours on this small thing

the simplest approach would have been tk just shove all the listeners and everything in activity and forget about it :/

senior devs on this platform, how do you stop yourself from adding every concept that you know into the smallest possible task?

Comments
  • 0
    comparing it with what i do in my current b2b job :

    1. everything has to be in java coz we build sdks and we gotta support every fucking dinosaur that pays us . so if this problem was in our current sdk, the only customisation that i would have done was to choose Between creating static functions + variables , or creating instance functions/variables.

    2. there are tons manager/controller classes and everything is either passed in as a dependency or called via static function. so this fuction would have probably gone into Utils, like Utils.attachDebouncingListenerToEditText(..)

    this edittext's callback would probably be a part of some config class that is instantiated by some static api call

    i would have hated it so much , that i would copy paste the first so link i find, check for its working with a few tests, push code, close laptop and get the hell away from my room.

    oh i forgot, thank the lords for giving me the brain to not try custom edittext route :/
  • 2
    I do take time to explore alternatives, especially if I'm not sure exactly how something works. It's a great way to learn more about the language.

    Stopping as soon as something works is a good way to only have surface level knowledge; these are the coders that disappoint in interviews.
  • 2
    I can tell that you're passionate about your job. I appreciate this trait in devs when I see it.

    You surely didn't waste all that time. You can rephrase it to "learning curve". I was in the same place when I had to write Shopify GraphQL API handler in PHP when Shopify didn't even have an official PHP client. Took me 4 12 hour shifts but it was well worth it because it saved me the research time from then onwards.

    For me, after 6 years of experience I kind of know where I should stop experimenting because I have what I was looking for.

    Don't let your passion die. It's already dead for many of us already.
  • 0
    I would implement debounce with a queue of lambdas, it's one of the few cases where it's very likely that operations in the same debounce group will have no shared type-level properties whatsoever.
  • 0
    @Sid2006 Thanks, I do know that I am good. (I also am grateful for my curious nature that somehow got developed in a restraining family out of rebellion for doing things "out of respect" and "coz we told you so")

    However, the problem is that I sometimes dive in so much that I end up reducing my priority for everything else (like going for a walk/gym/meeting friends/family time, etc ) and end up at a stage where I am frustrated with my job and want to lash out. I guess that's what burnout is .

    It's funny, I getting burnout because of a task that I am passionate about, and not because someone told/scolded me to optimize. I bet most of my seniors would just skim through my code, saying "oh so he took this approach. okay" and not having enough curiosity/fucks to debate whether any better approach exists
  • 0
    @dotenvironment I see that ... and here's what I do now that helps with keeping my curiosity down. I only look for what the company is looking for. As soon as I have it, I deliver it and forget about it.
Add Comment