万本电子书0元读

万本电子书0元读

顶部广告

Swift 3 Object-Oriented Programming - Second Edition电子书

售       价:¥

0人正在读 | 0人评论 9.8

作       者:Gastón C. Hillar

出  版  社:Packt Publishing

出版时间:2017-02-01

字       数:49.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Implement object-oriented programming paradigms with Swift 3.0 and mix them with modern functional programming techniques to build powerful real-world applications About This Book Leverage the most efficient object-oriented design patterns in your Swift applications Write robust, safer, and better code using the blueprints that generate objects Build a platform with object-oriented code using real-world elements and represent them in your apps Who This Book Is For This book is for iOS and macOS developers who want to get a detailed practical understanding of object-oriented programming with the latest version of Swift: 3.0. What You Will Learn Write high-quality and easy-to-maintain reusable object-oriented code to build applications for iOS, macOS, and Linux Work with encapsulation, abstraction, and polymorphism using Swift 3.0 Work with classes, instances, properties, and methods in Swift 3.0 Take advantage of inheritance, specialization, and the possibility to overload or override members Implement encapsulation, abstraction, and polymorphism Explore functional programming techniques mixed with object-oriented code in Swift 3.0 Understand the differences between Swift 3.0, previous Swift versions, and Objective-C code In Detail Swift has quickly become one of the most-liked languages and developers’ de-facto choice when building applications that target iOS and macOS. In the new version, the Swift team wants to take its adoption to the next level by making it available for new platforms and audiences. This book introduces the object-oriented paradigm and its implementation in the Swift 3 programming language to help you understand how real-world objects can become part of fundamental reusable elements in the code. This book is developed with XCode 8.x and covers all the enhancements included in Swift 3.0. In addition, we teach you to run most of the examples with the Swift REPL available on macOS and Linux, and with a Web-based Swift sandbox developed by IBM capable of running on any web browser, including Windows and mobile devices. You will organize data in blueprints that generate instances. You’ll work with examples so you understand how to encapsulate and hide data by working with properties and access control. Then, you’ll get to grips with complex scenarios where you use instances that belong to more than one blueprint. You’ll discover the power of contract programming and parametric polymorphism. You’ll combine generic code with inheritance and multiple inheritance. Later, you’ll see how to combine functional programming with object-oriented programming and find out how to refactor your existing code for easy maintenance. Style and approach This simple guide is packed with practical examples of solutions to common problems. Each chapter includes exercises and the possibility for you to test your progress by answering a quiz
目录展开

Swift 3 ObjectOriented Programming - Second Edition

Swift 3 ObjectOriented Programming - Second Edition

Credits

About the Author

Acknowledgement

About the Reviewer

www.PacktPub.com

Why subscribe?

Customer Feedback

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Objects from the Real World to the Playground

Installing the required software on Mac OS

Installing the required software on Ubuntu Linux

Working with Swift 3 on the web

Capturing objects from the real world

Generating classes to create objects

Recognizing variables and constants to create properties

Recognizing actions to create methods

Organizing classes with UML diagrams

Working with API objects in the Xcode Playground

Exercises

Test your knowledge

Summary

2. Structures, Classes, and Instances

Understanding structures, classes, and instances

Understanding initialization and its customization

Understanding deinitialization and its customization

Understanding automatic reference counting

Declaring classes

Customizing initialization

Customizing deinitialization

Creating the instances of classes

Exercises

Test your knowledge

Summary

3. Encapsulation of Data with Properties

Understanding elements that compose a class

Declaring stored properties

Generating computed properties with setters and getters

Combining setters, getters, and a related property

Understanding property observers

Transforming values with setters and getters

Creating values shared by all the instances of a class with type properties

Creating mutable classes

Building immutable classes

Exercises

Test your knowledge

Summary

4. Inheritance, Abstraction, and Specialization

Creating class hierarchies to abstract and specialize behavior

Understanding inheritance

Declaring classes that inherit from another class

Overriding and overloading methods

Overriding properties

Controlling whether subclasses can or cannot override members

Working with typecasting and polymorphism

Taking advantage of operator overloading

Declaring compound assignment operator functions

Declaring unary operator functions

Declaring operator functions for specific subclasses

Exercises

Test your knowledge

Summary

5. Contract Programming with Protocols

Understanding how protocols work in combination with classes

Declaring protocols

Declaring classes that adopt protocols

Taking advantage of the multiple inheritance of protocols

Combining inheritance and protocols

Working with methods that receive protocols as arguments

Downcasting with protocols and classes

Treating instances of a protocol type as a different subclass

Specifying requirements for properties

Specifying requirements for methods

Combining class inheritance with protocol inheritance

Exercises

Test your knowledge

Summary

6. Maximization of Code Reuse with Generic Code

Understanding parametric polymorphism and generic code

Declaring a protocol to be used as a constraint

Declaring a class that conforms to multiple protocols

Declaring subclasses that inherit the conformance to protocols

Declaring a class that works with a constrained generic type

Using a generic class for multiple types

Combining initializer requirements in protocols with generic types

Declaring associated types in protocols

Creating shortcuts with subscripts

Declaring a class that works with two constrained generic types

Using a generic class with two generic type parameters

Inheriting and adding associated types in protocols

Generalizing existing classes with generics

Extending base types to conform to custom protocols

Test your knowledge

Exercises

Summary

7. Object-Oriented and Functional Programming

Refactoring code to take advantage of object-oriented programming

Understanding functions as first-class citizens

Working with function types within classes

Creating a functional version of array filtering

Writing equivalent closures with simplified code

Creating a data repository with generics and protocols

Filtering arrays with complex conditions

Using map to transform values

Combining map with reduce

Chaining filter, map, and reduce

Solving algorithms with reduce

Exercises

Test your knowledge

Summary

8. Extending and Building Object-Oriented Code

Putting together all the pieces of the object-oriented puzzle

Adding methods with extensions

Adding computed properties to a base type with extensions

Declaring new convenience initializers with extensions

Defining subscripts with extensions

Working with object-oriented code in iOS apps

Adding an object-oriented data repository to a project

Interacting with an object-oriented data repository through Picker View

Exercises

Test your knowledge

Summary

9. Exercise Answers

Chapter 1, Objects from the Real World to Playground

Chapter 2, Structures, Classes, and Instances

Chapter 3, Encapsulation of Data with Properties

Chapter 4, Inheritance, Abstraction, and Specialization

Chapter 5, Contract Programming with Protocols

Chapter 6, Maximization of Code Reuse with Generic Code

Chapter 7, Object-Oriented Programming and Functional Programming

Chapter 8, Protection and Organization of Code

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部