android10 / android10/Android-CleanArchitecture

Where is the best place to validate the data?

Đang mở
#88 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
discussion question
Ngôn ngữ chính
Java
Star
15.5k
Fork
3.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

In order to load the model in a view i have to check the data for some preconditions. For example, for some string color value("#ffffff"), which is coming from backend, we have to check it if its not null, then parse it with Color.parseColor(). Where is the best place to put such code like this?
Is it a good idea, if i define the presentation layer model's backgroundColor propery as int and perform checks/transformation from String (domain layer object) to color int (presentation layer) in the model data mapper in the presentation layer?

---

DOMAIN LAYER
Object {
private String mBackgroundColor;
}

-------------------tranformation ---

PRESENTATION LAYER
Model {
private int mBackgroundColor;
}

Or maybe validation code have to be a part of the buisiness logic but for transformation in the presnetation layer from String to int i just call "trusted" Color.parseColor().

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.