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

  • 相关阅读:
    temp12
    temp111
    test.c
    vipLogin.c
    services.c
    request.c
    managerLogin.c
    将博客搬至CSDN
    SpringMabatis整合项目mybatis-configuration.xml核心配置
    logback-test.xml配置文件模板
  • 原文地址:https://www.cnblogs.com/gpuasic/p/3837809.html
Copyright © 2011-2022 走看看