4 ms·
I think the problem is expecting that there is a one-size-fits-all approach to writing software. I have had many discussions with developers over the years who
by danieltillett 11y ago
I think the problem is expecting that there is a one-size-fits-all approach to writing software. I have had many discussions with developers over the years who come from a pure CS background who really disparage the code scientists write. Yes a lot of the code is not good code, but it would not have been possible to get anything done at all if strict coding standards had been applied from the start.
The best approach I think is to take a hybrid approach of hack and then rewrite. I have worked on problems where I have written 10,000s of lines of very hacky code over many months and once I had a viable solution rewrote the whole module from scratch in a week. The key is to make sure you (or someone else) re-writes the code once it is working if you are going to use again and not pretend that what you have hacked together is acceptable just because it (sometimes) works.
- collyw 11y agoAs a software engineer (who works with scientists) that pretty much how I write new bits of code where I am unsure if the approach will work. Try a quick hacky version, and if that appers to be working, rewite it "properly". If its going to be complex, then start off writing it reasonably well in the first place as it will make debugging much easier.
- danieltillett 11y agoYou raise a good point about debugging - I have had to rewrite some hacky code just because it just became too complex to debug efficiently long before it was ready to be rewritten for final use.
- analog31 11y agoCall it "refactoring" and you're golden. ;-) For me, it's less about standards than about tools. I don't think software development is slow because of standards. I don't use the same tool chain as the developers, so I'm oblivious to their standards. Their code is unreadable to me. I follow what would probably have been considered good practices 15 years ago when programs tended to be smaller. I actually learned good hygiene, but in the context of BASIC and Pascal in the 1980s, not the massive tool chains of today. And my programs probably look like a throwback to that era in terms of their conceptual structure. I re-write early and often. Transforming a program is a good way to find out if it made sense in the first place.
- danieltillett 11y agoI have always considered refactoring as improving your current code rather than starting from scratch. I like to start over once I have a working approach for two reasons: 1. The original code is by that time I have finished hacking a mess and it is not a good place to start. 2. I can use the original code and the new code to find bugs I missed the first time around. A good percentage of the time I find bugs in my original code that only a clean rewrite exposes.
- analog31 11y agoThat's perfectly valid. In fact I did a re-write of a favorite code, a few weeks ago. It's something a colleague and I are working on, and I explained to him that I no longer trusted the old code because it was such a mess. Also, I try to incorporate new techniques that I've learned when I write new code.