title: Generic BaseFragment architecture with bounded type parameters to work with ViewModel
body: <p>I am trying to come up with an architecture for my BaseFragment. Here is what I've accomplished so far:</p>
  <pre><code>public abstract class BaseFragment&lt;V extends BaseViewModel&gt; extends Fragment {   
  
         private ViewModel viewModel;
  
         onAttach(Context context) {
           super.onAttach(context)
           viewModel = (T) ViewModelProviders.of(getActivity() , new BaseViewModel.Factory(getActivity())).get(getViewModelClass());
           // viewModel.registerView(getViewImpl());
         }
  }
  </code></pre>
  <p>and when I am creating any new Fragment, I do like this:</p>
  <pre><code>public class SomeFragment extends BaseFragment&lt;SomeViewModel&gt; {
  
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
     }
  
  }
  </code></pre>
  <p>Its all fine but what if I want to create a Frgament where in I don't need any ViewModel? Should I remove the bounded type arguments from the BaseFragment and register the ViewModels in their respective Fragment? If so then what is point having bounded type arguments in the BaseFragment, it's not granular enough.</p>