开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

reference/DesignPatternExample

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
贡献代码
同步代码
对比差异 通过 Pull Request 同步
同步更新到分支
通过 Pull Request 同步
将会在向当前分支创建一个 Pull
Request,合入后将完成同步
File empty ...
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Preface:
================================================================================
In the spirit of contributing to the design pattern community (whilst learning
more about patterns), I followed Mark McFadden’s example of converting the Java
examples associated with "Head First Design Patterns" to another computer
language: C++. 
First, I would like to acknowledge the good work done by the authors of this 
book and their support of my efforts. Second, I do not claim to be a Java 
developer, so I may have misinterpreted a subtle Java notion or convention 
during the conversion process. In this regard, I welcome (constructive) feedback.
 
Finally, I intend to provide three levels of interpretation (Bronze, Silver & Gold)
on two different platforms (Windows & Linux):
-	Bronze; a literal (syntax) translation that produces identical output
-	Silver; a lateral (semantic) translation that preserves the intent using
	good C++ programming practices
-	Gold: a modern level using templates and more STL.
Conventions:
================================================================================
A note about style: 
1) I have adopted the Java idiom of specifying a members access specifier
(e.g, public, protected and private) on an individual basis rather than adhering 
to the 'block' convention in C++. Although it requires a bit more typing, I like 
its explicit clarity, rather than having to search up a class declaration looking
for its access specifier. Warning, personal opinion rant follows: I never understood
the complaint of having to do extra typing, if it makes your code easier to understand
and maintain then its worth the extra keystrokes. Okay, I'm done :-). 
This convention revealed itself while I was creating the 'Bronze' version; when 
my charter was maintain the original example and minimize any code changes. That is, 
I simply wanted it to compile and run. I understand that adopting the Java convention
is a deviation from common C++ practices and some may balk at it (even ridicule it); 
however, I have grown to appreciate its simplicly and explicite clarity. 
2) I took liberties with header files. It is not my convention to put everything
into a single header file that includes the world. I have done so (like access
specifiers) to alter as little as possible from the original examples. I considered
changing it in the 'Silver' version (and I still might), but I am concentrating on
completing the leftover patterns and the 'gold' version at the moment.
3) I welcome positive & negative feeback as long as it is constructive. If there
is a better way to do something, or I simply "missed the boat" I would like to 
know about it. If you have other ideas, would like to expand the examples or provide
alternate versions of them (say Linux) I would be happy to include them and your
name in future updates.
BRONZE 
================================================================================
A 'syntactical' translation; simply get it to compile, run and produce the same
output as the Java examples with minimal changes. No regard was given for memory
leakes or class integrety.
version 1.0:
------------
Adapter:
* Duck and Turkey test drives' where combined into ducks.cpp and implemented by
 defining (or not defining) the pre-processor definition: _DUCK_ADAPTER_
Factory:
* Original Pizzaaf has a logic error, it does not cut Chicago Style pizza's in squares. 
Iterator:
* Renamed ‘Menu’ to ‘Menus’ to avoid a conflict between the project name and one
 of its header files.
* MenuIterator was initially attempted but dismissed for the following reasons:
* It did not eliminate the need for 'PancakeHouseMenuIterator' as in the Java 
 version. In C++, 'PancakeHouseMenuIterator' became an 'adapter' that translated
 the Java Iterator interface to the STL std::iterator interface.
	
Proxy:
* Deferred, pending suitable solution for RMI (most likely it will be 
 ‘boost:: serialization’ implementation.) Or, something completely differrent.
MVC (Model, View, Controller)
* Deferred, pending suitable solution for GUI (most likely it will be a WTL 
 implementation.)
SILVER
================================================================================
A 'semantical' translation; Convey the samples explicit and implicit meaning 
using C++ idioms and good practices; however, I still implement headers that 
"include the world" and contain code; however, the primary intent is still to 
demonstrate a pattern and keeps things as simple as possible.
The Silver version is 'volatile'! That is, it will continue to morph more and more
into what is termed 'Good C++ programming practices'. As stated, the 'Bronze'
version is a 'syntactical' translation only; however, it was also the foundation
for this version, which presented a dilemma: rework existing examples to implement
recognized C++ style, or provide more pattern examples, so its my intent to work
on patter examples and rework the code as I go.
version 1.0:
------------
* Initial release with basic C++ idioms
* Added test.bat (MSDOS style batch file that execute debug and release versions
version 1.1:
------------
* Added 'Bridge' and 'Builder' pattern examples
* Updated (this) readme.txt file
	
version 1.2:
------------
* Added 'Chain of Responsibility' pattern example (added vacation.txt as an 
 input file during execution of test.bat)
* C++ improvements: prepended and underscore (_) to all 'private' and 'protected'
 members, better class member initialization
* Disabled compiler generated methods (copy constructor and assignment operator)
 to ensure the integrity of the class.
* Better class construction in Strategy::MiniDuckSimulator::Duck and derived
 classes.
* Updated (this) readme.txt file
version 1.3:
------------
* Added 'Flyweight' pattern example: "Fowlweight". 
 I deviated from the example in the book for two reasons: I wanted to 'sort' 
 ducks as illustrated in the 'Template Method' pattern and since that illustration
 sorted by 'weight' I thought naming the example 'Fowlweight' combined both the
 pattern and its intent. Since I deviated, I felt obligated to write a narrative
 in the same tone as that used throughout the book. Here is my humble attempt: 
 
 "The number of birds migrating to Objective has overwhelmed the Quackologists
 who are complaining that it is hard to keep up because the journaling program
 you wrote is getting sluggish. Quackologists capture birds, categorize them, 
 weight them, tag them, and finally, record them with your program; however,
 as the size of the flock grows your program begins to crawl. After hours of
 drinking coffee at Starbuzz reviewing your design, you realize that some 
 traits are common to each type of bird; its type, the sound it makes and how
 it swims. If only you could isolate the common (intrinsic) traits from the 
 unique (extrinsic) traits, its weight and tag number. Your redesign implements
 the ‘Flyweight’ pattern by creating a single instance for each type of bird and
 each bird contains a reference back to its type."
version 1.4:
------------
* Added 'Interpreter' pattern (with 'Visitor'): "MiniDuckSimulator".
 See 'readme.txt' in 'Interpreter' directory for additional information regarding
 the implementation of this pattern(s).
 Possible enhancements: 
	- add other keywords, such as 'for', 'if'
	- add 'turkey' via adapter
	
version 1.5:
------------
* Added 'Visitor' pattern: "Menus".
 See 'readme.txt' in 'Visitor' directory for additional information regarding
 the implementation of this pattern(s).
version 1.6:
------------
* Added 'Mediator' pattern: "AutoHouse"
 See 'readme.txt' in 'mediator' directory for additional information regarding
 the implementation of this pattern(s).
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/reference/DesignPatternExample.git
git@gitee.com:reference/DesignPatternExample.git
reference
DesignPatternExample
DesignPatternExample
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /