What is the best way to split a large application into modules?

Building the application I'm working on takes a lot of time. This is the largest I have worked on. I tried to adjust the gradle settings, which helps, but still the build is rather slow.

Since the application was built without the use of modules, its just a lot of packages, and now I'm wondering how I can "extract" some of them and put them in separate modules. AFAIK modules should not depend on the application module, so I wondered if there was a tool or technique that would allow me to analyze the code and help me find the right packages to extract, since this is a lot of code.

How do you approach my problem?

+8
android code-analysis gradle
source share
3 answers

Your question: Modulation of source code in Software Engineering. This is a new topic in software, and there is little mention of it. Source code modulation is a refinement of the concept of clustering in source code.

in this link from ( see link 1 )

The goal of a software modular procedure is to separate the software into subsystems to provide an abstract view of the architecture of the software system, where the subsystem consists of a set of software artifacts that interact with each other to implement a high-level attribute or provide a high-level service for the rest of the software system.

However, for large and complex software systems , modulation software cannot be performed manually , due to the large number of interactions between various artifacts and the large size of the source code. Consequently, a fully automated or semi-automatic tool is required to perform software modulation.

There are many methods (algorithms) for modulating the source code ( see link 1 ):

  • Hierarchical methods:

    • Single Link, Full Link, Mid Link
    • Ward method, median method, Centroid method.
    • Combined and weighted combined methods
  • Search Based Methods:

    • Climbing a hill, multiple climbing a hill (HC)
    • Simulated Annealing (SA)
    • Genetic Algorithm (GA)

Note that you can find other Clustering methods with these names. But modulation is a little different. They are tuned to modulate the source code.

The general process of modulating the source code is shown below:

enter image description here


There are many tools you can use. You can use them in the modulation process:

  • Static source analysis tools (to get the ADG format, etc.) see the link here - (as understood, NDepend, etc.).
  • Visualization Tools - (Graphic Visualization) see the list here (e.g. Tom Sawyer Visualization )

For example, a small project. If your project structure (created from source using static analysis tools) looks like this:

enter image description here

The result can be like this (after applying the modulation process):

enter image description here

+4
source share

This is primarily a design problem. Since you stated that the project already has a large amount of code, one approach would be to analyze the UML diagram for the entire project structure. The goal is to identify areas of architecture where interactions are closely related between several classes, groups can also be formed based on which classes have the same external dependencies.

With this approach, you reduce the complexity of a large project, de-link classes from external dependencies that they do not use in a large project. The invisible modules into which you split the project will have faster build times. The modules into which you divided the project can be indicated as dependencies in the main project. An additional advantage is that only modified modules in the main project will be rebuilt with each change.

This post discusses the many plugins of the UML diagram generator for Android Studio. Iris code is a good option that you can install through the menu of the Android Studio plugin. An example is the output of Code Iris for an example of FaceTracker application for Android (click on the diagram to enlarge):

enter image description here

The diagram shows the grouping of packages and projects. You can see that different projects are divided into separate green fields, in these boxes are boxes for packages, and then, finally, classes and interactions. By analyzing UML, you can first determine how best to group your classes and create separate projects. After dividing the main project into modules, you can again use Code Iris to visualize interactions after making changes to the structure.

+7
source share

I would divide my application into four layers:

  • Layer for Objects: in this layer, you initiate all the objects you need with the get and set methods {example:

class person { private int _PersonID; endregion public int PersonID {get {return _PersonID;} set {_PersonID = ;}} endregion }} >

  1. Layer for accessing data: this layer will process the contribution of connecting your database and do everything related to procedures, triggers and functions. {this section must be truly protected} {Do not execute sql queries inside your code, do not create all your queries in your database and do not connect this procedure by calling their names in your codes} {example: //

    class personDAO { private List _GetPersons(){//codes here} ; public List GetPersons(){ _GetPersons();} public delegate void del_GetPersons(); private del_GetPersons _del_GetPersons; public del_GetPersons Del_GetPersons { get{return _del_GetPersons;} set {_del_GetPersons=value;} } public personDAO() {//constructor del_GetPersons=GetPersons; } } }

  2. Layer for a business object, this layer delegates data access library instances, then modifies them and adds them with several exception handlers. "we use delegates to hide the names of the methods that are used by aligning the method that it delegates to the DataAccessLibrary constructor function." example class personBO { //create instance of personDAO //create an other delegate for personBO //create private method _GetPerson(){//call personDAO.del_GetPersons()} //create public method GetPerson() {// call _GetPerson()} create public constructor function personBO{//set public method = delegates of bo} }

4. Finally, there is the last level or level in which the user has the right to interact with him, these are several related forms that are processed through interface handlers and hidden back-end Handlers (where they are called using delegates).

  • this structure may take longer when creating the application than another

  • but it's fast (as delegates do it faster)

  • it is protected (since it is developed in many layers and you are dealing with hidden methods that call an instance of the object, not the object itself).

+1
source share

All Articles