Improvement suggestion - Reusing common code across projects


#1

Just working through chapter 24 and have been directed (for the second time) to copy and paste SingleFragmentActivity into a new project, along with associated xml files.

What if the user was directed to move this code into a library project which was then re-used across multiple app projects?

As a developer who believes in The Boy Scout Rule and Don’t Repeat Yourself, I’m going to want to know how to do this eventually - the sooner the better.

Enjoying the book so far :slight_smile:

thanks,

Andrew


#2

Yep, that’s exactly what you’d want to do. Due to time and space considerations, we had to omit examples of Android Library projects (which could easily be a short chapter on its own). In the real world, that’s how you’d reuse the code for SingleFragmentActivity (and other code of general use).