News for hackers. Stuff that matters.
Re:The not so hidden cost of sharing code between iOS and An... by jugg1es on Wednesday August 14, 2019 @11:13PM (#20702282)
I often struggle trying to explain to more junior developers that there are times when it's OK to write code more than once. There is a mindset that you should only ever write code once. It exists for (very) good reason. But if you follow it dogmatically, you may end up with an unmaintainable tangle of dependencies that can only be resolved with a rewrite.

Sometimes, it's OK to write the same thing twice if the alternative is a major refactor - such as inventing your own stack.

Re:The not so hidden cost of sharing code between iOS and An... by reallydontask on Thursday August 15, 2019 @02:41AM (#20703103)
You are fortunate if you only have to explain it to juniors.

This seems pretty prevalent among senior developers too, in my experience.

The most egregious case was, this guy I worked with, who would just straight up start with abstractions to avoid any duplication and enable other use cases. Now, 9 out 10 times the use cases catered for by the abstraction failed to materialise (bloody customers) but boy did he let you know when he hit the abstraction lottery and what he'd done neatly fitted in with a new use case.

I think the term for what he created was ravioli code although maybe some of it was lasagne code

Re:The not so hidden cost of sharing code between iOS and An... by taurath on Thursday August 15, 2019 @04:23AM (#20703500)
Duplication is always more extensible and maintainable than a bad abstraction.
Re:The not so hidden cost of sharing code between iOS and An... by Roritharr on Thursday August 15, 2019 @04:47AM (#20703605)
>hit the abstraction lottery

Thanks, I'll use that from now on. A lot of wisdom in those 4 words.

Re:The not so hidden cost of sharing code between iOS and An... by ufmace on Thursday August 15, 2019 @03:12PM (#20708619)
I like the rule I read somewhere called Rule of 3. Goes something like, don't bother to write a shared version of some piece of code until you've already written it in at least 3 different places. This simultaneously ensures that

1. There is actually a need to use this code in multiple places

2. You know where the places that need this code actually are, and what they need, so what you write will actually be practical for all of them to use

3. Or maybe you can tell that, despite the seeming similarity, the different places are too far apart or too different for sharing code to actually make sense

Re:The not so hidden cost of sharing code between iOS and An... by phaedrus on Wednesday August 14, 2019 @11:24PM (#20702328)
At the very least you need to repeat yourself in as much as repeating the names you defined for constants, variables, macros, and functions when later invoking them. A program written in the limit of the style of don't repeat yourself either repeats these names many times and/or has too many layers.
Re:The not so hidden cost of sharing code between iOS and An... by gnychis on Friday August 16, 2019 @02:17PM (#20717939)
Hi there, sorry to hijack this post. We actually had a brief exchange a few months ago here (https://news.ycombinator.com/item?id=18133835). I didn't notice you had responded until now and that is now "locked." Are you still working on RPA? If so can you reach out at [email protected]? Thanks a lot!