没有合适的资源?快使用搜索试试~ 我知道了~
Smalltalk Best Practice Patterns Kent Beck
5星 · 超过95%的资源 需积分: 13 11 下载量 118 浏览量
2012-12-27
16:00:15
上传
评论
收藏 243KB PDF 举报
温馨提示
试读
147页
This book presents a set of patterns that organize all the informal experience successful Smalltalk programmers have learned the hard way. Understand these patterns, and you can write much more effective code. Understand the concept of Smalltalk patterns and why they work. Then learn patterns for working with methods, messages, state, collections, classes and formatting. Walk through a development example utilizing patterns. Smalltalk programmers, project managers, teachers and students -- both new and experienced.
资源推荐
资源详情
资源评论
Coding Patterns page 1 of 147 9/30/2006
Smalltalk Best Practice Patterns
Volume 1: Coding
Kent Beck
First Class Software, Inc.
Draft for comment only.
Copyright (c) 1995, 1996, Kent Beck, All rights reserved.
Please send comments to:
voice: +1.408.338.4649
fax: +1.408.338.1115
email: 70761.1216@compuserve.com
Coding Patterns page 2 of 147 9/30/2006
Table of Contents
TABLE OF CONTENTS .......................................................................................................................................2
PREFACE......................................................................................................................................................5
ACKNOWLEDGMENTS.............................................................................................................................7
INTRODUCTION.........................................................................................................................................8
CODING............................................................................................................................................................9
Talking Programs........................................................................................................................................9
GOOD SOFTWARE...........................................................................................................................................11
S
TYLE.............................................................................................................................................................13
W
HAT’S MISSING? .........................................................................................................................................14
O
RGANIZATION ..............................................................................................................................................15
A
DOPTION ......................................................................................................................................................16
PATTERNS..................................................................................................................................................17
WHY PATTERNS WORK..................................................................................................................................18
R
OLE OF PATTERNS........................................................................................................................................20
Reading......................................................................................................................................................20
Development..............................................................................................................................................20
Review .......................................................................................................................................................20
Documentation ..........................................................................................................................................20
Clean Up ...................................................................................................................................................20
FORMAT .........................................................................................................................................................21
BEHAVIOR .................................................................................................................................................22
METHODS.......................................................................................................................................................23
Composed Method ................................................................................................................................................. 24
Complete Creation Method .................................................................................................................................... 26
Creation Parameter Method ................................................................................................................................... 27
Conversion ............................................................................................................................................................. 28
Converter Method .................................................................................................................................................. 29
Converter Creation Method.................................................................................................................................... 30
Constructor Method ............................................................................................................................................... 31
Query Method ........................................................................................................................................................ 32
Comparing Method ................................................................................................................................................ 33
Execute Around Method ........................................................................................................................................ 34
Debug Printing Method.......................................................................................................................................... 35
MESSAGES......................................................................................................................................................36
Message.................................................................................................................................................................. 37
Choosing Message ................................................................................................................................................. 38
Decomposing Message........................................................................................................................................... 40
Intention Revealing Message ................................................................................................................................. 41
Intention Revealing Selector .................................................................................................................................. 42
Double Dispatch..................................................................................................................................................... 43
Send Back .............................................................................................................................................................. 45
Super ...................................................................................................................................................................... 47
Extending Super..................................................................................................................................................... 48
Modifying Super .................................................................................................................................................... 49
Delegation.............................................................................................................................................................. 50
Simple Delegation.................................................................................................................................................. 51
Self Delegation....................................................................................................................................................... 52
Pluggable Behavior ................................................................................................................................................ 54
Pluggable Selector.................................................................................................................................................. 55
Pluggable Block ..................................................................................................................................................... 56
Collecting Parameter.............................................................................................................................................. 57
Coding Patterns page 3 of 147 9/30/2006
STATE..........................................................................................................................................................59
INSTANCE VARIABLES....................................................................................................................................60
Common State........................................................................................................................................................ 61
Variable State......................................................................................................................................................... 62
Explicit Initialization.............................................................................................................................................. 63
Lazy Initialization .................................................................................................................................................. 65
Default Value Method............................................................................................................................................ 66
Constant Method.................................................................................................................................................... 67
Direct Variable Access........................................................................................................................................... 68
Indirect Variable Access ........................................................................................................................................ 69
Getting Method ...................................................................................................................................................... 70
Setting Method....................................................................................................................................................... 71
Collection Accessor Method .................................................................................................................................. 72
Enumeration Method.............................................................................................................................................. 74
Boolean Property Setting Method.......................................................................................................................... 75
Role Suggesting Instance Variable Name .............................................................................................................. 76
TEMPORARY VARIABLES................................................................................................................................77
Temporary Variable ............................................................................................................................................... 78
Collecting Temporary Variable.............................................................................................................................. 79
Caching Temporary Variable ................................................................................................................................. 80
Explaining Temporary Variable............................................................................................................................. 81
Reusing Temporary Variable ................................................................................................................................. 82
Role Suggesting Temporary Variable Name.......................................................................................................... 83
COLLECTIONS..........................................................................................................................................84
CLASSES.........................................................................................................................................................85
Collection............................................................................................................................................................... 86
OrderedCollection.................................................................................................................................................. 87
RunArray................................................................................................................................................................ 88
Set .......................................................................................................................................................................... 89
Equality Method..................................................................................................................................................... 91
Hashing Method..................................................................................................................................................... 93
Dictionary............................................................................................................................................................... 94
SortedCollection..................................................................................................................................................... 96
Array ...................................................................................................................................................................... 97
ByteArray............................................................................................................................................................... 98
Interval................................................................................................................................................................... 99
COLLECTION PROTOCOL...............................................................................................................................101
IsEmpty................................................................................................................................................................ 102
Includes:............................................................................................................................................................... 103
Concatentation ..................................................................................................................................................... 104
Enumeration......................................................................................................................................................... 105
Do......................................................................................................................................................................... 106
Collect.................................................................................................................................................................. 107
Select/Reject......................................................................................................................................................... 108
Detect................................................................................................................................................................... 109
Inject:into:............................................................................................................................................................ 110
COLLECTION IDIOMS ....................................................................................................................................111
Duplicate Removing Set....................................................................................................................................... 112
Temporarily Sorted Collection............................................................................................................................. 113
Stack..................................................................................................................................................................... 114
Queue................................................................................................................................................................... 115
Searching Literal.................................................................................................................................................. 117
Lookup Cache ...................................................................................................................................................... 118
Parsing Stream ..................................................................................................................................................... 120
Concatenating Stream .......................................................................................................................................... 121
CLASSES ...................................................................................................................................................122
Simple Superclass Name...................................................................................................................................... 123
Coding Patterns page 4 of 147 9/30/2006
Qualified Subclass Name ..................................................................................................................................... 124
Factored Superclass.............................................................................................................................................. 125
FORMATTING.........................................................................................................................................126
Inline Message Pattern ......................................................................................................................................... 127
Type Suggesting Parameter Name........................................................................................................................ 128
Indented Control Flow ......................................................................................................................................... 129
Rectangular Block................................................................................................................................................ 130
Guard Clause........................................................................................................................................................ 131
Conditional Expression........................................................................................................................................ 132
Simple Enumeration Parameter............................................................................................................................ 134
Cascade ................................................................................................................................................................ 135
Yourself................................................................................................................................................................ 137
Interesting Return Value ...................................................................................................................................... 139
DEVELOPMENT EXAMPLE.................................................................................................................140
PROBLEM .....................................................................................................................................................141
A
RITHMETIC.................................................................................................................................................143
I
NTEGRATION ...............................................................................................................................................145
S
UMMARY....................................................................................................................................................147
Coding Patterns page 5 of 147 9/30/2006
Preface
This preface will explain what this book is about. It will convince you to buy this book, or you will
know why you shouldn’t (more of the former than the latter, I hope).
What’s it all about?
This book is about the simple things experienced, successful Smalltalkers do that beginners don’t.
In a sense it is a style guide. I have tried to penetrate beneath the surface, though, to get at the
human realities that make the rules work instead of focusing solely on the rules themselves.
The topics covered are the daily tactics of programming:
How do you choose names for objects, variables, and methods?
How do you break logic into methods?
How do you communicate most clearly through your code?
These are small issues. There are also many bigger technical reasons why projects fail (and many
more non-technical reasons). The attraction of this set of issues is that they are so tractable. You
don’t have to be a programming wizard to pick good names, you just have to have good advice.
The advice is broken into 89 patterns. Each pattern presents:
a recurring daily programming problem
the tradeoffs that affect solutions to the problem
a concrete recipe to create a solution for the problem
For example, here is a summary of a pattern called “Role Suggesting Temporary Variable Name”:
Problem: What do you name a temporary variable?
Tradeoffs:
You want to include lots of information in the name
You want the name to be short so it is easy to type and doesn’t make formatting
difficult
You don’t want redundant information in the name
You want to communicate why the variable exists
You want to communicate the type of the variable (i.e. what messages it is sent)
Solution: Name the variable after the role it plays. The type can be inferred from context,
and so doesn’t need to be part of the name.
剩余146页未读,继续阅读
资源评论
- xdestiny2017-10-14不错,支持。
- nazifans802015-01-23很不错的,最近在学习该语言,谢谢
- hollyxu2014-08-12好的文档,支持!
- frankchenhf2013-03-20文档很清晰,谢谢楼主分享!
王辉的博客
- 粉丝: 21
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JSP企业人事管理系统设计(源代码+论文).rar
- VFP现代物流企业管理系统(源代码+论文).rar
- [图片动画]iFoto v1.0_ifoto-1.0.1.rar
- ssm+vue的物资物流系统的设计与实现(有报告) Javaee项目,ssm vue前后端分离项目
- 521yy 网站Whois查询 php版 1.0_whois_工具查询网站开发模板(使用说明+PHP源代码+html).zip
- vb药品库房管理系统设计(源代码+可执行程序+论文+开题报告+外文翻译+答辩ppt).rar
- 按键 12864显示_单片机C语言实例(纯C语言源代码).zip
- (FZY314)触屏版HTML5左侧展开导航菜单手机wap网站特效源码.zip
- 红外解码数码管显示_单片机C语言实例(纯C语言源代码).zip
- 案例3 遗传算法优化BP神经网络-非线性函数拟合.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功