• 0 Posts
  • 20 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle




  • I think it heavily depends on the size and (management) culture of your employer. My most recent gig had me sit in way too many meetings that were way too long (1hr daily anyone?), dealing with a lot of tooling issues and touching legacy code as little as possible while still adding new features to our main product on a daily basis. Obviously “we don’t need a clean solution. We’re going to replace that codebase anyways, next year™”.

    The job before that had me actually code for about 80% of the time, but writing tests is annoying and slows you down and we don’t have time for that. Odd how there was always time for fixing the regressions later.






  • … an average hobbyist programmer …

    and

    … create an MVP?

    are at odds in my opinion. Are you looking for a hobby project or are you trying to build a product that you can sell/persuade investors with?

    If you are interested in building such a thing because you care about the idea, go for it! Even if you abandon the whole thing after a few months of consistent work, I’m pretty confident that you will gain something in the process (insights, learnings, an idea for an actual product etc.).

    However if your goal is to build something that’s commercially viable, I would do some market analysis (see what’s out there, what you want to do differently) and maybe talk to people who have already launched products or started companies before, instead of basing my decision on the responses from strangers on social media.


  • The thing is, it works like this in certain countries. At least in Switzerland and Germany it is possible to make an apprenticeship as a programmer. This means there is a structured path for the vocational education that must meet certain regulatory criteria. Normally this takes 3-4 years to finish and includes both, working at a company as well as visiting vocational school. College is often done after finishing one’s apprenticeship to broaden the understanding of more complex or advanced topics like security, architecture, project management, advanced math etc.

    I don’t understand why this system is not more common in other places. Programming (not CS) is very much like a craft and to large degrees can be taught as/similar to one.








  • I think I misunderstood your initial post (and definitely didn’t read it as carefully as I should have 😅).

    Do I understand your correctly that your goal is a companion object for your arrays that simplifies access? Not a new data structure that you’d user instead of arrays? If so, most of my points are moot.

    If your IDs are integers then there is no need for an hybrid at all, precisely because all you have to do is put each item at the same position as their ID.

    If you don’t treat IDs as opaque values, this is true.

    I’ll definitely run benchmarks so that users would be aware of performance losses, if any. But use cases of hybrid arrays are mostly small datasets so it usually shouldn’t be a concern indeed.

    I think my point is actually wrong (it was really late when I was writing my initial response). Performance would be O(n), since that’s the worst case scenario.

    Anyways, I hope you could take something useful from my answer.

    Happy hacking :D


  • I’m pretty sure I’ve been in your situation but haven’t created a dictionary/array hybrid.

    Without any more details about your use case and situation, I can imagine a few pitfalls with your solution:

    • Serialization might not behave as you would expect (JSON.stringify).
    • 3rd-party functions might not be able to deal with your data structure properly (again, potentially unexpected behavior).
    • You can’t easily access array methods (find, filter, map etc).
    • How do you distinguish between ID access and index access? ArrayLike([ {id: "1" }, { id: "2" } ])[1] returns { id: "2" }, how do you access { id: "1" } by ID?
    • It’s harder to reason about access time of lookups. However, this might not be a concern of yours.
    • It may cause confusion if you’re working with other developers.

    That being said, unless you work in an environment where your code should be easily understandable by others, the best way to find out if this is a good idea or not, is to try :)

    Me personally, I usually use an associateBy function, when I need a values-by-ID structure. Of course this is not as convenient to use as your approach, but it’s good enough for me.

    // this WILL drop elements if key is not unique 
    function associateBy(array, key) {
      return array.reduce((acc, el) => ({
        ...acc,
        [el[key]]: el
      }), {});
    }
    
    associateBy([
      {id: "foo"},
      {id: "bar"}
    ], "id").foo; // -> {id: "foo"}
    

    Good luck!