DEV Community

Discussion on: Splitting Javascript Classes Into Different Files

Collapse
 
kmwill23 profile image
Kevin

I imagine the idea is similar to C# partial classes. I personally wouldn't split up a JavaScript "class" into multiple files just for organization. If a class gets too long, you have to really question why that is and if there's some refactoring to do.

The case for using "partial" classes is more about extending functionality. This is useful in template-built code, or if you feel like extending a third party library without modifying it. I would say it is like interfaces and abstractions, but you'd be better off using prototypical inheritance there.

So my final opinion! Don't do it just for organization or to keep file sizes small.