没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Design Patterns
in Modern C++20
Reusable Approaches for Object-
Oriented Software Design
—
Second Edition
—
Dmitri Nesteruk
Design Patterns in
Modern C++20
Reusable Approaches
forObject-Oriented
Software Design
Second Edition
DmitriNesteruk
Design Patterns in Modern C++20: Reusable Approaches for
Object- Oriented Software Design
ISBN-13 (pbk): 978-1-4842-7294-7 ISBN-13 (electronic): 978-1-4842-7295-4
https://doi.org/10.1007/978-1-4842-7295-4
Copyright © 2022 by Dmitri Nesteruk
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by Clark van der Beken on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 NewYork Plaza, NewYork, NY
10004, U.S.A.Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com,
or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance
Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for
reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions
and licenses are also available for most titles. For more information, reference our Print and eBook
Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on GitHub via the book’s product page, located at www.apress.com/9781484272947. For
more detailed information, please visit http://www.apress.com/source- code.
Printed on acid-free paper
DmitriNesteruk
St. Petersburg, Russia
iii
About the Author ���������������������������������������������������������������������������������xi
About the Technical Reviewers ���������������������������������������������������������xiii
Table of Contents
Chapter 1: Introduction�������������������������������������������������������������������������1
Who This Book Is For ���������������������������������������������������������������������������������������������2
On Code Examples ������������������������������������������������������������������������������������������������3
On Developer Tools ������������������������������������������������������������������������������������������������4
Preface to the Second Edition ������������������������������������������������������������������������������� 5
Important Concepts �����������������������������������������������������������������������������������������������6
Curiously Recurring Template Pattern ������������������������������������������������������������� 6
Mixin Inheritance ��������������������������������������������������������������������������������������������� 8
Old-Fashioned Static Polymorphism ���������������������������������������������������������������8
Static Polymorphism with Concepts ��������������������������������������������������������������11
Properties ������������������������������������������������������������������������������������������������������12
The SOLID Design Principles ������������������������������������������������������������������������������� 14
Single Responsibility Principle ����������������������������������������������������������������������15
Open-Closed Principle �����������������������������������������������������������������������������������17
Liskov Substitution Principle �������������������������������������������������������������������������26
Interface Segregation Principle ���������������������������������������������������������������������29
Dependency Inversion Principle ��������������������������������������������������������������������33
iv
Part I: Creational Patterns ���������������������������������������������������������41
Chapter 2: Builder �������������������������������������������������������������������������������43
Scenario �������������������������������������������������������������������������������������������������������������� 43
Simple Builder �����������������������������������������������������������������������������������������������������45
Fluent Builder ������������������������������������������������������������������������������������������������������46
Communicating Intent �����������������������������������������������������������������������������������������47
Groovy-Style Builder �������������������������������������������������������������������������������������������49
Composite Builder �����������������������������������������������������������������������������������������������52
Builder Parameter �����������������������������������������������������������������������������������������������57
Builder Inheritance ����������������������������������������������������������������������������������������������59
Summary�������������������������������������������������������������������������������������������������������������65
Chapter 3: Factories ���������������������������������������������������������������������������67
Scenario �������������������������������������������������������������������������������������������������������������� 67
Factory Method ��������������������������������������������������������������������������������������������������� 70
Factory ���������������������������������������������������������������������������������������������������������������� 72
Factory Methods and Polymorphism ������������������������������������������������������������������75
Nested Factory ����������������������������������������������������������������������������������������������������76
Abstract Factory ��������������������������������������������������������������������������������������������������78
Functional Factory ����������������������������������������������������������������������������������������������82
Object Tracking ���������������������������������������������������������������������������������������������������83
Summary�������������������������������������������������������������������������������������������������������������85
Chapter 4: Prototype ���������������������������������������������������������������������������87
Object Construction ���������������������������������������������������������������������������������������������87
Ordinary Duplication �������������������������������������������������������������������������������������������88
Duplication via Copy Construction ����������������������������������������������������������������������89
Virtual Constructor ����������������������������������������������������������������������������������������������92
Table of ConTenTs
剩余390页未读,继续阅读
资源评论
- jordan222024-03-11十分好的资源,谢谢分享,找了好久才找到 #完美解决问题 #内容详尽
CyberLogix
- 粉丝: 397
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功