I'm not a professional software engineer, but I enjoy working on personal projects and I'm often concerned about the quality of my code. What are the best practices or resources available to help me determine if my code is clean and secure? Any advice or recommendations would be appreciated!
5 Answers
Honestly, just make sure your code works and that it's readable for you in the future. If you can explain your variables without looking back at them, you're already ahead of the game compared to most people!
One important concept is "functional cohesion"—make sure that parts of your code, like functions or modules, all work together toward a single goal. Avoid overly tiny functions, but keep them simple and well-named so that they're easy to understand at a glance. This helps with readability and testing, too!
Clean code should be easy to read and extend. A great starting point is reading 'Clean Code' by Uncle Bob, even though it might not make sense right away. Getting your code reviewed by someone more experienced can really help highlight areas for improvement that you might not notice!
Clean code is all about organization! Use clear naming, logical structure, and avoid global variables. For secure code, think defensively: always verify and validate inputs to ensure they are what you expect. This protects against unexpected issues, especially in dynamic languages. Check out the OWASP resources for more on secure coding practices.
I suggest checking out Ousterhout's work on code structure instead of sticking only with Uncle Bob’s methods. Code quality can be seen in two ways: external (user experience, security) and internal (how easy it is to understand and modify the code later). Keeping things organized will save you headaches down the road.

Yeah, naming things well and commenting on complex code sections can save a lot of confusion later on!