代码编织梦想

一、

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers,intelligent routing, micro-proxy,control bus, one-time tokens, global locks, leadership  election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns,and using Spring Cloud developers can quickly stand up services and applications that implement those patterns.They will work well in any distributed environment, including the developer's own laptop, bare metal data centres,and managed platforms such as Cloud Foundry.

 解析:Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如,配置管理、服务发现、断路器、智能路由、微代理、控制总线、一次性令牌、全局锁、领导选举、分布式会话、集群状态)。分布式系统的协调导致了锅炉式模式,使用Spring Cloud开发人员可以快速建立实现这些模式的服务和应用程序。它们可以在任何分布式环境中很好地工作,包括开发人员自己的笔记本电脑、裸机数据中心和托管平台(如Cloud Foundry)。

二、

The Open/Closed Principle (OCP)Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification.

When a single change to a program results in a cascade of changes to dependent modules, the design smells of rigidity. OCP advises us to refactor the system so that further changes of that kind will not cause more modifications. If OCP is applied well, further changes of that kind are achieved by

adding new code, not by changing old code that already works. This may seem like motherhood and apple piethe golden, unachievable idealbut in fact, there are some relatively simple and effective strategies for approaching that ideal.

Description of OCP

Modules that conform to OCP have two primary attributes.

They are open for extension. This means that the behavior of the module can be extended. As the requirements of the application change, we can extend the module with new behaviors that satisfy those changes. In other words, we are able to change what the module does.

They are closed for modification. Extending the behavior of a module does not result in changes to the source, or binary, code of the module. The binary executable version of the modulewhether in a linkable library, a DLL, or a .EXE fileremains untouched.

It would seem that these two attributes are at odds. The normal way to extend the behavior of a module is to make changes to the source code of that module. A module that cannot be changed is normally thought to have a fixed behavior.

How is it possible that the behaviors of a module can be modified without changing its source code?Without changing the module, how can we change what a module does?

The answer is abstraction.

解析:

开放/封闭原则(OCP)软件实体(类、模块、函数等)应该对扩展开放,对修改关闭。

当对程序的单一更改导致对相关模块的级联更改时,设计就带有刚性的味道。OCP建议我们重构系统,这样进一步的更改就不会导致更多的修改。如果OCP应用得好,这种类型的进一步变化可以通过

添加新代码,而不是通过更改已经工作的旧代码。这可能看起来像母亲和苹果派,黄金的,无法实现的理想,但事实上,有一些相对简单和有效的策略来实现这个理想。

OCP描述

符合OCP的模块有两个主要属性。

他们对延期开放。这意味着模块的行为可以扩展。随着应用程序需求的变化,我们可以用满足这些变化的新行为来扩展模块。换句话说,我们可以改变模块的功能。

他们因修改而关闭。扩展模块的行为不会导致对模块的源代码或二进制代码的更改。模块的二进制可执行版本,无论是在可链接库、DLL还是. exe文件中,都保持不变。

这两种属性似乎是不一致的。扩展模块行为的正常方法是对该模块的源代码进行更改。无法更改的模块通常被认为具有固定的行为。

怎么可能在不改变源代码的情况下修改模块的行为?在不改变模块的情况下,我们如何改变模块的功能?

答案是抽象。

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m0_65908376/article/details/129543199

100家大公司java笔试题汇总_aplez的博客-爱代码爱编程_java有笔试的公司

NHN CHINA公司笔试题 1.在这写代码 Var array1 = [10,20]; Var array2 = [8,5]; Var result = array1.add(array2); Alert(result); 输出结果18,25   2.解析dom tree <html> <body> <input typ

java面试笔试题大汇总(最全+详细答案)_java面试大全的博客-爱代码爱编程_java面试笔试题

声明:有人说, 有些面试题很变态,个人认为其实是因为我们基础不扎实或者没有深入。本篇文章来自一位很资深的前辈对于最近java面试题目所做的总结归纳,有170道题目 ,知识面很广 ,而且这位前辈对于每个题都自己测试给出了答案 ,如果你对某个题有疑问或者不明白,可以电脑端登录把题目复制下来然后发表评论,大家一起探讨,也可以电脑端登录后关注我给我发私信,我们

java笔试知识点总结(基础)_酒吧七的博客-爱代码爱编程_泛型的类型擦除机制意味着不能在运行时动态获取list中t的实际类型

  异常 异常分类 Java的异常分为两种,一种是运行时异常(RuntimeException),一种是非运行异常也叫检查式异常(CheckedException)。 对异常的处理只有两种try  catch捕获或throws 声明(抛出)异常 1、运行时异常不需要程序员去显式处理,当异常出现时,JVM会帮助处理。常见的运行时异常有: Null

对网上一些java笔试题的总结,答案与自我理解(400道)_weixin_42431912的博客-爱代码爱编程_假设a是一个由线程1和线程2共享的初始值为0的全局变量

对网上一些Java笔试题的总结,答案与自我理解 1… https://www.nowcoder.com/questionTerminal/48db39d722894c08907a8f613858672e 在Java中,对于

java英文面试题_一套英文的Java面试题笔试题-爱代码爱编程

2014-07-15 06:30:01 阅读( 108 ) 一、    选择题: 1.    Which declarations of identifiers are legal? A.$persons B.TwoUsers C.*point D.this E._endline 2.    Which statements abou

java笔试题做多少才行,Java校招笔试题-Java基础部分(二)-爱代码爱编程

导语 Java面试题集2021版 Java基础部分二 14、hashCode方法的作用? hashCode 这个方法是用来鉴定2个对象是否相等,当然它与equals方法还是有一些区别的。 一般来说,equals() 这个方法是给程序员编写代码的时候进行调用的,如果想判断两个对象是否相等,可以对这个方法进行重写,重写的目的就是可以规定自己判断这

原码、反码和补码_程序喵正在路上的博客-爱代码爱编程

🔥 本文由 程序喵正在路上 原创,CSDN首发! 💖 系列专栏:计算机组成原理 🌠 首发时间:2022年9月10日 🦋 欢迎关注🖱点赞👍收藏🌟留言🐾 🌟 一以贯之的努力 不得懈怠的人生 阅读指南 引入原码

java笔试总结(问答题)-爱代码爱编程

1、final、finalize和finally的不同之处? 解析:final是Java中的关键字,修饰符,用于声明 属性(属性不可交变)、方法(方法不可覆盖)、类(类不可继承)。 finally 是 异常处理语句结构 的一部分,不管是否有异常,他的语句总是执行。 finalize 是Object类的一个方法,主要是在收集器执行的时候会调用被回收对象