As a class gets bigger and bigger it becomes harder to maintain. So I would love to divide some of my classes in multiple files. Defining the class in a file, something like:
var animal = can.Construct({
someClassMethod: function() {...}
}, {
somePrototypemethod: function() {...}
});
then later in a separate file I would love to reopen this class, and add new class methods/properties, and prototype methods/properties to it.
Is this possible in canJS? If no, what should be a possible workaround?
You can always add properties and methods to the prototype and the constructor. That's how JavaScript works.
So as long as you still have access to animal
you can just do
animal.anotherClassMethod = function() {}
animal.prototype.anotherPrototypeMethod = function()
in another file. However, having class definitions get too big is usually a problem of them doing too much. If they get too big to be maintainable in one file (which would mean 2000+ lines of code) there is definitely a better way to refactor besides just splitting them up. A downside of splitting it into separate files is definitely that it might be hard to know what functionality is where.