Giter Club home page Giter Club logo

Comments (7)

drakeet avatar drakeet commented on July 29, 2024 2

@taany6210 不客气。嗯,顺便说一下我不喜欢 DataBinding 的原因:

看过许多人使用 DB,大部分人把代码写得十分复杂又凌乱,迷失了初衷。

DB 把一些简单的数据绑定写到布局去,省了一点点 Java 代码,却要在 Java 层面写各种 "转交"、"代理" 等等逻辑,也使得代码变得绕来绕去,许多原本很简单很直观的需求,偏偏要绕一圈。而且将一些逻辑移到布局文件去,使得布局文件失去了纯粹性,当需要找逻辑代码的时候,可能就得东找西找。也使得布局文件变得非常不清爽、混杂,无法向外提供复用,也没有编译器很好地协助校验。而且许多工作在布局文件上做也十分有限,使得不得不又回到 Java 层,向 binding 索要出 view,然后对 view 进行一些操作。何苦呢?

而对于过分响应式、双向绑定设计,我只能说,一段时间后再回过头来看看当初设定的一堆关系,还能理得清吗?或者做一些事情会不会手心冒汗,因为影响面很可能不是那么直观。

再然后,DB 带来了许多原本没有的问题和异常,也带来了协作成本。

from multitype.

drakeet avatar drakeet commented on July 29, 2024

我不喜欢 DataBinding(以下简称 DB。如果有人感兴趣,我可以说说不喜欢的理由),对 DB 不熟悉。但很明显,你有一个简单的做法:你可以由你的这个 BannerViewProvider 提供一个 setViewModel 方法或使用构造函数,来由外部注入 viewModel.

from multitype.

drakeet avatar drakeet commented on July 29, 2024

由于长久不使用 DB,我已经忘记 DB 的许多细节内容了。不知你的 viewModel 是由哪里生产的?

from multitype.

drakeet avatar drakeet commented on July 29, 2024

你可以把 provider 当成一个普通类对象,平时我们是怎么给一个普通类对象传递数据或对象的?不就是采用构造函数初始化传入,或使用各种 setter 方法传入。

from multitype.

taany6210 avatar taany6210 commented on July 29, 2024

哦哦哦,fuck 我没反应过来。谢谢了。

from multitype.

taany6210 avatar taany6210 commented on July 29, 2024

我想知道你不喜欢DB的理由,能告诉我下吗?

from multitype.

taany6210 avatar taany6210 commented on July 29, 2024

@drakeet 😢可能我还理解不到这个层面,我回去想下。

from multitype.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.