• KillingTimeItself@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    20
    arrow-down
    5
    ·
    4 months ago

    i think programmers need a self inflicted rule of it being less than 500 lines of code means you need to write it instead of using a pre written package/library.

    On the other hand, we could make the packages like is-number the worst possible way of checking if something is a number, which would be really fucking funny…

    • dan@upvote.au
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      4 months ago

      programmers need a self inflicted rule of it being less than 500 lines of code means you need to write it instead of using a pre written package/library.

      That’s what I do, but then I end up with similar utils across multiple projects (eg some of these array, map, and set utils: https://github.com/Daniel15/dnstools/tree/master/src/DnsTools.Web/ClientApp/src/utils) and wonder if I should create a library.

      Then I end up doing that (https://github.com/Daniel15/jsframework is my most ‘recent’ one, now very outdated) but eventually the library gets outdated and you end up deleting most of it and starting again. (edit: practically this entire library is obsolete how)

      It’s the circle of life.

      • KillingTimeItself@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        1
        ·
        4 months ago

        i wonder if maybe we just need personal package repos for shit like this, stuff that probably shouldnt be out on the internet and accessible, but that’s also worth packaging for regular use. Like a sort of “code macro” which is something i see people doing a lot for certain boilerplate strings.

        • felbane@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          4 months ago

          You are describing a state of software development that has existed since the introduction of punch cards.

          Practically every business I’ve worked at has had some internal library or repository of commonly used behavior that can be included in day to day projects.

          • KillingTimeItself@lemmy.dbzer0.com
            link
            fedilink
            English
            arrow-up
            1
            arrow-down
            1
            ·
            4 months ago

            obviously, i just mean more universally on an individual level today, maybe we just need package quality reviewers these days lol.

            You could pretty easily add this feature into whatever shit ass IDE you use that consumes 8GB of ram by just existing.

    • jonne@infosec.pub
      link
      fedilink
      arrow-up
      6
      ·
      4 months ago

      Eh, I can see why you’d want something like that in a language like JavaScript where pretty much all native ways of validating input have weird edge cases. Sometimes you just want the community to figure it out for you instead of reinventing the wheel and finding out you missed something later on.

      A whole package that handles validation of inputs, or a math package would be better than a package that just has one function tho.

      • KillingTimeItself@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        5
        ·
        4 months ago

        yeah, generally it seems like you want a more broad package, if for something like validating input, it would be comprehensive across all input for example.

        There’s one package on npm called is-even and i think another called is-odd, which according to the author are “learning experiences” which have, considerable amounts of downloads, even though it’s literally just is-even checking. Shit like that should probably get you banned from using keyboards for the rest of your life lol