Can you help me understand this design pattern made by Java expert?

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.

  1. 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?

  2. 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.

2

On Android events are triggered on the main UI thread, but you can not do any work on the main UI thread.

What the developer might be doing is sending the task of addObject to another thread so that the main UI thread can continue.

Looks like he has created a few classes to make these kinds of tasks easy to do. This is good practice, but I am making an assumption. Without seeing the code of these files we won’t know for sure.

In your example;

MyDatabaseClass.addEntity1(ent);

If that is writing to a SQLite database on the Android device, then there is the risk that the database is stored on an SD card. SD cards are a bottleneck for performance on mobile devices, and this will block the main UI thread. You should not be doing any time consuming tasks on that thread.

I’m not even sure if Android will let you do it. There are some cases where the SDK will throw an exception if you attempt to do certain operations in the main thread.

7

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật