I've addressed the modularity on the angular side by creating a directory structure for my apps, which breaks them out into reusable pieces by component feature. If I have an Ask a Question publisher action for example, that gets its own directory in my filesystem and version control, that contains its own controllers, directives, HTML partials, etc. We then use requirejs and grunt to compile and bundle pieces together into different static resources for use on different VF pages.
The problem is on the Visualforce side. There is no equivalent requirejs, that allows me to custom bundle JS remoting methods into a controller based on an feature config. I have a few options as I see it, and there may be more I'm not seeing:
- Make all remoting calls global, such that they can be called like any other static method from apex. This allows me to just use a method from another controller. It does not allow me to eliminate creating an @RemoteAction for some function in a new controller, but at least most of the logic can be abstracted to avoid redundant code.
- Abstract as much logic as possible out of the controllers and move them to helper classes with static methods
- Create a single controller for all of my Angular apps, with a ton of remote actions. I would assume this would incur a performance hit?
What's the optimal architecture here?