There is an app that I made by myself, TwitMorse, but until now it has a decent package structure. I had never thought about it, so I decided to think about it after rehabilitation.
Simply put, managing classes with a specific role in separate folders. If it is developed by one person, it may not be necessary because if that person knows what role the class has, it may not be necessary, but every time the function is expanded, "What? What ?! "
For example Classes that convert Strings, etc. go to the folder named "strings" The class responsible for the screen display system is grouped into folders (directories) such as "ui", and if it is fragment, "fragments".
TwitMorse hasn't been updated at all since October last year, so it's been six months since then. When I opened it, it said, "Wow, I don't remember anything about which one ...". So let's organize the class properly this time! I thought.
I would like to introduce an easy-to-understand article.
Earlier I wrote that packages are useful for managing classes, but there are other benefits to using them. Suddenly, duplicate class names are not allowed. Even if the processing is different, it is not allowed. I don't think that such a problem will probably occur if you develop it by yourself, but if you develop it with a large number of people, there is a high possibility that you will suffer. However, if the package is different, the class name can be covered! This is because different FQCNs can distinguish classes.
For example, even if there are several people with the same surname and the same name in the same school, you can distinguish them by grade and group, right? It's the same.
Quoted from Introduction to Java Package Management.
I started thinking that it was simply digging a directory and putting a java file in it, which is surprisingly dull.
Well, divide it like this and leave only the ones that do not have more than one outside (I do not know the correct method)
Android development is Android Studio, but every time this child moves a file to a directory, he asks "Refactor?". I chose "yes" without thinking about anything.
Recalling the role of the class, thinking about the distribution and finishing the work of transferring ... When trying to build
** Bright red yanke ---------- **
▂▅▇█▓▒░ ('ω') ░▒▓█▇▅▂ Wow ah ah ah ah
The reason why this happens is Because I didn't separate the packages
The protected methods can no longer be called. Until now, it was protected because it was in the same package, but this time, due to the change in the package structure, many methods that cannot be accessed (cannot be used) from other packages have been created unless they are made public.
I'm addicted to this trap, and it takes 30 minutes to crush the error.
It was really helpful with a small fucking app.
If you make it by yourself like me, you will think, "I'm developing it by myself, and it's okay if it's a package or something." If you try to eliminate it, you will have to fight the error hell as a secondary disaster.
** You should think about the package structure properly! First! !! Even individuals! !! !! ** **
I noticed that, so I posted it on qiita for the first time in a while as a rehabilitation.
Recommended Posts