-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Organize by feature - View Injection #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I won't go as far as creating separate modules per feature, as it comes with a list of problems and overhead in setting up a complex project correctly. Much code is also shared beween different features, so you're also stuck with setting up that correctly. Here's a quick example. Notice that "caching" is also a "feature" of the app. Features aren't always what the app does from a user's perspective. They are everything that an app does.
You can also go the 3-tier module route that this project uses as an example. Here is a good read on the topic. |
When would you generally decide to split into a module? Is having a large application inside a single module fairly common and generally accepted as a good practice? You're right, I was having a trouble in trying to setup the project correctly since I kept running into circular dependencies, but was willing to pay the price of a one time setup v/s having to refactor all over again. |
I think three modules as example is good enough. Sometime we need more than 3 but it shouldn't be general. Actually you should separate your project into libraries rather than modules. When you have a really big project you can split into group of features module should not each module for each feature. |
It al depends on you/your teams needs. Large applications can exist is one module. And even then, things can change, there is nothing wrong with refactoring project structures of the scope of the project increases. The 3-tier module setup in this example is a very handy one because of several reasons, but this also makes a project packaged by layer, instead of feature. There's an ongoing discussion here about project structures. I posted some more ways to structure there. |
This here is an interesting conversation. I never before saw things the way @Trikke puts them. "I'd say you shouldn't think of features and feature-teams so rigidly." - superb Glad to borrow a new lens for coding sight. @Trikke , would you mind sharing a repo or blog outlining the given code arrangement? |
Having a module per feature is a lot of overhead and unnecessary complexity. Why you wanna do that? We do not work that way at SoundCloud, not even close. We actually have a similar arquitectural approach to this repo but with only one module. This solution came out of my personal experience and it has nothing to do with my employer. |
If you have your activities isolated on modules, How are you starting those activities from different modules? |
Certain features are pretty good candidates for modules, e.g. the authentication module or a networking module and even in some cases, certain design elements that are common amongst company apps. @kuassivi : The main app has a dependency on the other modules and the main app controls all navigation, so moving between activities is via the main app. |
Anyway.. I have received my answer. Thanks for helping out. |
@RowlandOti There's an ongoing discussion here about project structures. I posted some more ways to structure there. |
In your blog, you mentioned that organizing the code via feature is better and I totally agree. In my case, I've split my app into different modules and each module is actually a feature. I assume that this is how you guys also work at SoundCloud so as to allow individual teams working on a feature to work independently.
On splitting the code by module, I'm not able to use Butterknife's
@Bind
annotations since Android doesn't markR
constants in module asstatic final
. Hence I get a compile time for the following@Bind (R.id.auth_et_password) EditText passwordTxt;
Error received : "Error:(44, 15) error: element value must be a constant expression"
So how do you guys inject views? Do you have a custom framework or use AndroidAnnotations framework or something else or you don't split by modules?
DISCLAIMER: I'm a Android noob.
The text was updated successfully, but these errors were encountered: