title: What is the design logic behind Fragments as static inner classes vs standalone public classes?
body: <p>I am not able to understand one important aspect of Android software design which I am just starting out with, from what I know <code>Fragment</code> design has been adopted in order to decouple the code, where the intuition is that the <code>Activity</code> remains as is and <code>Fragment</code> can be <em>reused</em> else where, maybe even in a different activity, or maybe along side other fragments, in something like a Master/Detail flow or landscape UI.</p>
  
  <p>Okay so I have seen quite a handful of questions on SO asking as to why <code>Fragments</code> are placed as static inner classes within an <code>Activity</code> and the answer there is that if we do not make them static, the <code>Fragment</code> may hold a reference to the activity and something like a screen rotation or a re-draw might leak the activity or something.</p>
  
  <p>This brings me back to square one and I have the question that, well, if the Fragment design has been adopted in order to decouple the code, then why are we marrying the <code>Fragment</code> to the <code>Activity</code> by putting it <em>inside</em> the activity class and not putting them as standalone public classes? Isn't that totally contradicting to the very existence of Fragments?</p>
  
  <p>What is the down side of having a project structure as such? Where each <code>Fragment</code> is a separate class of its own? Given that my Fragment code can grow to like a 1000 lines especially when trying to do animations I am seeing this as far more neater, decoupled and reusable within activities other than it's intended parent Activity. </p>
  
  <ul>
  <li>Do we still suffer from the memory leak issue mentioned above?</li>
  <li>Am I missing something about the design logic? Please educate me.</li>
  <li>Is there a way where the Fragments stay as an inner class and still be used elsewhere? I might be missing something here as well... so do inform me.</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/ZEvmr.png" alt="Project structure"></p>
  
  <p>Any other project design methods, concepts, corrections to my intuition are more than welcome since I am just starting out here, I would love to know all my options.</p>
  
  <p>Thank you :)</p>