The code design guidelines (mostly just for Java ) that I read, somehow miss the questions I am interested in:

  1. Do I understand correctly that a long code in the activation class is not welcome and should be broken down into separate classes according to the task being performed?

  2. Then, by what principle should the code be divided into classes: according to the principle of performing one small task (for example, checking for new information on the server) or a complex of similar tasks, one class is allocated (for example, besides checking this information, also borrowing from it)?

  3. Where should the files of separate classes be located, in the same place as the activation classes or in their own directory?

  4. I read the recommendation, where it was said that nested classes are unacceptable, except for the cases when the nested class is used only by the parent class. But in the android just such a situation. Only the activation class will use those classes that I write for it (nested or separate).

Does not the code readability make it more difficult to break the whole code into classes?

Closed due to the fact that the issue is too general for the participants aleksandr barakin , Peter Olson , Nick Volynkin , pavlofff , BOPOH 12 Aug '15 at 3:12 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • This is a very big question. I do not think that you can answer it here. To learn and understand the answers, you need to read a couple of good books on OOP and stuff cones on writing code. In addition, the division into classes - this is no longer the design of the code, it is the architecture of the application. It's great that you are interested in this, of course. - Nick Volynkin
  • Read books and blogs by Mayer, Hardy, Daytel, and so on. recognized experts - gradually understanding will come. In one article, this is not to convey. - pavlofff
  • Thanks for the advice, I do not bypass the recommendations on the design of the code, etc. Now, in the course of the study, I met with a specific question, the coverage of which I could not find anywhere, so I want to get a specific answer: on what basis should the code related to an activation be broken up into classes and should it be done at all? - Best Friend
  • Your question is too general to get a good answer. I think when deciding on the need for a new class, you should be guided by the principles of SOLID . In your case, the "S" acquires special relevance - Single responsibility - the principle of the only responsibility. Activity, in essence, is a controller, it should only manage data on the view (View) and possibly elementary logic, which it is senseless to carry into a separate class. Data processing, loading / unloading, etc. taken out. - pavlofff
  • Most likely the Nested class is not what you think. The breakdown into classes will simplify the readability of the code due to encapsulation, that is, instead of a long bootleg of data you have one call from the class to load this data and is immediately clear from one line - we load the data here. Look at the API structure of Android itself, how many different classes are there for all sorts of actions. Consider that you supplement the API with your own classes that are not there. Use them the same way. - pavlofff

1 answer 1

There is no definite answer, but there are recommendations for the development. On Habré somewhere was the translation of this article if with English tight.

  • We write a beautiful code: link There is also a link for those who have difficulty with English: English link - LEO
  • Thanks, but I already read all these resources. I did not find the main thing that worries me. Namely, this was described in the question: according to what principle does the code relating to some kind of activit be split into classes? - Best Friend