Header Ads

Header ADS

How do you define a good code? And how do we identify it as we code?

 The 3 pillars of good code:

1. Readable
2. Time Complexity
3. Space Complexity

Good code checklist:
[✅]It works
[✅]Good use of data structures
[✅]Code Re-use/ Do Not Repeat Yourself
[✅]Modular - makes code more readable, maintainable, and testable
[✅]Less than O(N^2). We want to avoid nested loops if we can since they are expensive. Two separate loops are better than 2 nested loops
[✅]Low Space Complexity --> Recursion can cause a stack overflow, copying of large arrays may exceed the memory of machine.

No comments

Powered by Blogger.