zoukankan      html  css  js  c++  java
  • HF-DP1: strategy pattern

    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)

    OOP_Concepts_and_manymore/notation.jpg

  • 相关阅读:
    10.20stark组件已经完工
    webpack3到webpack4
    app埋点
    postman使用
    phantomjs
    nodejieba中文分词
    爬虫--cheerio
    mysql命令(三)
    mysql学习(二)
    mysql安装登录
  • 原文地址:https://www.cnblogs.com/gpuasic/p/3837809.html
Copyright © 2011-2022 走看看