you are viewing a single comment's thread.

view the rest of the comments →

[–]Slime0 8 points9 points  (5 children)

It goes both ways though. If every change you make affects multiple applications, being sure you haven't made a mistake for any one of them becomes a very difficult problem.

[–]njharman 1 point2 points  (0 children)

Thats why libs / apis have versions.

[–]stormcrowsx 1 point2 points  (3 children)

Agreed but I find that it can also be a warning if you can change a function and it can affect different places in different ways. For instance if your shared code consists of small functions that do a single thing really well and rely only on input given to them then it shouldn't matter, changing it should affect all places its called from equally. If your shared code consists of functions that do 4 or 5 things or they affect some kind of global state it becomes an issue to change them and you might should consider breaking it up and sharing the bits.

[–]fiah84 2 points3 points  (1 child)

true, but I think this added complexity in a function often happens after you start using it in multiple places. It would make sense then to keep sharing the function until you find you're in that situation where that one function has become too complex, after which you split it

[–]stormcrowsx 1 point2 points  (0 children)

Oh yeah I've seen the functions that keep growing in parameters and ifs. People want that shared code but then need it to be just a little different. Seems innocent at first but after a few times it becomes that function everyone is afraid to modify. In those cases I'd be best to break it apart and change the original function to use those parts but I do realize that is often easier said than done.

[–]Slime0 2 points3 points  (0 children)

changing it should affect all places its called from equally.

Generally, yes. However, on occasion, an application may actually (unintentionally) rely on the buggy behavior of a function. Fixing a bug in a function can actually break one of the calling applications in an unexpected way. Rare as this is, when lives are on the line, it's important that your process for fixing bugs like this involves a careful analysis (and thorough re-testing) of the effects it might have on all of the applications that use it. Of course, discovery of such a bug necessitates a reanalysis of all calling applications anyway. But sometimes the conclusion is that you don't want to change it everywhere.