I recently watched this video: ArcGIS Web AppBuilder: Development Tools and Techniques | Esri Video and have been implementing some of the tools and techniques that were suggested. The sub widget pattern is a Tom Wayson suggestion. His GITHub repository of the session is here: tomwayson/web-appbuilder-tools-techniques-dev-summit-2015 · GitHub.
The sub widget pattern separates your custom widget code from the base widget implementation by embedding your sub widget in the base widget. Essentially you are using the base widget as a wrapper for your sub widget, which contains your business logic. Start the video at 8:06 to see the sub widget presentation. I recommend watching the entire video though.
OK, thanks for the exploitation. I was actually at that dev summit presentation, I forgot what Tom was calling it. I don't use this pattern for any of my widget so I don't have advice or a sample. I will tag Tom Wayson and see if he has any input.
I may be getting my terminology mixed up. I've just been learning about widgets that incorporate templates. I notice now that that the samplewidgets/demo has these lines in it:
//please note that this property is be set by the framework when widget is loaded.
Apparently I can get a template to load into the main widget using this in the define() 'dojo/text!./templates/TemplateName.html' and then inject this dependency into the widget.
The Print Widget in WAB uses this pattern. It was basically the print widget written by David Spriggs when he was at Esri. It is in the Configurable Map Viewer (CMV). Esri essentially put a wrapper around it in WAB.
My Print Plus Widget was originally for the CMV. I ported it to WAB in just a few hours following the same pattern Esri had used with David Spriggs' Print WIdget.