Home  >  Q&A  >  body text

大家怎么看待Android的面向Holder编程?

最近在熟悉一套面向Holder开发的一套代码,这种方法确实减轻了Activity的负担,可能是原来没有这么写过,很不适应,有没有熟悉的来说一说到底有什么好处或不好?

PHPzPHPz2712 days ago511

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 15:35:59

    In the original design of Android, Activity and View play the roles of Controller and View. However, in most development, developers write the original View code into Activity for convenience, especially the combination of View controls. At that time, we did not implement the encapsulation of the combined control by ourselves, but wrote the code into the Activity in a heavily coupled manner.

    As the program grows, there are more and more codes in the Activity, and the volume is increasing, making maintenance more and more troublesome. The use of Holder is actually to separate the display part of the View in the Activity, and leave the display of the combined View to the Holder to complete. This clarifies the relationship between Controller and View, reduces system coupling, and improves maintenance efficiency.

    reply
    0
  • Cancelreply