舉報(bào)

會(huì)員
Hands-On Design Patterns with Swift
Florent Vilmart Giordano Scalzo Sergio De Simone 著
更新時(shí)間:2021-07-02 14:46:05
開(kāi)會(huì)員,本書(shū)免費(fèi)讀 >
SwiftkeepsgainingtractionnotonlyamongstAppledevelopersbutalsoasaserver-sidelanguage.Thisbookdemonstrateshowtoapplydesignpatternsandbestpracticesinreal-lifesituations,whetherthat'sforneworalreadyexistingprojects.You’llbeginwithaquickrefresheronSwift,thecompiler,thestandardlibrary,andthefoundation,followedbytheCocoadesignpatterns–theonesatthecoreofmanycocoalibraries–tofollowupwiththecreational,structural,andbehavioralpatternsasdefinedbytheGoF.You'llgetacquaintedwithapplicationarchitecture,aswellasthemostpopulararchitecturaldesignpatterns,suchasMVCandMVVM,andlearntousetheminthecontextofSwift.Inaddition,you’llwalkthroughdependencyinjectionandfunctionalreactiveprogramming.Specialemphasiswillbegiventotechniquestohandleconcurrency,includingcallbacks,futuresandpromises,andreactiveprogramming.Thesetechniqueswillhelpyouadoptatest-drivenapproachtoyourworkflowinordertouseSwiftPackageManagerandintegratetheframeworkintotheoriginalcodebase,alongwithUnitandUItesting.Bytheendofthebook,you'llbeabletobuildapplicationsthatarescalable,faster,andeasiertomaintain.
最新章節(jié)
- Leave a review - let other readers know what you think
- Other Books You May Enjoy
- Summary
- No is temporary yes is forever
- Issues Pull Requests and more
- The CODE_OF_CONDUCT.md file
品牌:中圖公司
上架時(shí)間:2021-07-02 12:38:18
出版社:Packt Publishing
本書(shū)數(shù)字版權(quán)由中圖公司提供,并由其授權(quán)上海閱文信息技術(shù)有限公司制作發(fā)行
- Leave a review - let other readers know what you think 更新時(shí)間:2021-07-02 14:46:05
- Other Books You May Enjoy
- Summary
- No is temporary yes is forever
- Issues Pull Requests and more
- The CODE_OF_CONDUCT.md file
- The LICENSE.md file
- The README.md file
- Becoming a maintainer tips and tricks
- Using Travis to upload on tags
- Fastlane beta
- Your first lane
- Getting started with fastlane
- Using fastlane for automated delivery
- Some final words on Travis and GitLab
- Adding a linter SwiftLint
- Building and testing
- GitLab.com
- Configuring pure Swift projects
- Configuring more complex build scenarios
- Configuring simple projects
- Travis CI
- Continuous integration
- Publishing to GitHub Pages
- Generating HTML docs
- Structural annotations
- Additional callouts
- Rich content
- The anatomy of a documentation block
- The Markdown language
- Documenting Swift
- Going Out in the Open (Source)
- Summary
- Run only the test with the cursor
- Testing Async code
- Testing singletons
- Tips and tricks
- Writing UI tests in code
- Recording a UI test
- The importance of UI testing
- UI testing with Xcode
- Mock test double: asserting collaboration
- Spy test double: verifying collaboration
- Stub test double: a predefined collaborator
- Fake test double: a simplified collaborator
- Dummy test double: when we don't need to test the collaborator
- Testing in Isolation
- Advanced testing with mocks spy and others
- Assertions
- Learnings from our first TDD code
- Adding operations
- Refactoring the tests
- More tests
- The first test
- A simple RPN Calculator app
- What is an reverse polish notation calculator?
- TDD
- Testing an RPN Calculator app
- Unit testing using XCTest
- Testing Your Code with Unit and UI Tests
- Summary
- Extracting a framework
- Refactoring your code
- Extracting and sharing a framework
- Using SPM with Xcode
- Adding third-party dependencies
- Adding more targets
- Adding features to the library
- Creating a library package
- Modularize Your Apps with Swift Package Manager
- Summary
- Asynchronous networking – an example
- Schedulers
- Transformations
- Observables and observers
- RxSwift
- Reactive programming
- Google Promises
- PromiseKit
- Futures and promises frameworks for Swift
- Futures and promises under the hood
- Futures and promises
- The issue with callbacks
- Closures and memory management
- Callbacks and closures
- Futures Promises and Reactive Programming
- Summary
- Automatic Storyboard Injection
- Swinject
- The Typhoon framework
- Why you should use a DI Container
- Using a Dependency Injection Container
- Service Locator
- Bastard Injection
- Stable and volatile dependencies
- Control Freak
- DI anti-patterns
- Composition Root
- Bind the dependencies
- Ambient Context
- Method Injection
- Property Injection
- Constructor Injection
- Four ways to use Dependency Injection (with examples)
- Dependency Injection by example
- Testability
- Separation of concerns
- Why DI is useful
- Definition
- What is Dependency Injection?
- Dependency Injection a primer
- Implementing Dependency Injection
- Summary
- Using Observables with ViewModels
- Two-way binding on UITextField
- Implementing the Binding protocol
- Implementing the Observable class
- MVVM and data binding
- Drawbacks
- Improved reusability
- Enhanced testing
- Benefits and drawbacks of MVVM
- View
- ViewModel
- Model
- Refactoring MVC into MVVM
- Basics of the MVVM pattern
- Model-View-ViewModel in Swift
- Summary
- The Controller
- Model controllers
- View controllers
- Refactoring controllers
- Using model controllers
- The model layer
- Using view controller composition
- Removing child view controllers
- Adding child view controllers
- Composition and child view controllers
- Early view access in properties
- Early view access in initializer
- Early view instantiation
- UIViewController anti-patterns
- View controller life cycles
- UIViewController
- The controller layer
- The view layer
- The model layer
- A pure MVC example
- The theory behind the MVC pattern
- A refresher on MVC
- Using the Model-View-Controller Pattern
- Summary
- Summing up with the template method pattern
- A recommendation engine
- Template pattern with protocol-oriented programming
- The type erasure pattern – a summary
- The public wrapper
- The private box
- The abstract base class
- Boxing-based type erasure
- Closure-based type erasure
- Elements of type erasure
- The type erasure pattern
- Protocol-oriented programming
- A word on Self requirement
- Associated types
- Conditional conformance
- Generic everything
- Generic functions
- Generics-based programming
- Generics conditional conformance and associated types
- Protocols are full-fledged types
- Mutation and value types
- Adding requirements to protocols
- A refresher on protocols
- Getting started with protocol-oriented programming
- Swift-Oriented Patterns
- Summary
- Using the strategy pattern
- The ice-cream shop example
- Components of the strategy pattern
- The strategy pattern
- Using visitors
- Contributors thank you notes and the visitor pattern
- Visitable and visitor protocols
- The visitor pattern
- Using the memento pattern
- Implementing the memento pattern
- Components of the memento pattern
- The memento pattern
- Using observation
- Observation using pure Swift
- Using KVO with Swift
- Using KVO with existing Objective-C APIs
- Using Key-Value Observing
- Using NotificationCenter
- Event-based programming
- The observer pattern
- Using state machines
- Refactoring the context object
- Implementing all states through structs and moving the logic
- Extracting a single protocol
- Refactoring for maintainability
- Using enums
- The card reader
- The state pattern
- Behavioral Patterns
- Summary
- A shopping list using the flyweight pattern
- The flyweight pattern
- Using the bridge pattern
- Anatomy of the bridge pattern
- The bridge pattern
- Using the composite pattern to represent tests and suites
- The composite pattern
- Using the proxy pattern to implement request/response logging
- Building a network cache with the facade pattern
- The facade pattern
- The facade pattern and proxy pattern
- Decoration in a nutshell
- Going further with decorator
- Using a decorator
- The decorator pattern
- The adapter pattern in a nutshell
- Leveraging extensions
- Using classes as adapters
- The classes to adapt
- The basics
- Using the adapter pattern
- The adapter pattern
- Structural Patterns
- Summary
- The prototype pattern in a nutshell
- Implementing NSMutableCopying automatically
- Implementing mutable objects
- Implementing NSCopying automatically
- Going further – NSCopying with Sourcery
- Leveraging the prototype pattern
- The prototype pattern
- The builder pattern in a nutshell
- Going further: metaprogramming with Sourcery
- Model building
- The builder pattern
- Checklist for using the factory method pattern
- Protocol extensions
- Inheritance
- Default implementations
- Going further with factory methods
- Using the abstract factory pattern
- The abstract factory pattern
- Wrapping up
- Advanced usage of the factory method pattern
- Using the factory method pattern
- The factory method pattern
- Singletons in a nutshell
- Using singletons
- The singleton pattern
- Creational Patterns
- Summary
- Lazy initialization
- Implementing delegation
- Using delegation
- Delegation
- Cocoa design patterns in Swift
- Generic classes in Objective-C
- Using typed NSArray* in Objective-C
- Lightweight generics in Objective-C
- Renaming methods and enum cases
- Renaming classes
- Setting Swift names from Objective-C
- Setting Objective-C names from Swift
- Naming renaming and refining Objective-C for Swift
- Using nullable nonnull _Nullable and _Nonnull
- Using NS_ASSUME_NON_NULL_BEGIN and NS_ASSSUME_NON_NULL_END
- Nullability and optionals in Objective-C
- Exposing Swift to Objective-C
- Importing Objective-C in Swift
- Setting up your project
- Working with Objective-C in a Mixed Code Base
- Summary
- Sending requests with Encodable
- Parsing responses with Decodable
- Making your first call with URLSession
- HTTP with URLSession
- Using groups
- Example of a counting semaphore
- Organizing execution with groups and semaphores
- Thread safety through serial queues
- Synchronization with Dispatch
- Tasks and queues
- Mastering concurrency with Dispatch
- Iterating mapping and reducing
- Initialization and mutability
- Dictionaries
- Iterating mapping and reducing
- Mutability and operations
- Arrays
- Container types
- Throwing and catching errors
- Range as Sequence
- Working with ranges
- Swift basic types
- Diving into Foundation and the Standard Library
- Summary
- Dangling references
- Using unowned
- Using weak
- Fixing the leak
- A simple leak
- Leaking with cycles
- Leaks cycles and dangling references
- Using the memory graph hierarchy tool
- Configuring your project
- Memory debugging
- Unowned references
- Weak references
- Strong references
- Value types
- ARC – what is that?
- Dangling pointers
- Memory leaks
- Using and misusing manual reference counting
- Copying
- Assign
- Release
- Retain
- The semantics of reference counting
- A brief history of reference counting
- Understanding ARC and Memory Management
- Summary
- Generics protocols and associated types
- Generic types
- Generic functions
- Generics
- Type aliases
- Using tuples in functions
- Destructuring tuples
- Declaring tuples
- Tuples
- Tuples type aliases and generics
- Default implementations
- Protocol extensions
- Conformance in an extension
- Conformance at declaration
- Conforming to a protocol
- Declaring a protocol
- Protocols
- Using weak and unowned
- Using closures as callbacks
- Currying
- Closures functions and currying
- Switching the state of light
- Raw type enums
- Generic enums
- Associating values
- Adding methods
- Simple enums
- Enums
- Struct
- Classes
- Classes and structs
- Refreshing the Basics
- Reviews
- Get in touch
- Conventions used
- Download the color images
- Download the example code files
- To get the most out of this book
- What this book covers
- Who this book is for
- Preface
- Packt is searching for authors like you
- About the reviewers
- About the authors
- Contributors
- Packt.com
- Why subscribe?
- About Packt
- Hands-On Design Patterns with Swift
- Copyright and Credits
- Title Page
- coverpage
- coverpage
- Title Page
- Copyright and Credits
- Hands-On Design Patterns with Swift
- About Packt
- Why subscribe?
- Packt.com
- Contributors
- About the authors
- About the reviewers
- Packt is searching for authors like you
- Preface
- Who this book is for
- What this book covers
- To get the most out of this book
- Download the example code files
- Download the color images
- Conventions used
- Get in touch
- Reviews
- Refreshing the Basics
- Classes and structs
- Classes
- Struct
- Enums
- Simple enums
- Adding methods
- Associating values
- Generic enums
- Raw type enums
- Switching the state of light
- Closures functions and currying
- Currying
- Using closures as callbacks
- Using weak and unowned
- Protocols
- Declaring a protocol
- Conforming to a protocol
- Conformance at declaration
- Conformance in an extension
- Protocol extensions
- Default implementations
- Tuples type aliases and generics
- Tuples
- Declaring tuples
- Destructuring tuples
- Using tuples in functions
- Type aliases
- Generics
- Generic functions
- Generic types
- Generics protocols and associated types
- Summary
- Understanding ARC and Memory Management
- A brief history of reference counting
- The semantics of reference counting
- Retain
- Release
- Assign
- Copying
- Using and misusing manual reference counting
- Memory leaks
- Dangling pointers
- ARC – what is that?
- Value types
- Strong references
- Weak references
- Unowned references
- Memory debugging
- Configuring your project
- Using the memory graph hierarchy tool
- Leaks cycles and dangling references
- Leaking with cycles
- A simple leak
- Fixing the leak
- Using weak
- Using unowned
- Dangling references
- Summary
- Diving into Foundation and the Standard Library
- Swift basic types
- Working with ranges
- Range as Sequence
- Throwing and catching errors
- Container types
- Arrays
- Mutability and operations
- Iterating mapping and reducing
- Dictionaries
- Initialization and mutability
- Iterating mapping and reducing
- Mastering concurrency with Dispatch
- Tasks and queues
- Synchronization with Dispatch
- Thread safety through serial queues
- Organizing execution with groups and semaphores
- Example of a counting semaphore
- Using groups
- HTTP with URLSession
- Making your first call with URLSession
- Parsing responses with Decodable
- Sending requests with Encodable
- Summary
- Working with Objective-C in a Mixed Code Base
- Setting up your project
- Importing Objective-C in Swift
- Exposing Swift to Objective-C
- Nullability and optionals in Objective-C
- Using NS_ASSUME_NON_NULL_BEGIN and NS_ASSSUME_NON_NULL_END
- Using nullable nonnull _Nullable and _Nonnull
- Naming renaming and refining Objective-C for Swift
- Setting Objective-C names from Swift
- Setting Swift names from Objective-C
- Renaming classes
- Renaming methods and enum cases
- Lightweight generics in Objective-C
- Using typed NSArray* in Objective-C
- Generic classes in Objective-C
- Cocoa design patterns in Swift
- Delegation
- Using delegation
- Implementing delegation
- Lazy initialization
- Summary
- Creational Patterns
- The singleton pattern
- Using singletons
- Singletons in a nutshell
- The factory method pattern
- Using the factory method pattern
- Advanced usage of the factory method pattern
- Wrapping up
- The abstract factory pattern
- Using the abstract factory pattern
- Going further with factory methods
- Default implementations
- Inheritance
- Protocol extensions
- Checklist for using the factory method pattern
- The builder pattern
- Model building
- Going further: metaprogramming with Sourcery
- The builder pattern in a nutshell
- The prototype pattern
- Leveraging the prototype pattern
- Going further – NSCopying with Sourcery
- Implementing NSCopying automatically
- Implementing mutable objects
- Implementing NSMutableCopying automatically
- The prototype pattern in a nutshell
- Summary
- Structural Patterns
- The adapter pattern
- Using the adapter pattern
- The basics
- The classes to adapt
- Using classes as adapters
- Leveraging extensions
- The adapter pattern in a nutshell
- The decorator pattern
- Using a decorator
- Going further with decorator
- Decoration in a nutshell
- The facade pattern and proxy pattern
- The facade pattern
- Building a network cache with the facade pattern
- Using the proxy pattern to implement request/response logging
- The composite pattern
- Using the composite pattern to represent tests and suites
- The bridge pattern
- Anatomy of the bridge pattern
- Using the bridge pattern
- The flyweight pattern
- A shopping list using the flyweight pattern
- Summary
- Behavioral Patterns
- The state pattern
- The card reader
- Using enums
- Refactoring for maintainability
- Extracting a single protocol
- Implementing all states through structs and moving the logic
- Refactoring the context object
- Using state machines
- The observer pattern
- Event-based programming
- Using NotificationCenter
- Using Key-Value Observing
- Using KVO with existing Objective-C APIs
- Using KVO with Swift
- Observation using pure Swift
- Using observation
- The memento pattern
- Components of the memento pattern
- Implementing the memento pattern
- Using the memento pattern
- The visitor pattern
- Visitable and visitor protocols
- Contributors thank you notes and the visitor pattern
- Using visitors
- The strategy pattern
- Components of the strategy pattern
- The ice-cream shop example
- Using the strategy pattern
- Summary
- Swift-Oriented Patterns
- Getting started with protocol-oriented programming
- A refresher on protocols
- Adding requirements to protocols
- Mutation and value types
- Protocols are full-fledged types
- Generics conditional conformance and associated types
- Generics-based programming
- Generic functions
- Generic everything
- Conditional conformance
- Associated types
- A word on Self requirement
- Protocol-oriented programming
- The type erasure pattern
- Elements of type erasure
- Closure-based type erasure
- Boxing-based type erasure
- The abstract base class
- The private box
- The public wrapper
- The type erasure pattern – a summary
- Template pattern with protocol-oriented programming
- A recommendation engine
- Summing up with the template method pattern
- Summary
- Using the Model-View-Controller Pattern
- A refresher on MVC
- The theory behind the MVC pattern
- A pure MVC example
- The model layer
- The view layer
- The controller layer
- UIViewController
- View controller life cycles
- UIViewController anti-patterns
- Early view instantiation
- Early view access in initializer
- Early view access in properties
- Composition and child view controllers
- Adding child view controllers
- Removing child view controllers
- Using view controller composition
- The model layer
- Using model controllers
- Refactoring controllers
- View controllers
- Model controllers
- The Controller
- Summary
- Model-View-ViewModel in Swift
- Basics of the MVVM pattern
- Refactoring MVC into MVVM
- Model
- ViewModel
- View
- Benefits and drawbacks of MVVM
- Enhanced testing
- Improved reusability
- Drawbacks
- MVVM and data binding
- Implementing the Observable class
- Implementing the Binding protocol
- Two-way binding on UITextField
- Using Observables with ViewModels
- Summary
- Implementing Dependency Injection
- Dependency Injection a primer
- What is Dependency Injection?
- Definition
- Why DI is useful
- Separation of concerns
- Testability
- Dependency Injection by example
- Four ways to use Dependency Injection (with examples)
- Constructor Injection
- Property Injection
- Method Injection
- Ambient Context
- Bind the dependencies
- Composition Root
- DI anti-patterns
- Control Freak
- Stable and volatile dependencies
- Bastard Injection
- Service Locator
- Using a Dependency Injection Container
- Why you should use a DI Container
- The Typhoon framework
- Swinject
- Automatic Storyboard Injection
- Summary
- Futures Promises and Reactive Programming
- Callbacks and closures
- Closures and memory management
- The issue with callbacks
- Futures and promises
- Futures and promises under the hood
- Futures and promises frameworks for Swift
- PromiseKit
- Google Promises
- Reactive programming
- RxSwift
- Observables and observers
- Transformations
- Schedulers
- Asynchronous networking – an example
- Summary
- Modularize Your Apps with Swift Package Manager
- Creating a library package
- Adding features to the library
- Adding more targets
- Adding third-party dependencies
- Using SPM with Xcode
- Extracting and sharing a framework
- Refactoring your code
- Extracting a framework
- Summary
- Testing Your Code with Unit and UI Tests
- Unit testing using XCTest
- Testing an RPN Calculator app
- TDD
- What is an reverse polish notation calculator?
- A simple RPN Calculator app
- The first test
- More tests
- Refactoring the tests
- Adding operations
- Learnings from our first TDD code
- Assertions
- Advanced testing with mocks spy and others
- Testing in Isolation
- Dummy test double: when we don't need to test the collaborator
- Fake test double: a simplified collaborator
- Stub test double: a predefined collaborator
- Spy test double: verifying collaboration
- Mock test double: asserting collaboration
- UI testing with Xcode
- The importance of UI testing
- Recording a UI test
- Writing UI tests in code
- Tips and tricks
- Testing singletons
- Testing Async code
- Run only the test with the cursor
- Summary
- Going Out in the Open (Source)
- Documenting Swift
- The Markdown language
- The anatomy of a documentation block
- Rich content
- Additional callouts
- Structural annotations
- Generating HTML docs
- Publishing to GitHub Pages
- Continuous integration
- Travis CI
- Configuring simple projects
- Configuring more complex build scenarios
- Configuring pure Swift projects
- GitLab.com
- Building and testing
- Adding a linter SwiftLint
- Some final words on Travis and GitLab
- Using fastlane for automated delivery
- Getting started with fastlane
- Your first lane
- Fastlane beta
- Using Travis to upload on tags
- Becoming a maintainer tips and tricks
- The README.md file
- The LICENSE.md file
- The CODE_OF_CONDUCT.md file
- Issues Pull Requests and more
- No is temporary yes is forever
- Summary
- Other Books You May Enjoy
- Leave a review - let other readers know what you think 更新時(shí)間:2021-07-02 14:46:05