Recently while developing some features for a client's React app I faced this dilemma: What to prefer over another - Readability or Re-usability.
My first reaction to it was what any other great developer in the history of web applications would have done - "Google it out".
I found some good articles and blogs around it but still I had my doubts, since at many such places the examples used were heavily dependent on the individual's situation.
So, my next move was to consult a peer or another dev from the community whom I trust, and who is better to trust then random people on twitter!
I would admit that I did not expect some of those answers but it really taught me one most important thing in software development - "Everything is situational". In other words, I was introduced to "anti-patterns" in real life!
Good read for the difference between patterns and anti-patterns.
<*Insert a funny gif related to anti-patterns here(if you find one)*>
In my opinion, we all should try to take a greedy approach and follow the patterns which are most suitable at the given time and try to not future-proof everything. (Again, it can also be an anti-pattern in some situations. Now you get a taste of how it feels!)
In short, use your grey matter.
Now, going back to the title - so what was actually required in my particular case? Good thing you asked, I don't know!
But I guess it's Readability. May be it's only for this project or for most of what I work on, but I try to make it as easy to understand as it can be. According to me a readable and understandable code is the most re-used one.
If we keep trying to make everything so generic that it can be re-used in 'n' number of ways on the cost of its simplicity, then I don't think it will do us any good, specially when the app starts getting complex with dozens of logic at one place (because you have to write that logic which renders those generic components conditionally, somewhere!).
TL;DR - Just choose what you and your team thinks is more important for the application/project in that particular situation. If no unified answer comes across - just go for readability!
And most importantly, always be ready for refactoring coz' you never know what worked then would not work now or may be later. I think this uncertainty is what drives many people like me to keep learning and evolving.
My first reaction to it was what any other great developer in the history of web applications would have done - "Google it out".
I found some good articles and blogs around it but still I had my doubts, since at many such places the examples used were heavily dependent on the individual's situation.
So, my next move was to consult a peer or another dev from the community whom I trust, and who is better to trust then random people on twitter!
I would admit that I did not expect some of those answers but it really taught me one most important thing in software development - "Everything is situational". In other words, I was introduced to "anti-patterns" in real life!
Good read for the difference between patterns and anti-patterns.
<*Insert a funny gif related to anti-patterns here(if you find one)*>
In my opinion, we all should try to take a greedy approach and follow the patterns which are most suitable at the given time and try to not future-proof everything. (Again, it can also be an anti-pattern in some situations. Now you get a taste of how it feels!)
In short, use your grey matter.
Now, going back to the title - so what was actually required in my particular case? Good thing you asked, I don't know!
But I guess it's Readability. May be it's only for this project or for most of what I work on, but I try to make it as easy to understand as it can be. According to me a readable and understandable code is the most re-used one.
If we keep trying to make everything so generic that it can be re-used in 'n' number of ways on the cost of its simplicity, then I don't think it will do us any good, specially when the app starts getting complex with dozens of logic at one place (because you have to write that logic which renders those generic components conditionally, somewhere!).
TL;DR - Just choose what you and your team thinks is more important for the application/project in that particular situation. If no unified answer comes across - just go for readability!
And most importantly, always be ready for refactoring coz' you never know what worked then would not work now or may be later. I think this uncertainty is what drives many people like me to keep learning and evolving.
Comments
Post a Comment