Summary
In this chapter, you learned some of the practical techniques for breaking your user interface and application into modular components that can be reused. It's always a good idea to start with the finished user interface and break it up, preferably from the mockup stage. It's also good to identify where some parts of the system can serve multiple roles, for example, being both a read-only display and an editor. It's also a good idea to wrap components within other components, even if it's just conceptually. Keeping certain types of event handlers as their own modules makes them reusable over screens that don't share exactly the same widgets, but need to reuse the same logic.
When building user interfaces, it's a good idea to use an Activity
to just wrap a collection of Fragment
rather than nesting the screen logic in the Activity
. This will allow the Fragment
to take on specific responsibilities (such as attachments), making them more reusable elsewhere in your application. It also...