I’m a mechanical engineer who works at a design build construction firm, and I’ve taught myself a lot more about coding and good programming practices since I started working just to automate some things we do (mainly VBA Excel). I’m probably still a novice in this respect compared to a full-time programmer, but I’ve learned a fair amount of things that made it easier for me to debug and update the programs I’ve worked on over the years.
However, good programming practices is not something you learn when you’re studying an non-CS related engineering degree in most cases (we do learn a bit of programming though for doing things like complex math problems and simulations of physical systems), and I found that most of the code I see written by others is not following standards like those I’ve learned on this website and elsewhere. More importantly, I’m worried that some of the things I do to make code easier for myself to debug and maintain will actually make it harder for others to do so if they don’t know about the programming best practices. For example, if you understand function calls, using lots of little functions that reference each other will be much easier to read and maintain. But if you’re fuzzy on the concept of one function referencing another, it could make it harder to read the code compared to seeing the lines of code written in the order they will be run in.
Another issue is that spreadsheets we make are generally left alone for a couple of years at a time, then updates could be returned to by someone who has not seen them before (usually when the construction schedule gets slow). Overall, engineers at my company will spend ~0-4% of their time programming, and the average would probably be less than 1%, so there is a real argument for not spending too much time on learning excellent software engineering principles. As of now, we aren’t doing anything too major; the largest projects we’re doing are on the order of a thousand lines of code. On the other hand, I think if engineers felt more comfortable programming, I think there would be more innovation in terms of automating different parts of the job to improve productivity and accuracy over time. Even if a future automation project meant bringing in professional programmers, it would be helpful to have some people who know about what we do and can communicate and understand with the programmers, and ideally we could at least maintain the code in-house. I’m not senior enough to issue a policy change in the organization by decree, but I could probably influence standards on coding issues if I made a strong case to management and/or my co-workers.
So I have a few questions about this situation:
- What are the basic programming practices that are so valuable and/or easy to learn that you think would be worth the time to learn even if you didn’t spend a large portion of your time at work programming?
- Are there any programming practices help make code easier to read even for unexperienced programmers? One obvious one I can think of is over-commenting the code, but if anyone can think of other things like that I’d appreciate the advice.
- General advice for programming practices in this situation from experience or intuition?