没有合适的资源?快使用搜索试试~ 我知道了~
首页从编程到架构:实践C++设计全览
从编程到架构:实践C++设计全览
需积分: 10 25 下载量 33 浏览量
更新于2024-07-19
1
收藏 3.1MB PDF 举报
"《Practical C++ Design:从编程到架构》是一本由Adam B. Singer撰写的专业书籍,于2018年由Apress出版社发行。该书旨在填补市场上关于C++设计与架构实践的空白,不同于其他专注于语言基础、最佳实践或单一主题深入的书籍,它假设读者已经具备了基础的编程知识,特别是对C++语言、数据结构、算法、面向对象分析与设计以及设计模式等领域的理解。 作者在职业生涯中作为导师,发现大部分书籍往往只关注设计或实现的某个方面,而缺乏整体视角。因此,本书的独特之处在于,它通过一个具体的案例研究,将理论设计知识与实际应用相结合,帮助读者巩固并提升他们的设计技能。书中内容涵盖了如何从编程实践出发,逐步构建和优化系统架构,强调的是将概念转化为实际项目的经验分享。 《Practical C++ Design》并不追求深度的专业细分,而是提供一种实用的方法论,适合那些希望在已有基础知识基础上,通过实践深化对C++设计的理解和实践能力的开发者。读者可以在阅读过程中,学习如何处理复杂的设计问题,如何权衡不同设计决策的影响,以及如何在实际开发环境中迭代和优化设计。 该书不仅包含了丰富的代码示例和详细解释,还可能包含对于设计模式的实战应用,以及如何遵循软件工程的最佳实践,如模块化、可扩展性、性能优化等方面。此外,由于版权保护,读者需遵守版权规定,不得未经许可进行任何形式的复制或传播。 《Practical C++ Design》是一本实用且富有实践价值的书籍,它不仅是一本技术指南,更是一部帮助程序员跨越编程技巧向架构设计进阶的桥梁。”
资源详情
资源推荐
xviii
advanced features such as template metaprogramming. This intentional omission is not
meant to be a commentary on the importance of these language features or a critique
of their usefulness as design constructs. In fact, they are essential for specific domains,
particularly where efficiency and genericity dominate (e.g., the standard library, boost).
Rather, the lack of usage of any particular feature reflects my pragmatic approach toward
design: the appropriate language subset for a particular project should reflect only those
features required to express clearly and efficiently the developer’s intent. If your favorite
language feature is missing, it may be because I felt that its use in this context was less
clear than my chosen alternative. After all, we write programs in higher level languages
to be read and understood by other programmers. The task of designing, implementing,
maintaining, and extending code in a production environment is quite difficult in its own
right. Displays of unnecessary cleverness are generally neither warranted nor appreciated.
GUI Framework and Platforms
While graphical user interfaces (GUI) are not the primary focus of this book, our
program will eventually acquire one; hence, selecting a particular GUI framework
was necessary. I selected Qt for this purpose and have successfully tested the code
with versions 4 and 5. As with C++, Qt is widely deployed, cross platform, and free. As
with C++, again, selfishly, I chose Qt because I am experienced using desktop Qt and
personally enjoy using it. A big advantage of using Qt is that it makes nearly all of the
source code for the project platform-independent. Where platform independence
was not achievable, I encapsulated the platform-dependent code behind an abstract
interface. We’ll explore this design pattern, in depth, in Chapter 7.
In general, I always strive to write standards-conforming, platform-independent
code. The source code in this book should compile with any C++14-compliant compiler
and on any platform where Qt is supported. That said, every platform and every
compiler somehow manage to have their own unique idiosyncrasies, and testing every
possible combination of platform and compiler is impossible. I personally have tested
the source code for this book on Windows 7, Windows 10, and Linux using gcc (the
mingw variant on Windows). I do not own an Apple computer, so I have not tested the
source code on Mac OS X. However, the code should work as is or require only very
minor changes to get it to compile there if that is your platform of choice. Any known
platform-specific code is compartmentalized and encapsulated; extension to other
platforms should be straightforward.
PrefaCe
https://sci101web.wordpress.com/
xix
The Case Study
To this point, I have not yet mentioned the subject of the case study central to this book.
In my opinion, an ideal problem would be one that is not too daunting and yet not so
trivial that it needs no design. Additionally, the domain of the problem should be readily
understandable to any reader. For this reason, I have chosen to implement a stack-
based, Reverse Polish Notation (RPN) calculator that I named pdCalc, short for Practical
Design Calculator. Functionally, pdCalc was inspired by the HP48S calculator, an old
favorite calculator of mine from high school and college (that still sits on my desk today).
I cannot imagine any reader being unfamiliar with the basic operations of a calculator,
and making the calculator use RPN adds a little twist that I hope will make the project
interesting.
The Source Code
The source code (and supporting unit tests) for pdCalc is available, in its entirety, from
Apress’s GitHub repository. The easiest way to find the repository is via the Download
Source Code button located at www.apress.com/9781484230565. Appendix A describes,
in detail, how to download and build the source code. Although most readers will likely
prefer to download the source using a git client, the entire source code is also available
from GitHub as a single zip file.
The source code itself is licensed under the GNU Public License (GPL) version 3.
I hope you find the source code useful for learning about design and implementation.
Beyond its use as an educational aide for this book, you are, of course, free to do
anything you like with the source code within the rights granted to you by the GPL.
This book uses two distinct fonts, the standard font you are reading now and a fixed
width font used for source code. The fixed width font is demonstrated in the following list
of standard template library containers: vector, list, and map. When clear from context,
to save space, I often omit namespaces and template arguments. When the discussion
requires a block of source code, it will be offset from the rest of the text as follows:
class ExampleClass
{
public:
// your implementation here
};
PrefaCe
https://sci101web.wordpress.com/
xx
In general, I tried to reproduce the code in the text identically to the code in the
repository. However, in some cases, parts of the source were deliberately omitted in the
text either for brevity or clarity. I have tried to note instances where the differences are
significant. Where the two differ, assume the code in the repository is the more correct
and complete version.
Contacting the Author
I suspect that as you read this book and explore the source code, you will invariably
have questions. Please feel free to contact me with questions about the content of
the book, questions about the source code, errors, or improvements to my design or
implementation. I can be contacted at PracticalDesignBook@gmail.com. I will make
my best effort to reply to all reasonable email related to pdCalc, but without knowing
the volume of email I’ll receive, I can make no ironclad guarantee that I will be able
to respond to every request. If I find that there is a significant interest in a community
discussion of pdCalc and its design, I’ll investigate establishing a web page to
accompany this book. Again, I can offer no promises.
Parting Advice
Finally, in addition to learning something, I hope that you, the reader, have fun with
the subject. My personal suggestion is to try to think about the design decisions
yourself before reading my solutions. If you are truly industrious, you may even want
to implement your own calculator using a completely different, possibly better design.
After all, as I said before, design is ultimately about both experience and taste, and your
experience and taste may differ significantly from mine.
PrefaCe
https://sci101web.wordpress.com/
1
© Adam B. Singer 2017
A. B. Singer, Practical C++ Design, DOI10.1007/978-1-4842-3057-2_1
CHAPTER 1
Defining theCase Study
1.1 A Brief Introduction
This book is about programming design. However, unlike many books on this topic, this
book teaches design by exploration rather than design by instruction. Typically, most
authors writing about some aspect of design establish principles they wish to convey, lay
out these principles in the abstract, and then proceed to give examples supporting the
current points. This is not such a book. Rather, this book defines a practical problem to
be solved, and proceeds to examine its solution in detail. That is, instead of deciding on a
topic and creating trivial examples to support its teaching, I have defined a hard problem
and then let the solution of this problem dictate what topics should be discussed.
Interestingly enough, the above approach is exactly how I would tell someone not
to learn a subject. I always stress that people should learn broad fundamentals first
and subsequently apply these principles to solving problems. However, this is not a
book meant to teach the principles of design. Rather, this is a book meant for someone
who already knows the fundamentals but wishes to deepen his knowledge of practice.
This is a book meant to teach someone the craft of designing and implementing a
realistic, albeit small, program from start to finish. This process involves more than
knowing elements of design. It involves understanding when and how to use what
you know, understanding how to decide between seemingly equivalent approaches,
and understanding the long-term implications of various decisions. This book is
not comprehensive in its coverage of data structures, algorithms, design patterns, or
C++ best practices; volumes of books exist to cover these topics. This is a book about
learning how to apply this knowledge to write code that is organized, cohesive, sensible,
purposeful, and pragmatic. In other words, this book is about learning to write code that
both gets the job done now (development) and allows others to continue to get the job
done in the future (maintenance). This, I have termed practical design.
https://sci101web.wordpress.com/
2
In order to explore practical design, we need a case study. Ideally, the case study
problem should be
• Large enough to be more than trivial,
• Small enough to be tractable,
• Familiar enough to not require domain specic expertise, and
• Interesting enough to maintain the reader’s attention for the duration
of the book.
After taking the above criteria into consideration, I decided to select a stack- based,
Reverse Polish Notation (RPN) calculator as the case study. The details of the calculator’s
requirements will be defined below. I believe that the code for a fully functioning
calculator is significant enough that the detailed study of its design provides sufficient
material to cover a book. Yet, the project is small enough that the book can be a reasonable
length. Certainly, specialized domain expertise is not required. I suspect every reader of
this book has used a calculator and is well-versed in its basic functionality. Finally, I hope
that making the calculator RPN provides a suitable twist to stave off boredom.
1.2 A Few Words About Requirements
No matter how big or how small, all programs have requirements. Requirements are
those features, whether explicit or implicit, to which the program must comply. Entire
books have been written on gathering and managing software requirements (see, for
example, [28] or [21]). Typically, despite one’s best efforts, it is practically impossible to
gather all of the requirements upfront. Sometimes, the effort required is economically
infeasible. Sometimes, domain experts overlook what seem like obvious requirements
to them, and they simply neglect to relate all of their requirements to the development
team. Sometimes, requirements only become apparent after the program begins to take
shape. Sometimes, the customer does not understand his or her own requirements well
enough to articulate them to the development team. While some of these dilemmas
may be mitigated using agile development methods, the fact remains that many design
decisions, some of which may have far reaching implications, must occur before all of
the requirements are known.
Chapter 1 Defining theCase stuDy
https://sci101web.wordpress.com/
剩余256页未读,继续阅读
lsb0733
- 粉丝: 1
- 资源: 54
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- OptiX传输试题与SDH基础知识
- C++Builder函数详解与应用
- Linux shell (bash) 文件与字符串比较运算符详解
- Adam Gawne-Cain解读英文版WKT格式与常见投影标准
- dos命令详解:基础操作与网络测试必备
- Windows 蓝屏代码解析与处理指南
- PSoC CY8C24533在电动自行车控制器设计中的应用
- PHP整合FCKeditor网页编辑器教程
- Java Swing计算器源码示例:初学者入门教程
- Eclipse平台上的可视化开发:使用VEP与SWT
- 软件工程CASE工具实践指南
- AIX LVM详解:网络存储架构与管理
- 递归算法解析:文件系统、XML与树图
- 使用Struts2与MySQL构建Web登录验证教程
- PHP5 CLI模式:用PHP编写Shell脚本教程
- MyBatis与Spring完美整合:1.0.0-RC3详解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功