根據(jù)團(tuán)隊(duì)開發(fā)經(jīng)驗(yàn),不斷完善中
哪些地方容易出bug
條件覆蓋不全
- if else 條件只覆蓋了if 咽安,else里沒(méi)有處理
- 條件執(zhí)行伴网,提前return掉板乙,后續(xù)的其他處理被忽略
- 復(fù)制粘貼:復(fù)制粘貼是最容易出錯(cuò)的是偷,表現(xiàn)在 if else 條件語(yǔ)句里面,最后個(gè)else if 的
tvClassBehaviorContent
沒(méi)被賦值
Paste_Image.png
邏輯混亂
- 復(fù)雜判斷:一個(gè)if判斷語(yǔ)句里面涵蓋了多種判斷條件
- 多頭領(lǐng)導(dǎo):比如一個(gè)Activity的View控制募逞,除了activity本身蛋铆,又開放給了子fragment
- 異步操作,狀態(tài)同步:子頁(yè)面A異步操作結(jié)果放接,需要對(duì)父的UI做修改刺啦,而此時(shí)用戶切換到了子頁(yè)面B,子頁(yè)面A的UI操作纠脾,會(huì)出現(xiàn)在子頁(yè)面B上玛瘸。
- 異步操作蜕青,線程同步:
舉個(gè)rxJavasubscribeOn(Schedulers.newThread())
的例子,異步方法沒(méi)執(zhí)行完就返回了糊渊,此時(shí)數(shù)據(jù)是空的
private List<Person> getPeopleList() {
final List<Person> peopleList = new ArrayList<>();
Observable.from(MOCK_LIST()).filter(new Func1<Person, Boolean>() {
@Override
public Boolean call(Person m_class) {
return m_class.getAge() > 50;
}
}).toList().subscribeOn(Schedulers.newThread()).subscribe(new Action1<List<Person>>() {
@Override
public void call(List<Person> classes) {
peopleList.addAll(classes);
}
});
return peopleList;
}