装饰着模式装饰者模式动态地将责任附加到对象上。若要扩展功能,装饰者提供了比继承更有弹性的替代方案。案例有这样一个项目,做一个餐厅订餐系统。起初的代码结构是这样的。前面有很多Beverage的继承类,现在遇到的问题是牛奶的价钱上涨了,那么所有相关的类,我们都要进行调整,比如Milk,SugarAndM...
分类:
其他好文 时间:
2014-12-16 19:02:27
阅读次数:
315
我竟然在这么水的题目上WA了一次,可是它没说要多组数据啊。我的英语啊!!!上题目:
Problem Description
FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as ...
分类:
其他好文 时间:
2014-12-15 13:47:01
阅读次数:
150
Question:Atraditionalrussionsquareismadeby4blocks,andhas7differentpatterns.GivenNblocks,howmanydifferentpatternswouldbe.N=1,P#=1N=2,P#=1N=3,P#=3N=4,P#=7.AssumeN=k,P#=PkthenwhenN=k+1,P#=foreachPinPk,appendonemoreblockaroundP,removedups.classPattern
{
List<..
分类:
其他好文 时间:
2014-12-15 10:34:54
阅读次数:
150
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070注意:1.喝到第五天,第六天就不喝了 2.相同花费的,优先考虑容量大的 3.注意强制类型转换 4.精度一定要注意附上题解: #include #include #include #include ....
分类:
其他好文 时间:
2014-12-14 18:35:38
阅读次数:
149
题目大意:给出一个字符串,求出出现过k次以上的最长的子串(可重叠).
思路:现弄出来sa数组和height数组,之后就是判断每个长度为k的height数组的区间中最小的数字的最大值了.为什么好多人都二分了?这只要单调队列扫一次就行了啊..
CODE:
#include
#include
#include
#include
#include
#define M...
分类:
其他好文 时间:
2014-12-08 13:57:55
阅读次数:
134
前言:
大话设计模式中一直提到GoF,猜想应该是某位创建设计模式的鼻祖大牛,百度之后发现GoF原意:
设计模式的经典名著——Design Patterns: Elements of Reusable Object-Oriented Software,中译本名为《设计模式——可复用面向对象软件的基础》的四位作者Erich Gamma、Richard Helm、Ralph Johnson,以及Jo...
分类:
其他好文 时间:
2014-12-07 17:49:49
阅读次数:
222
原文:http://thecodeship.com/patterns/guide-to-python-function-decorators/仅此做一个中文翻译:我们知道,python在方法def的使用上,有一些非常强大的功能。譬如,将方法传给一个变量:def sayHI(name): ret...
分类:
编程语言 时间:
2014-12-03 20:47:24
阅读次数:
192
原文地址:http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-applic...
分类:
其他好文 时间:
2014-12-03 18:45:03
阅读次数:
275
本文转载至http://www.cocoachina.com/ios/20141124/10296.html相信大家都了解GoF的《Design Patterns》中提到的23种设计模式,其中将常见的设计模式分为三大类:创建型模式、行为型模式、结构型模式。而在《Clean Code》中也提到建造酒店...
分类:
其他好文 时间:
2014-12-03 00:14:13
阅读次数:
194
设计模式(Design Patterns) ——可复用面向对象软件的基础设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性。 毫无疑问,设计模式于己于他人于系统都是多赢的,设...
分类:
编程语言 时间:
2014-11-29 11:44:05
阅读次数:
283