码迷,mamicode.com
首页 > 其他好文 > 详细

HF-DP1: strategy pattern

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

标签:des   http   java   color   strong   os   

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

标签:des   http   java   color   strong   os   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!