文件名称:
More Coding In Delphi.pdf
开发工具:
文件大小: 14mb
下载次数: 0
上传时间: 2019-08-23
详细说明:Delphi进阶书籍,是Coding in delphi作者的最新力作,对于入门之后需要提高编程水平的Delphier们来说是本好书,在国内这类书太少了,尤其是进些年来,Delphi已经没有新书发布了,而国外Delphi还是有很多拥泵的,书籍也非常丰富,这本书就是其中之一,希望能帮助大家。Tweet This book!
Please help Nick Hodges by spreading the word about this book on Twitter
The suggested hashtag for this book is #morecodingindelphi
Find out what other people are saying about the book by clicking on this link to search for this hashtag on
Twitter
https://twitter.com/search?q=#morecodingindelph
Contents
Foreword
reface
Acknowledgments
Frameworks Used in this book
Spring for Delphi Framework
DuckDuckDelph
Six Thoughts Before We start
Thoughts on Encapsulation
Thoughts on Coupling
Thoughts on Cohesion
Thoughts on Command Query Principle
4垂.
Thoughts on Postel's Law
56790
Thoughts on Composition over Inheritance
Conclusion
13
Writing SOLID Code
新
15
15
What Solid is
15
Single responsibility Principle
16
Open/Closed Principle
18
Liskov's Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
26
Conclusion
30
Patterns..·
31
Factory Pattern
32
2
An informal look at factories
32
A More Formal look at factories
42
Factory Method
42
Abstract Factory
CONTENTS
Conclusion
47
Observer Pattern
48
Introduction
Baseball data
48
Generic Observer with Spring4D
54
Conclusion
The Adapter Pattern
58
Introduction
A Simple example
59
A More Practical Example
Conclusion
Decorator pattern
66
Decorator and Interfaces
70
Summary
75
Command Pattern
77
A Simple example: An auto Key fob
··
Undoing Commands
82
A Simple queue of Commands
86
ummary
Operator overloading
An Example: Teraction
92
Assignments
96
Implicit vs Explicit
7
Sir
g
FRact
98
Conclusion
Multi-Threading and parallelism
101
About These Three Chapters
101
What is a thread?
101
Think Differently
Why Should I Care About Multi-threaded and Parallel Programming?
103
Multi-threading with TThread
106
Introduction
106
Descending from tThread
106
Thread Termination
111
Handling Exceptions in Threads
114
TThread Class methods
116
Synchronization
118
Abstracting the notion of synchronization
121
CONTENTS
The Perils of Multi-threading
127
Conclusion
·
128
Parallel Programming
129
Parallel Programming Library
129
Parallel For Loops
146
Introduction
146
Conclusion
159
Aspect-Oriented Programming
160
Introduction
160
An lllustration
161
The basics:
162
A More Useful Example
AOP in a Single place
171
AoP via attributes
17
Conclusion
174
Component Writing
175
Introduction
175
TSmiley -a Brief history
175
Start from scratch
Conclusion
196
Appendix A: Resources
Source contro
,197
Pattern
198
A
ppendIx
B:
ping
.199
Introduction
What is Going on Here?
Duck Typing with DSh
200
Duck Typing with DuckDuckDelphi
203
Duck Typing in the VCL
2(
Why use duck typing?
208
Problems with Duck Typing
208
Conclusion
209
Appendix C: Stuff Nick Does When Coding
·
210
Formatting Stuff
210
Spacing
210
Coding Stuff
214
Conclusion
.217
Appendix D: Sources Used in Writing This Book
218
Books
218
CONTENTS
Web links
.218
eos
··
219
Foreword
I first met Nick Hodges at a meeting of the Naval Postgraduate Schools PC Computer Club the early 1990s
I drove down to the meeting from Scotts Valley to present Borlands developer tools(which included Turbo
Pascal for Windows, Borland Pascal, Turbo C++ and Borland C++). In those early days we had the turbo
Vision and OWL class libraries for writing DOS and Windows applications. By the middle of the 1990's the
VCL component architecture( Properties, Methods, Events) was added to move gui programming to the next
level for Pascal and C++ developers. Even with these extensive class and component libraries, developers still
needed to focus a majority of their time on their code, the real business logic of an application
I have had the privilege of working closely with Nick Hodges since those early days when he was a member
of our developer community and also as a fellow employee. Nick has always had a passion for programming,
developer tools and the community of developers who love what we can do with the tools and code. Nick
has also shown the development world new tips, tricks and techniques at our live conferences, online events
technical articles, blog posts and videos
In his first book, Coding in Delphi, Nick shared even more of his coding experiences to the world showing
developers the power and new innovations in the object Pascal programming language including: interfaces,
generics, attrib
utes and anonymous methods beyond new language syntax, nick went on to showcase best
practices for exception handing, using the extended runtime type information system and exception handling
To finish the book, Nick documented his years of experience modernizing legacy applications while keeping
them stable using dependency injection and unit testing
In this new book, More Coding in Delphi, Nick brings us all to an even higher level of programming
expertise covering patterns, operator overloading, parallel programming, multi-threading, aspect oriented
programming and component development
It is my honor to call Nick Hodges my friend. More importantly, I am an avid Nick Hodges student of
programming. Put together, these two books provide the largest amount of deep Delphi coding expertise
covering the most important programming topics
I know you will enjoy reading and learning about"More Coding in Delphi
DaⅤ id Intersimone“ David i
Vice President of Developer relations and Chief Evangelist
Embarcadero technologies
August 1, 2015
Preface
Well, here we are again. This book is to follow my first book, Coding in Delphi. I was humbled and pleased by
the reception it received, and so i decided to give book writing another shot.
The first book didn t have many screen shots of forms and such. The focus was on the code. Ultimately, thats
what we developers produce, right? I thought it would be a good idea to write another book of the same ilk
because, well, the first one worked out really well and because there was a lot more to write about. However
this one will have a few screen shots in it, as there are some coding principles -parallel programming comes
to mind- where a simple console application wont quite illustrate things well. So this book will have some
VCL applications in the demo code.
I' ve actually broken down and included an entire chapter on VCL component writing. My friend, Bob Dawson
suggested that it has been quite a while since anyone wrote about components, and i decided he was right
So we'll get a chapter covering the latest techniques on building the immortal TSmiley
But the focus will remain, as always, on the code
One of the reasons that I've written these books is that they force me to learn new things. I'll be honest: at the
start of the first book, I didnt always know enough to write a complete chapter on the topic at hand (cough
parallel programming, cough, cough). But I used writing about the topic as an opportunity to learn all i could
and share it with you. The same is true of this book -I've learned a lot in writing it. This seems to work well
as we both end up smarter. I love learning, and I assume you do, too, because you bought this book. They
say that you never really know a topic until you have to teach it, and these books are my way of teaching to
learn, in addition to giving back to the Delphi community that has given me so much
Another aspect to this book is that it uses a number of open source frameworks to teach the principles and
techniques within. One of the objections that i hear from developers about using some of the tools and
frameworks included in these books is that they add"bloat and make binaries bigger. While i might not
gree with the characterization that comes with the term "bloat, I have no choice but to concede the point
about binary size. However, I'm going to press forward with the assumption that binary size isnt an issue
You can't make an omelet without breaking a few eggs, and in this case, the broken eggs are an expansion of
generated code. For instance, if you want to use Duck Typing in your application, you'll need to enable RTti,
and that is going to increase the size of your binary. But without that increase, you dont get Duck Typing
It's a price that must be paid for cleaner, more powerful code
The same thing could be said for performance. Much of what is discussed here wont make for the most
blazingly fast code ever written, but blazingly fast code isnt always the goal. If speed is your deal, you've
likely come to the wrong place. My friend, Bob Dawson, refers to the battle between two types of developers
those that want speed and performance and would have Delphi be more like C++, and those that want Delphi
to be more like C#, with more powerful language features and libraries as part of the system. i fall in the
second camp, and this book, as did my previous book, will reflect that Speed is nice, but clear, powerful code
is what i'n interested in
ome things to note
Preface
I'm going to assume in this book that you have read my first book, Coding in Delphi. If you havent
done so, I very strongly recommend that you head over to the books website, buy a copy and read it
first. There will be things I talk about here that assume you know the ideas and principles found in the
first book. In addition my demo code may make use of things like the the spring4d2 collections and
other frameworks discussed in Coding in delphi
all of the code and this entire book is written about the windows compiler We wont be covering any
of the newer features added to the mobile compilers in more recent versions of delphi
This book was written with Delphi XE8 as the main development platform- nost of the code will very
likely work with earlier versions, but some of it wont. Specifically, the Parallel library is found only in
Delphi Xe7 and above, so for that chapter you' ll have to have at least XE7
There's a further point that i want to emphasize that i dont think i made clear enough in my previous bool
The techniques that i describe here and in my previous book should generally be applied to green-field code
By that, I mean"code that you write from scratch. Im pleased that I've helped some people"see the light
on writing clean, decoupled code, but you can only take these principles so far
For instance, I urge you to code against interfaces and not implementations. But i wouldnt argue that you
should wrap every component in an interface I would argue that when you start writing your domain
objects and business classes, you should write against interfaces, but for things like already existing code
or components, you can use those as is. There's no need to try to put your datamodules into the Spring 4D
Container. The bottom line- if it seems hard to do, then maybe you shouldnt be doing it. Writing clean
code should flow naturally, and if you find yourself fighting to do it, then perhaps you need to rethink your
p
In any event, the goal here is as before: to help you write clean, uncoupled code with your concerns neatly
separated and your code highly maintainable and testable. I hope that this book does that for you like the last
one did
http://www.codingindelphi.com
http://www.springid.org
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.