zoukankan      html  css  js  c++  java
  • 声明式编程与命令式编程

    声明式编程(Declarative Programming)和命令式编程(Imperative Programming)是两种编程范式。

    Alright here’s a metaphor.

    Declarative Programming is like asking your friend to draw a landscape. You don’t care how they draw it, that’s up to them.

    Imperative Programming is like your friend listening to Bob Ross tell them how to paint a landscape. While good ole Bob Ross isn’t exactly commanding, he is giving them step by step directions to get the desired result.

    声明式编程就像是你告诉你朋友画一幅画,但是你不用去关心他怎么画。

    命令式编程就像是你的朋友完全按照你的命令,将画一步步地画出来。

    比如像Spring提供的依赖注入特性,我们将只需要声明在运行过程中需要用到的Bean,Spring就会自动帮我们注入依赖,而不用我们手动去new一个。我们手动去new一个对象这样的做法就是命令式编程,而我们将new一个对象的操作交给Spring容器去实现,这样的做法就是声明式编程。注意到了吗,我们只需要声明在哪里需要用到这些Bean,而不再需要去关心这些Bean在什么时候、在哪里被创建或是怎么样被创建和销毁这样的细节,这就是声明式编程带给我们的好处。

    这样的设计放到整个应用层面也是一样的道理,我们更加需要关心的是整个应用和页面的框架结构。

    "成熟谦卑的人,知道如何面对人生中的失望。"

  • 相关阅读:
    Hive-1.2.1_05_案例操作
    Hive-1.2.1_04_DML操作
    Hive-1.2.1_03_DDL操作
    Hive-1.2.1_02_简单操作与访问方式
    Hive-1.2.1_01_安装部署
    Hadoop2.7.6_08_Federation联邦机制
    Hadoop2.7.6_07_HA高可用
    NFS服务搭建与配置
    Hadoop2.7.6_06_mapreduce参数优化
    Hadoop2.7.6_05_mapreduce-Yarn
  • 原文地址:https://www.cnblogs.com/yanggb/p/12571692.html
Copyright © 2011-2022 走看看