Java笔试总结(英汉互译)

一、

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文件中,都保持不变。

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

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

答案是抽象。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值