BETA
This is a BETA experience. You may opt-out by clicking here

More From Forbes

Edit Story

31 Of The Best Kept Secrets Of Great Programmers

Following
This article is more than 8 years old.

This question originally appeared on Quora: What are the best-kept secrets of great programmers?

Answer by Jens Rantil, Developer, life hacker, and inspired Swede, on Quora

  1. Most of the time, using inheritance is a bad object oriented design in the long run. It reduces reusability and testability of code. Consider using interfaces instead. See No, inheritance is not the way to achieve code reuse!. Related;
  2. Avoid introducing an interface until you are comfortable in your domain. "Premature interfacing" can also lead to design issues down the road.
  3. Deep nested code (both intra-function and inter-function) is 1) harder to maintain and 2) more prone to bugs.
  4. Estimating time is hard. One reason why Scrum and sprints are used in many places.
  5. Proper encryption is hard. Don't invent it yourself unless you have a good reason to.
  6. Side-effect free logic is nice. It makes it easier to reason about state (see below)
  7. Learn to reason around state and lifecycles. See Jens Rantil's Hideout.
  8. Concurrency can be hard without the right primitives. Queues, Observables, and actors can sometimes help a lot.
  9. Premature optimization is the root of all evil. A good general development process is: 1) Get it to work. 2) Make the code beautiful. 3) Optimize.
  10. Know your basic data structures and understand time complexity. It's an effective way of making your code much faster without adding complexity.
  11. Practise back-of-the-envelope calculations. How many items will a piece of code generally hold in memory?
  12. Write code as you want to read it. Add comments where you think you will not understand your code in a year's time. You will need the comment in a month. Somewhat related;
  13. Setup your build tooling around a project so that it's easy to get started. Document the (few) commands needed to build, run, test and package in a README file.
  14. Making sure your projects can build from command line makes things so much easier down the road.
  15. Handling 3rd party dependencies in many languages can be a real mess (looking at you Java and Python). Specifically, when two different libraries depend on different versions. Some key things to take away from this: 1) Constantly question your dependencies. 2) Automated tests can help against this. 3) Always fixate which version of a 3rd party dependency you should use.
  16. Popular Open Source projects are a great way to learn about good maintainable code and software development process.
  17. Every single line you add to an application adds complexity and makes it more likely to have bugs. Removing code is a great way to remove bugs.
  18. Code paths that handles failures are rarely tested/executed (for a reason). This makes them a good candidate for bugs.
  19. Input validation is not just useful for security reasons. It helps you catch bugs early.
  20. Somewhat related to above: State validation and output validation can be equally useful as input validation, both in terms of discovering inherent bugs, but also for security sensitive code.
  21. Code reviews are a great way to improve as a programmer. You will get critique on your code, and you will learn to describe in words why someone else's code is good or bad. It also trains you to discover common mistakes.
  22. Learning a new programming language is a great way to learn about new paradigms and question old habits.
  23. Always specify encoding when converting text to and from bytes; be it when reading/writing to network, file, or for encryption purposes. If you rely on your locale's character set, you are bound to run into data corruption eventually. Use a UTF character set if you can get to choose yourself.
  24. Know your tools; That includes your editor, the terminal, version control system (such as git) and build tooling.
  25. Learn to use your tools without a mouse. Learn as many keyboard shortcuts as possible. It will make you more efficient and is generally more ergonomic.
  26. Reusing code is not an end goal and will not make your code more maintainable per se. Reuse complicated code and be aware that reusing code between two different domains might make them depend on each other more than necessary.
  27. Sitting for long time by the computer can break your body. 1) Listen to what your body has to say. Think extra about your back, neck, and wrists. Take breaks if your body starts to hurt. Creating a pause habit (making tea, grabing coffee) can surprisingly be good for your body and mind. 2) Rest your eyes from time to time by looking away from your screen. 3) Get a good keyboard without awkward wrist movements.
  28. Automated testing, and in particular unit tests, are not just testing that your code does what it should. They also 1) document how the code is supposed to be used and 2) also helps you put yourself in the shoes of someone who will be using the code. The latter is why some claim test-first approach to development can yield cleaner APIs.
  29. Race conditions are surprisingly more common than one generally thinks. This is because a computer generally has more TPS than we are used to.
  30. Understanding the relationship between throughout and latency (http://en.m.wikipedia.org/wiki/L...) can be very useful when your systems are being optimized. Related;
  31. Many times high throughput can be achieved by introducing smart batching.

What are the best-kept secrets of great programmers?: originally appeared on Quora: The best answer to any question. Ask a question, get a great answer. Learn from experts and access insider knowledge. You can follow Quora on Twitter, Facebook, and Google+. More questions: