单一的事实/真想来源
Ref[2] Ref[3]
"One core principle that is good to keep in mind when modelling various states is to try to stick to
a “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]
google "immutable object in objective-c"
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
. "
Ref[4] Ref[5] Ref[8]
Too many parameters in initializer method
Objective-C Version
.html
Swift Version
Todo
Ref[10]
Ref[11] Ref[12]
Remodel Plugin
.md
Ref[13]
Ref[14]
1. Advanced iOS Application Architecture and Patterns
2. Modelling state in Swift
/@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
4. Immutability and Builder Pattern
5. Value Objects (Read Again)
/
6. Mutability, aliasing, and the caches you didn't know you had
7. Boundaries (To Read)
8. Improving Immutable Object Initialization in Objective-C
/
AHKBuilder
9. Simplifying Objective-C Value Objects with Mantle and the Builder Pattern (AAAA+)
/
10. Objective-C Value Objects: Code Generation
/
11. Building and managing iOS model objects with Remodel
/
12. 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. plank
A tool for generating immutable model objects /
/
14. ConsistencyManager-iOS
A library that manages consistency of immutable models …
转载于:.html
本文发布于:2024-01-27 17:53:28,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063492081753.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |