DEV Community

Discussion on: Helpful patterns I use in Vue

padarom profile image
Christopher Mühl • Edited

Using too much of a framework's special sauce increases the dependency - not good!

I‘m not sure I agree with this statement. The purpose of a framework is to make certain development tasks easier. To make use of those you will pretty much always be required to write framework-specific code (if not, why would you be using the framework to begin with?) Of course it‘s debatable whether syntactic sugar is always worth the reduced clarity of intent, but I don‘t see the dependency on the framework to be the issue here.

I‘ve not had to convert a huge codebase from one framework to the other. Usually it‘s been complete rewrites, occassionally taking inspiration from the old code, but never could I just translate Vue into e.g. React just one-to-one without also having to change tiny details that are just too different between these frameworks anyways.

Other people‘s mileage may vary, but I think not making use of reasonable syntactic sugar due to fear of maybe having to translate it into a different framework at some point in the future will make your life harder, not easier. This is not to say that .prevent specifically is a worthwile feature, but there most certainly are other framework-specific features that would fit into this category.

jfbrennan profile image
Jordan Brennan Author • Edited

I prefer composition, so when possible I take opportunities - even small ones like avoiding low-value template shortcuts - to flatten the dependency graph. This leaves as many pieces of the system as possible open to change or replacement.

Vue helps with structure and managing the render cycle - the biggest pieces of an app - but I don't want it doing much more than that for me. There's better options, usually vanilla js, for other parts of an app and I don't want to lock myself in or bloat my project by YOLO-ing the framework. Thankfully Vue is not like React or Angular or Ember in that way, so it's not possible to get that deep, but I avoid it just the same.