Good practices to keep code clean

-2

Developing on Android a few months and one thing I noticed is that the more features a screen has, the more messed up the code gets!

What do you mean?

Imagine an activity that has Loading bar, several actions that make asynchronous calls, etc. the source code is full of classes and very messy, do you know a good practice to group these classes into separate files? Any good practice is welcome!

    
asked by anonymous 08.08.2014 / 23:20

1 answer

2

I use the following structure to manage packages and classes:

  • *. activity - A group of classes that handle activity.
  • *. adapter - A group of classes that use adapters.
  • *. broadcastreceiver - Group of classes that receive broadcast signals.
  • *. db - Group of classes that handle database
  • *. db.tables - Base class group of your database tables.
  • *. fragments - Group of classes that handle fragments in your project.
  • *. service - Group of classes that generate services in your program.
  • *. sync - Group of classes that use asynctask or another type of synchronization system.
  • *. utilities - Auxiliary class group.

You can also create class packages according to your needs. Make good use of the concept of code modularization. Also comment your code, the comments help you when you are oriented.

I hope I have helped.

    
13.08.2014 / 21:17