DEV Community

Discussion on: Getting your website to load in under 0.1 seconds

Collapse
 
griffinsauce profile image
Joris Griffioen

Abstract your code as much as possible! I cannot stress the importance of abstraction enough.

This is not good advice. Look up the concepts of DRY and WET and the many more nuanced things many smart developers have written about it.

If you abstract "as much as possible" you are going to have a terrible, terrible time.

Collapse
 
hamo225 profile image
Tarek Hamaoui

Will keep this is mind. Reading up about abstraction now. Always keeping in mind DRY and WET practices.

Collapse
 
urielbitton profile image
Uriel Bitton • Edited

how is is bad? Abstraction is important to not repeat code and reuse methods and functions.
I then said as much as possible, so where you can't abstract you don't.
Essentially to achieve dry practices, abstraction is exactly how you do that. When you see you shouldn't abstract then you don't, hence "as much as possible" or "wherever possible".

Please elaborate why you believe its not good advice?

Collapse
 
griffinsauce profile image
Joris Griffioen

You didn't look up WET did you? I'm not going to badly repeat what has been written by others way better, so do some research here.

One link that comes to mind is this: overreacted.io/goodbye-clean-code/

so where you can't abstract you don't

Yes, this is bad practice. You don't abstract because you can, you abstract when it helps. Abstraction introduces complexity, you have to balance the cost of that complexity with the benefits.

Abstraction is important to not repeat code and reuse methods and functions.

Repeating code is not a sin (see the link above). Every line of code has a different context, as those contexts diverge over time your abstractions increase in cost.