some feature addition requires either a lot of refactoring
This means you are on the right path! You understand that the code needs to be clean in order to add features.
Now, how to code to avoid the constant need to refactor... This is tough question indeed; unfortunately even mature projects sometimes require refactorings or even complete rewrites. And that's not always because of design mistakes: not everything may be foreseen in the beginning.
SOLID principles are certainly helpful. But keep in mind they are designed mainly for OOP which is not considered today as the only way to code. The most universal principle IMO is orthogonality: try to design different parts of application so that they don't depend on others implementation details. That's not 100% possible but can be achieved to some degree.
Helpful thing is defining boundaries between components, and that's where TypeScript shines. It allows you to clearly define API: object shapes, functions etc which are used to transfer data between components.
Hi Sandeep
This means you are on the right path! You understand that the code needs to be clean in order to add features.
Now, how to code to avoid the constant need to refactor... This is tough question indeed; unfortunately even mature projects sometimes require refactorings or even complete rewrites. And that's not always because of design mistakes: not everything may be foreseen in the beginning.
SOLID principles are certainly helpful. But keep in mind they are designed mainly for OOP which is not considered today as the only way to code. The most universal principle IMO is orthogonality: try to design different parts of application so that they don't depend on others implementation details. That's not 100% possible but can be achieved to some degree.
Helpful thing is defining boundaries between components, and that's where TypeScript shines. It allows you to clearly define API: object shapes, functions etc which are used to transfer data between components.
Keep going and good luck!
Thanks alot aleksei!!