I inherited the project from a very experienced Java developer. The project is Android app and the guy who coded is is very experienced in coding regular Java apps. He introduced some file structures that I haven't come across before (I haven't coded Java apps outside Android area). I can follow the code with no problem and I actually have finished a few add-ons so far, but now I would like to know more of why he used such approach since it may help me myself write a better code. On the other hand, if his approach is not suitable for Android apps, I would like to know that as well so I don't use such structures.
I will divide all questions into points.
When dealing with a database, he made 3 layers: entities, data_access and controllers. This is a kind of MVC structure. Is it advised to use it in Android apps?
In controller part, he made the following file structure:
controller/ async/ AsyncAddObject.java AsyncExecutorAdd.java AsyncExecutorGetAll.java Entity1Controller.java Entity2Controller.java Entity3Controller.java IController.java
All async files are the generics.
Is this structure familiar to you? I remember executors used in Java, but have never used such approach in Android development. If this is a proper way, what is Executor used for?
What about IController.java
- something usual in regular Java coding?
+++++++++
Then when we want to add some entry into database, he uses the following code
Entity1 ent = new Entity1();
ent.setSomething(someParameter);
AsyncAddObject<Entity1> obj = new AsyncAddObject<Entity1>();
obj.setController(mEntity1Controller);
obj.setObj(ent);
new AsyncExecutorAdd<Entity1>().execute(obj);
Does this look confusing to you? I usually call some database method and pass object to it. For example, I would do it like this
Entity1 ent = new Entity1();
ent.setSomething(someParameter);
MyDatabaseClass.addEntity1(ent); //just an example, adding to database will be done on non-Main thread.
This is it. I apologize for a long post.
ISomething
for interfaces is common for .NET applications but not a typical naming convention for Java apps. I hope somebody with more Android experience can directly answer your question.