7 ms·
Don't be afraid to ask for help. But don't ask for help until you've made an honest ever to figure it out yourself. You learn best when someone isn't spoon-feed
by drblast 8y ago
Don't be afraid to ask for help. But don't ask for help until you've made an honest ever to figure it out yourself. You learn best when someone isn't spoon-feeding you the answers.
Your project will be cancelled and your team will be reorganized. The manager you love to work for will leave.
The most important part of writing software is being able to understand it. You should be able to understand it when you're writing it, debugging it, and six months after you haven't touched it. Other people should be able to understand it. That principal informs the following rules:
1. Code for simplicity first. Do the simplest thing that can possibly work. For whatever reason in this industry, people are seduced by cleverness and complexity. You're doing a job, not trying to prove how smart you are. Clever code that is hard to understand isn't smart. The problem you're working on is probably simple. Don't try to make it fun and sexy when it isn't. Don't make something harder than it is because it would be cool to use the new shiny ____ to write it.
2. Don't repeat yourself. This is the opposite of simplicity, and your problems compound the more you do it.
3. If you have code that you are afraid to change for fear of breaking it, you've failed to make it simple and understandable. All the testing in the world won't help you if you don't understand the black box, and need to change the black box.
4. Code for readability. If you can't look at a line of code or an error message and understand what's going on, you've failed to make it simple and understandable enough. Functional code helps here; if you have to navigate between 50 different files to understand what a function is doing, something is wrong.
5. YAGNI. You will never, ever, ever need the thing you're about to spend time on and that dramatically increases the code complexity. If you ever do, it's much easier to refactor something simple than it is to work around something complex that made the wrong assumptions. Build systems in small steps.
6. Use the compiler and type system. Everything should be as strongly typed as possible to prevent future you from messing things up. The compiler is your best friend; make it work for you and write code so that when you inevitably have to change it, the type system prevents you from making a mistake.
7. Get good at debugging. This is a skill that you develop that nobody teaches you for whatever reason. When you're writing code while thinking about how it will be easily debuggable later, you're doing it right.
8. Use spaces instead of tabs. You'll make more money. Also turn on visible whitespace in whatever editor you're using and delete those silly extra spaces on the end of lines. I can see those and they're the code equivalent of walking out of the restroom with toilet paper on your shoe.