Monday, 21 October 2013

Android Packages Organization

I like my stuff to be organized, in the same way I like my code to be organized. Here's the structure that I usually adopt for my Android projects:

  • com.<company-name>.<project-name>: The main package, here I store only the Application class. All following packages will be sub-packages of this one.
  • .gui: Contains all the classes related to UI management. Usually this package is empty, the content is organized in sub packages.
  • .gui.activities: Contains all the Activity classes.
  • .gui.fragments: Contains all the Fragment classes.
  • .gui.views: Contains all the View classes.
  • .gui.adapters: Contains all the Adapter classes.
  • .gui.dialogs: Contains all the Dialog definition classes.
  • Contains all the UI related classes that doesn't fit in previously described packages.
  • .domain: Contains all the java beans that represents the application domain.
  • .domain.enums: Contains all the enumeration files related to the application domain.
  • .core: Contains all the core logic classes. These classes form a layer that services the UI classes managing local storage, web service connection, data elaboration, ...
  • .db: Contains all the database management classes.
  • .db.tables: Contains all the database table definition classes.
  • web: Contains all the web service communication classes.
  • web.messages: Contains all the message definition classes.
What do you think of it? Every comment or suggestion is welcome.