DEV Community

Ashish Salunkhe
Ashish Salunkhe

Posted on • Originally published at ashishsalunkhe.vercel.app

Code Practices every developer can follow!

Coding the right way!

  • You always feel difficulty understanding what doctors write, right?
  • Ever found a code on the internet but found it difficult to understand?

  1. Exception Handling : Code in a defensive manner. Always consider the worst case scenario. Think about input failures, event handling exceptions. This would help keep a track of possible bugs and catch the exceptions.

Alt Text

  1. Enhance code readability : Writing highly optimized code and creating complex libraries is easy but consider junior developer trying to understand 300 lines of code. Which more of a challenge than learning. Code which is clean and modular reflects maturity, competency and professionalism of the developer. A code logically structured into modules and functions is always more readable, effecient and reusable.
  2. Minimize the memory footprint : Simple yet significant coding habits can change the performance of your final product. Memory management involves ways programmer / developer dynamically allocates memory to code when requested and frees it for reuse when not needed. Here are a few good blogs I came accross:
  3. Refactor your code : Restructuring your existing code without changing it's functionality. Aggregate groups of functions doing similar tasks into a single function, use of abstraction, deduplication of code and polymorphism.

Alt Text

  1. Version Control : Tracking all changes and synchronization of codes, bug-resolve, managing changes to source codeover time. Basic, niche practice every developer should master. Git, GitHub, Gitlab, Mercurial are tools used for version control.

  2. Code Testing : Isn't it nice when someone praises us after we dress up with a good outfit? Testing practices act just like that validation we need when code the functionalities of any software. It guides and shapes the development process of the software. Unit tests, code coverage and other testing techniques help maintain modular structure and good quality end-product.

  3. KISS-DRY-YAGNI :

    • “Keep It Simple, Silly” - keep your code as concise as possible
    • "Don’t Repeat Yourself" - reducing repetition and redundancies
    • "You aren't gonna need it" - Don't try to think far ahead in future and add complex bits of code features. You don't need it, you ain't gonna need it!

Top comments (0)