博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Draft]iOS.Architecture.16.Truth-information-flow-and-clear-responsibilities-immutability
阅读量:6225 次
发布时间:2019-06-21

本文共 4947 字,大约阅读时间需要 16 分钟。

Concept: Truth, Information Flow, Clear Responsibilities and Immutability

 

1. Truth

 

1.1 Single Source of Truth

单一的事实/真想来源

Ref[2] Ref[3]

 

"One core principle that is good to keep in mind when modelling various states is to try to stick to

“single source of truth” as much as possible. One easy wayto look at this is that you should never

need to check for multiple conditions to determine what state you are in." Ref[2]

 

1.2 Truth vs 

Ref[1] 

 

2. Information Flow (Data Flow)

 

 

 

3. Clear Responsibilities

 

 

4. Immutability

google "immutable object in objective-c"

 

4.0 Mutable vs Immutable Object 

 

 

4.1 Why immutable object?

 

Value Object

“In computer science, a value object is a small object that represents a simple entity

whose equality is not based on identity: i.e. two value objects are equal when they

have the same value, not necessarily being the same object.

 

Value objects should be immutable: this is required for the implicit contract that

two value objects created equal, should remain equal. It is also useful for value objects

to be immutable, as client code cannot put the value object in an invalid state or

introduce buggy behaviour after instantiation.” Ref[9]

 

Value Object and Mantle

"For an Objective-C class to be used as a value object, it needs to be immutable,

support value equality, implement proper hashing, and support NSCopying.

Mantle provides the latter three just by subclassing MTLModel. "

 

4.2 Immutability and Builder Pattern

Ref[4] Ref[5] Ref[8]

Too many parameters in initializer method

 

4.3 Builder Pattern in Objective-C and Swift

Objective-C Version

http://www.cnblogs.com/cwgk/p/9013260.html 

Swift Version

Todo

 

4.4 Code Generation (DSL, ruby)

Ref[10] 

 

4.5 Code Generation (remodel) 

Ref[11] Ref[12] 

 

Remodel Plugin

https://github.com/facebook/remodel/blob/master/PLUGINS.md 

4.6 Code Generation (plank)

Ref[13]

 

4.7 Consistency

Ref[14]

 

 


Reference

1. Advanced iOS Application Architecture and Patterns

http://asciiwwdc.com/2014/sessions/229

2. Modelling state in Swift

https://medium.com/@johnsundell/modelling-state-in-swift-3751a4acb8f3

Rules: 

A single source of truth

Making states exclusive

Rendering reactively

Handling state changes

Extracting information

 

3. Single source of truth

https://en.wikipedia.org/wiki/Single_source_of_truth

4. Immutability and Builder Pattern

http://kean.github.io/post/immutability-and-builder-pattern

5. Value Objects (Read Again)

https://www.objc.io/issues/7-foundation/value-objects/

6. Mutability, aliasing, and the caches you didn't know you had

https://garbagecollective.quora.com/Mutability-aliasing-and-the-caches-you-didnt-know-you-had 

7. Boundaries (To Read)

https://www.destroyallsoftware.com/talks/boundaries

8. Improving Immutable Object Initialization in Objective-C

http://holko.pl/2015/05/12/immutable-object-initialization/

9. Simplifying Objective-C Value Objects with Mantle and the Builder Pattern (AAAA+)

https://spin.atomicobject.com/2015/11/02/objective-c-value-objects-mantle/

10. Objective-C Value Objects: Code Generation

https://spin.atomicobject.com/2015/12/16/objective-c-value-objects-code-generation/

11. Building and managing iOS model objects with Remodel

https://code.facebook.com/posts/1154141864616569/building-and-managing-ios-model-objects-with-remodel/

12. 

https://github.com/facebook/remodel

Remodel is a tool that helps iOS and OS X developers avoid repetitive code by generating Objective-C

models that support coding, value comparison, and immutability.

13. 

A tool for generating immutable model objects 

https://github.com/pinterest/plank/

14. 

https://github.com/plivesey/ConsistencyManager-iOS

A library that manages consistency of immutable models 

15. 

http://blog.mrriddler.com/2017/06/28/iOS响应式架构/

16. Single Source of Truth Principal in Software Development (Android) 

https://www.youtube.com/watch?v=Ex9IT1bq0PQ

https://codingwithmitch.com/courses/android-local-database-cache-rest-api/demo/

In this course you'll learn how to build a local database cache with SQLite and Room.

The cache retrieves data from a REST API using Retrofit2. Architecture is MVVM.

17. 

https://softwareengineering.stackexchange.com/questions/284874/difference-between-single-source-of-truth-and-single-responsibility-principle

18. Understanding One Source of Truth for Analytics

https://blogs.workday.com/understanding-one-source-truth-analytics/

19. The Single Source of Truth

https://blog.buckets.co/the-single-source-of-truth-430b61d10e19

20. Why Single Source of Truth Data Systems Kill Team Collaboration

https://unito.io/blog/a-single-source-of-truth-data-system-kills-team-collaboration-heres-why/

21. Single Source of Truth

https://www.dragon1.com/concepts/single-source-of-truth

22. Single Source of Truth…and Why it Matters

https://medium.com/@elisavaccaro/single-source-of-truth-and-why-it-matters-a68e28b8c175

23. 应用架构指南

https://developer.android.com/jetpack/docs/guide

 

 

 

转载于:https://www.cnblogs.com/cwgk/p/9007000.html

你可能感兴趣的文章
关于Activity的onSaveInstanceSate()这个API
查看>>
Sphinx在windows下安装使用[支持中文全文检索]
查看>>
solr4.0安装和简单导入mysql数据
查看>>
用完成端口开发大响应规模的Winsock应用程序
查看>>
添加deb的源后,执行update报错 NO_PUBKEY 64AA94D00B849883的...
查看>>
Firefox 浏览器运行firefox os模拟器
查看>>
WINCE系统中coredll.dll有什么用?
查看>>
git 中文文件名
查看>>
转载:安卓应用运营知识:VersionCode和VersionName
查看>>
结构体的优化声明
查看>>
android 自定义permission
查看>>
Maven +Tomcat+m2eclipse的热部署(hot deploy)
查看>>
安装phpab
查看>>
Java集合--HashIterator
查看>>
Firefox Pale Moon此连接是不受信任的、无效的安全证书解决办法
查看>>
sicily 1215 脱离地牢
查看>>
python 效率测试
查看>>
iphone开源网络编程cocoaasyncsocket
查看>>
sql 分頁查詢
查看>>
Nginx负载均衡
查看>>