文件名称:
dive into design patterns(Alexander Shvets).pdf
开发工具:
文件大小: 32mb
下载次数: 0
上传时间: 2019-08-31
详细说明:设计模式(Design pattern)代表了最佳的实践,通常被有经验的面向对象的软件开发人员所采用。设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案。这些解决方案是众多软件开发人员经过相当长的一段时间的试验和错误总结出来的。
设计模式是一套被反复使用的、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了重用代码、让代码更容易被他人理解、保证代码可靠性。 毫无疑问,设计模式于己于他人于系统都是多赢的,设计模式使代码编制真正工程化,设计模式是软件工程的基石,如同大厦的一块块砖石一样。项目中合理地运用设计模式可以完美地解决很多问题,每种模式在现实中都有相应的原理来与之对应,每种模式都描述了一个在我们周围不断重复发生的问题,以及该问题的核心解决方案,这也是设计模式能被广泛应用的原因。A Few Words on Copyright
Hi! My name is Alexander Shvets. I'm
the author of the book dive nto
Design Patterns and the online course
Dive Into Refactoring
This book is for your personal use only
Please don't share it with any third
parties except your family members. If you'd like to share the
book with a friend or colleague, buy and send them a
new copy.
All profit from the sale of my books and courses is spent on
the development of Refactoring. Guru. Each copy sold helps
the project immensely and brings the moment of a new book
release a little bit closer
C Alexander Shvets, Refactoring. Guru, 2019
M support(refactoring. guru
e ILlustrations: Dmitry Zhart
Editing: Andrew Wetmore, Rhyan Solomon
I dedicate this book to my wife, Maria. fit
hadn't been for her, /'d probably have finished
the book some 30 years later
4 Table of contents
Table of contents
Tab| e of contents……4
How to read this book
16
INTRODUCTION TO OOP
Basics of oop
Pillars of oop
13
Relations between objects.............20
INTRODUCTION TO DESIGN PATTERNS
What's a Design Pattern?
春鲁春鲁鲁鲁。自。鲁。。意
24
Why should I Learn Patterns?.........28
SOFTWARE DESIGN PRINCIPLES
29
Features of Good Design ........30
Design Principles
34
s Encapsulate What Varies.........5
s Program to an Interface, not an Implementation. 39
s Favor Composition Over Inheritance
4
SOLID Principles..........48
5 Single responsibility Principle.......49
5 Open/Closed Principle
.51
5 Liskov Substitution Principle........54
5 Interface Segregation Principle
61
s Dependency Inversion Principle……
64
5 Table of contents
CATALOG OF DESIGN PATTERNS
68
Creational Design Patterns
69
s Factory Method
71
5 Abstract Factory…
87
s Builder…103
s Prototype
122
5 Singleton............136
Structural Design Patterns..........146
5 Adapter
149
§ Bridge.162
s Composite...............177
5 Decorator
191
5 Facade…..209
s Flyweight
219
5 Proxy…
233
Behavioral Design Patterns
246
s Chain of responsibility
250
s Command
268
s Iterator
289
§ Mediator……1304
5 Memento.…...........….320
Observer…136
s State
352
s Strategy
368
s Template Method
381
5 Visitor…
393
Conclusion…
409
6 How to read this book
How to Read this book
This book contains the descriptions of 22 classic design pat
terns formulated by the"Gang of Four"(or simply goF)in 1994
Each chapter explores a particular pattern. Therefore, you can
read from cover to cover or by picking the patterns you're inter
ested in
Many patterns are related, so you can easily jump from topic
to topic using numerous anchors. The end of each chapter has
a list of links between the current pattern and others. If you
see the name of a pattern that you havent seen yet, just keep
reading-this item will appear in one of the next chapters
Design patterns are universaL. Therefore, all code samples in
this book are written in pseudocode that doesnt constrain the
material to a particular programming language
Prior to studying patterns, you can refresh your memory by
going over the key terms of object-oriented programming
That chapter also explains the basics of UML diagrams, which
is useful because the book has tons of them. Of course, if you
already know all of that, you can proceed to learning patterns
right away.
INTRODUCTION
T000P
8 Introduction to OOP/Basics of OOP
Basics of oop
Object-oriented programming is a paradigm based on the con
cept of wrapping pieces of data, and behavior related to that
data, into special bundles called objects, which are construct
ed from a set of blueprints, defined by a programmer, called
classes
Objects. classes
Do you like cats? I hope you do because I'll try to explain the
OoP concepts using various cat examples
Cat
Name
Visibility+hame
gender
public
private+ age
Fields
weight
(state)
t color
The ellipsis means
that theres more
stuff in the class
breathe
but it's not relevant
+ eat(food)
Methods
at the moment
+run(destination)
sleep(hours)
(behavior)
+ meow
This is a UMl class diagram. You'll see a lot of such diagrams in the book
9 Introduction to OoP/ Basics of OOP
Say you have a cat named Oscar Oscar is an object, an instance
of the Cat class. Every cat has a lot of standard attributes
name, sex, age, weight, color, favorite food, etc. These are the
class's felds
All cats also behave similarly: they breathe, eat, run, sleep and
meow. These are the class's methods Collectively, fields and
methods can be referenced as the members of their class
Data stored inside the object's fields is often referenced
as state, and all the objects methods define its behavior
Oscar: Cat
Luna: Cat
name
Oscar
name
luna
sex
=ma le
sex
= female
age
3
age
2
weight
weight
5
color= brown
color
gray
texture striped
texture= plain
Objects are instances of classes
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.