News for hackers. Stuff that matters.
Re:Tips for beginning systems and software engineers by mikekchar on Thursday May 19, 2016 @04:54AM (#11728891)
DRY has many caveats. For example there is the famous "Rule of 3" - On the third time you copy something, factor it out. But really DRY is simply a rule of thumb that is intended to get you to a better design. Because "good" with respect to design is a somewhat ephemeral concept, people often equate DRY with "good". This is incorrect as there are many DRY designs that are not good.

In fact, my experience has been that for good design much more important than DRY code is simply reducing global variables (including classes -- which implies that you will be doing a lot of dependency injection). But, again, you can take it too far.

I think my biggest piece of advice for beginners is to get a mentor and constantly ask for opinions about whether a design is good or not (and what about it is good/bad). It's not something you can learn from rules. It requires a considerable amount of experience.

Re:Tips for beginning systems and software engineers by crdoconnor on Thursday May 19, 2016 @05:54AM (#11729056)
It's more fundamental than just a rule of thumb, but it's not the only rule of good code.

Loose coupling (which implies getting rid of global state) is at least equally important, as is failing fast.

Re:Tips for beginning systems and software engineers by mason55 on Thursday May 19, 2016 @08:48AM (#11729702)
One problem is that junior and mid level developers have a lot of trouble figuring out good coupling because they are not experienced in the ways things can change.

I was reviewing some code yesterday and the developer had a bunch of interfaces for everything so she could swap out implementations and she was very proud of how modular everything was. The problem was that all of her interfaces accepted a File object instead of a stream so we could change what the behavior is but not what it acts on which is really the opposite of what we needed.

Re:Tips for beginning systems and software engineers by crdoconnor on Thursday May 19, 2016 @10:21AM (#11730381)
It's hard even if you're not a beginner. One of the hardest aspects of good design is choosing the appropriate level and location for coupling.

I find that most developers who think that they can predict what kind of coupling they will need for future requirements tend to be wrong, too, no matter how experienced. Only backwards-facing refactoring really works at producing a good result, coupling-wise.