Comments (1)
- 其实最初的版本,我就是多个TitleBar对应一个XML文件的,不同的Fragment使用一个XML文件,然后在相应的fragment中用代码对TitleBar里面的TextView做文本调整。但是到后面,TitleBar的功能就不这么简单了,比如首页的TitleBar就有个小箭头图标,发现页的TitleBar是一个搜索栏等等,这样,我还需要在代码里面做各种隐藏和显示操作,这样会让代码非常混乱,也很难后期维护。所以我打算每个fragment对应的TtileBar,如果后期TitleBar需要增加新的功能样式,我也可以方便扩展。
- 为什么采用MVP,如果你自己负责过一个非常完整的App项目,我想你就能明白架构对于程序设计的重要性。我最初设计的版本并没有使用MVP,导致了在fragment中不仅仅需要做更新各种UI部件,还需要做数据的网络请求,请求回来的数据我还要进行相应的二重处理等等。不仅仅在这个fragment中我需要做这些操作,我还需要在别的fragment中也需要重复做这些操作,这样代码就会冗余,而且会难以后期维护,我有一段时间写到后面完全不想再写,觉得非常烦,后来下定决定重构全部代码,才有写下去的动力。
你提到类爆炸这个点,我觉得其实还好,并没有到爆炸那么恐怖,只是把若干的功能都分离成更小的单元而已,MVP导致类的增多,其实大部分是接口类的增多,通过继承接口,我们后期做各种扩展,而不会影响到之前的代码方案,这也是MVP的好处。这也符合『对修改封闭,对扩展开发』的设计原则。
希望我的回答能解决你的困惑!
from weibo.
Related Issues (20)
- 微博详情页转发评论悬浮 HOT 2
- 评论失败
- 大神怎么不继续维护这个项目了? HOT 2
- 关于下拉刷新与上拉加载更多 HOT 1
- 大神,关于recyclerview置顶以及取消置顶有没有好的方案,百度谷歌找遍了,自己实现的时候问题颇多 HOT 2
- 运行一直卡住在 gradle:resolve dependencies ':multiwindow:_debugPublish' HOT 1
- 关于微博图片浏览器区别加载普通图片、长图、gif HOT 1
- 无法登陆 HOT 1
- 这个客户端的微博授权过期了,大佬,无法登陆了 HOT 1
- Saving image error.
- 强烈建议加入抢沙发功能
- 点击图片 程序退出
- 点击登录的时候Weico授权失效了
- 啊
- 无法登陆? HOT 1
- 无法登陆?
- 无法登陆:对第三方应用授权时出现错误
- 用我自己的微博授权点击登录后显示是空白
- 在网盘下载的无法注册账号
- 网盘链接炸了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weibo.