I write about science and technology, mostly. I live in the Port Stephens area in Australia and love my garden.
DRY - don’t repeat yourself This one isn’t a secret, but for many people who work “adjacent” to software engineering, it might be new. Basically, if you have to write it more than once, put it in a function and import a function. Or, write it once, and refer to it every where you were repeating it. This principal alone will make anyone’s code easy to maintain and easy for others to contribute to. Sometimes, a bit of repetition is good, e.g. when something is almost identical, but there are still enough differences that boiling it down into a single object/function/class/module would actually be more complex anyway. You have to use your judgement a little bit.
Learn to use your version control.
This will almost always be a tool called “git”. So just use that. If the command line isn’t your preference, there are
programs like Sublime Merge [LINK] and Atlassian Sourcetree [LINK] which give you a visual interface.
Basically, the 3 things you need to do are:
When you are done changing something, “add” the file to git
git add <filename>
When you’ve finished that round of changes, you then “lock” the change in:
git commit -m 'write a message in quotes so what the change does'
You can make a different version of your code by doing the above 2 steps on a different “branch”:
git branch -b 'name your branch something descriptive here'
And then you just switch between branches, rather than keeping many copies of your code:
git checkout masterbranch
git checkout alternate_timeline
git checkout prototype_feature
..and so on..
Keep learning about your editor/IDE, same as (4)
Try reading it out loud sometimes This may sound silly, but it’s a bit like rubber-ducky programming. A lot of “good” programming is what makes it clear to other programmers, rather than the computer. If you read it out loud, or explain it out loud to someone, different parts of your brain are engaged and you’ll likely think of something you missed when you were writing “in the zone”.
There are some great books out there, like “The pragmatic programmer”, and “Code complete”. Sure, the code examples might be outdated, but the principles can still be very, very useful. Another option if you like books and are interested in the Python langauge, testing or web apps is “Test-Driven Development with Python”.