[Draft]ios.architecture.16.truth-information-flow-and-clear-responsibilities-immutability

Source: Internet
Author: User

Concept:truth, Information Flow, Clear responsibilities and immutability

1. Truth

1.1 Single Source of Truth

A single fact/true wish source

REF[2] ref[3]

One core principle that's good to keep in mind when modelling various states are to try and stick to

A "single source of Truth" as much as possible. One easy Wayto look at this is so you should never

need to check for multiple conditions to determine REF[2]

1.2 Truth vs

REF[1]

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 isn't based on identity:i.e. The value objects is equal when they

The same value, not necessarily being the same object.

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

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

To is immutable, as client code cannot put the value object in a invalid state or

Introduce buggy behaviour after instantiation. " REF[9]

Value Object and Mantle

For the Objective-c class to being 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

REF[10]

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

    • Objc.io:Value Objects
    • Wikipedia:builder Pattern
    • Wikipedia:immutable Objects
    • Concepts in Objective-c Programming:object mutability

5. Value Objects (Read Again)

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

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

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

7. Boundaries (toRead)

A talk by Gary Bernhardt from SCNA 2012

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

8. Improving immutable Object initialization in Objective-c

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

Ahkbuilder

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/

Objective-c Value Objects:code Generation

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

Building and managing IOS model objects with remodel

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

[Draft]ios.architecture.16.truth-information-flow-and-clear-responsibilities-immutability

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.