android10 / android10/Android-CleanArchitecture

Where is the best place to validate the data?

未關閉
#88 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
discussion question
主要語言
Java
星號
15.5k
分支
3.3k
PR 合併指標
30 天內沒有已合併 PR

描述

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().

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。