首页 > 其他 > 详细

HF-DP1: strategy pattern

时间:2014-07-13 10:51:17      阅读:318      评论:0      收藏:0      [点我收藏+]

This is the 1st pattern I study. In here, I will mark down my doubts, java study, DESIGN PRINCIPLES, DESIGN PATTERN.

There are 3 design principles in this pattern:

1. Identify the aspects of your application that vary and separate them from what stays the same (Codeproject)

2. Program to an interface, not an implementation (Stackoverflow)

3. Favor composition over inheritance (Stackoverflow)

 

Java study:

1. In C++, Absolute C++ said we need to encapsulate so that we separate codes into Interface (.hpp) and Implementation (.cpp). But in Java, just use:

public interface name{}

public class name{}

2. In strategy DP, encapsulate algorithms for one interface. and the duck base class needs to be inherited, and use abstract method. By defining an abstract method, the class needs to be defined as:

public abstract class Duck{}

3.

UML notations: (ref: codeproj link shown before)

bubuko.com,布布扣

HF-DP1: strategy pattern,布布扣,bubuko.com

HF-DP1: strategy pattern

原文:http://www.cnblogs.com/gpuasic/p/3837809.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!