Tag:decorate

  • Using Python decorator

    Time:2020-11-21

    Decorator pattern is one of the commonly used software design patterns. With this design pattern, we can assign new responsibilities to existing objects without modifying any underlying code. In Python, decorators can be used to implement decorator mode simply. PS note: many people will encounter a variety of vexation problems in the process of learning […]

  • Typescript 3.0 + react + Redux best practices

    Time:2020-11-4

    First of all, this article is to explain the new features of the latest version of typescript (3.0), which brings great improvement in the development experience of react, rather than how to use typescript to develop react applications This feature is rightdefaultPropsSupport for is described in the wiki of typescript. For details, please refer to: […]

  • Decorator usage of connect in react Redux

    Time:2020-10-8

    Recently, I studied the management of data state in react, that is, redux. When we want to use Redux, we will write a reducer and an action, and then use connect to wrap your component, as follows App.js As shown in Fig import React from ‘react’ import {render} from ‘react-dom’ import {connect} from ‘react-redux’ import […]

  • Summary of design patterns (1)

    Time:2020-9-12

    Through encapsulation, inheritance and polymorphism, the coupling degree of the program is reduced, which makes the program more flexible, easy to modify and easy to reuse Simple factory public class Operation { public double NumberA { get; set; } public double NumberB { get; set; } public virtual double GetResult() { double result = 0; […]

  • 2020python job 15 — decorator 2 + iterator

    Time:2020-8-16

    @2020.3.24 (Q1) Assignment:1. Write the decorator with parameters explained in class def auth(db_type = ‘file’): def inner(func): def wrapper(*args, **kwargs): inp_name = input(“your name:”).strip() inp_pwd = input(“your password:”).strip() if db_type == ‘file’: with open(r’db.txt’, ‘rt’, encoding=’utf-8′) as f: for line in f: user, pwd, *_ = line.strip().split(‘:’) if inp_name == user and inp_pwd == pwd: […]

  • Implementation of flash cross domain access decorator

    Time:2020-8-11

    Now web development has entered the stage of separating the front end and the back endThe back end often only needs to spit API data Generally pure API interface needs to consider cross domain accessThe following is a simple implementation of cross domain access decorator in flash from functools import wraps from flask import make_response […]

  • In 2020, you don’t know JavaScript decorators yet?

    Time:2020-8-4

    As the saying goes, people depend on clothes, while Buddha depends on gold clothes. The girls in the street like to dress themselves up. You can’t help looking at them more. This is the function of decoration. 1. Preface Decorator is a proposal in the latest ECMA, which is a kind of and class(class)Related syntax […]

  • Decorating connect with decorators in react

    Time:2020-8-1

    Suppose we have the following header components in react: import React, { PureComponent } from ‘react’; import { connect } from ‘react-redux’; import actions from ‘./actions’; class Header extends PureComponent{ render(){ return ( < div > this is a component < / div > ) } } const mapStateToProps = state => ({ todos:state.todos }) […]

  • Design pattern — Decorator Pattern

    Time:2020-7-23

    Decorator pattern allows you to add new functionality to an existing object without changing its structure. This type of design pattern is a structural pattern that serves as a wrapper around an existing class. Decorator pattern structure diagram Component (abstract component): it is the common parent class (usually interface or abstract class) of decoration class […]

  • Learning notes of design mode: (8) decoration mode

    Time:2020-6-28

    This note is excerpted from: https://www.cnblogs.com/PatrickLiu/p/7723225.html Record the learning process for future reference.     1、 Introduction Today we are going to talk about the third mode of structural design mode — decoration mode. When I first saw this name, I thought of another word “decoration”. Let’s talk about my understanding of “decoration”. Please See clearly […]