Java8设计模式最佳实战-设计模式概述(第一天学习记录)

对象和类选择的创建和初始化;结构模式定义

relationship between classes and objects, and the behavioral patterns control the

类和对象之间的关系,以及行为模式控制

communication and interaction between objects. As well as this, the GoF design patterns

对象之间的通信和交互。除此之外,GoF的设计模式

have two types of scope which define the focus of solutions. These scopes are object

有两种定义解决方案重点的范围。这些作用域是对象

scope, which resolves problems about object relations, and class scope, which resolves

scope用于解决有关对象关系的问题,类scope用于解决

problems about class relations.

关于类关系的问题。

The object scope works with composition and the behavior changes are done in a runtime.

对象作用域与组合一起工作,行为更改在运行时完成。

Thus, the object can have a dynamic behavior. The class scope works with inheritance and

因此,对象可以具有动态行为。类作用域使用继承和

its behavior is static-fixed at compile-time way. Then, to change the behavior of a classscope pattern, we need to change the class and recompile.

它的行为在编译时是静态固定的。然后,要更改类作用域模式的行为,我们需要更改类并重新编译。

Patterns classified as class scope solve problems about the relationship between classes and

此分类为类范围的模式解决了类之间关系

are static (fixed at compile time and cannot be changed once compiled). However, patterns

是静态的(在编译时是固定的,一旦编译就不能更改)。然而,模式

classified under the object scope solve problems about the relationship between objects and

在对象范围下进行分类,解决对象之间关系

can be changed at runtime

可以在运行时更改

重点词汇


  • As well as 既…又… ; 除…之外 ; 此外

  • types of 类型 ; 的型态 ; 债券的种类

  • resolves 解决 ; 决心 ; 决定 ; 作出决定 ; 作出决议 ; 表决 ; 坚定的信

The following diagram shows us the three classifications, as well as their patterns and

下图显示了三种分类,以及它们的模式和

scope:

范围:

在这里插入图片描述

In the preceding diagram, we can see the Factory Method pattern on the Class section and

在前面的图中,我们可以在Class部分和

the Abstract Factory pattern on the Object section. This occurs because the Factory Method

对象部分上的抽象工厂模式。这是因为工厂方法

works with inheritance and the abstract method pattern works with composition. Then, the

处理继承,抽象方法模式处理组合。然后

Factory Method is static-fixed at compile time and cannot be changed after compilation.

工厂方法在编译时是静态固定的,编译后不能更改。

However, the Abstract Factory is dynamic and can be changed at runtime.

但是,抽象工厂是动态的,可以在运行时更改。

GoF design patterns are generally described using a graphical notation such as a use case

GoF设计模式通常使用图形表示法来描述,例如用例

diagram, and an example of the implementation’s code. The used notation must be able to

图,以及实现的代码示例。使用的符号必须能够

describe the classes and objects as well as the relationship between these classes and

描述类和对象以及这些类和

objects.

对象。

The pattern’s name is an important part of the design patterns. This is because it is what the

模式的名称是设计模式的重要组成部分。这是因为

developer uses to quickly identify the problem related to the pattern and to understand

开发人员用来快速识别与模式相关的问题并理解

how the pattern will solve it. The name of the pattern must be brief and refer to the problem

模式将如何解决它。模式的名称必须简短并引用问题

and its solution.

以及它的解决方案。

重点词汇


  • 在前面 farther on ; fore

  • 继承 inherit ; succeed ; carry on ; carry forward

  • 抽象方法 abstract method

  • 编译 compile ; translate and edit

  • 静态 static state ; quiescent condition ; steady state ; statics

  • 更改 change ; alter ; alteration

  • 抽象 abstract

pattern is a great tool for designing software development, but its use needs to be

模式是设计软件开发的一个很好的工具,但是它的使用需要

analyzed to determine if the design pattern is really required in order to solve the problem.

分析以确定是否确实需要设计模式来解决问题。

The catalog of Gang of Four design patterns

四人帮设计模式分类目录

Names of design patterns need be succinct, making them easy to identify. This is because

设计模式的名称必须简洁,使其易于识别。这是因为

design patterns create a vocabulary for communicating between developers independent of

设计模式创建了一个独立于

programming language, permitting developers to identify problems and solutions only by

编程语言,允许开发人员通过

name of a design pattern.

设计模式的名称。

In design patterns, a catalog is a set of pattern names which are designed to permit a better

在设计模式中,目录是一组模式名,它们被设计成允许更好的的沟通在

communication between developers.

开发人员之间。

The catalog of GoF’s design patterns has 23 patterns, as 在shown in the preceding diagram.

GoF的设计模式目录有23个模式,如上图所示。

Here is a description of these patterns:

以下是对这些模式的描述:

Abstract Factory: This provides an interface to create objects without specifying

抽象工厂:这提供了一个接口来创建对象,而无需指定

their concrete class, making it possible to decouple the business logic and

它们的具体类,使业务逻辑和

the object creation logic. With this, we can update the object creation logic in an

对象创建逻辑。这样,我们就可以更新对象的创建逻辑

easy way.

简单点。

Adapter: This provides an interface that makes it possible for two incompatible

适配器:这提供了一个接口,使两个不兼容的

interfaces to work together. The adapter pattern works as a bridge between

接口协同工作。适配器模式在

interfaces, adapting these interfaces to work together. Furthermore, the adapter

接口,调整这些接口以协同工作。此外,适配器

can adopt a class or objects.

可以采用一个类或对象。

Bridge: This pattern decouples an abstraction from its implementation, making

桥:这个模式将抽象从它的实现中分离出来,使得

them vary independently. With this, we can modify the implementations without

它们各不相同。有了它,我们可以修改实现而不需要

impacting the abstractions and we can also modify the abstractions without

影响抽象,我们也可以在没有

impacting the implementations. The class of abstraction hides implementations

影响实施。抽象类隐藏了实现

and its complexity.

以及它的复杂性。

Builder: This pattern separates the construction of a complex object from its

Builder:此模式将分开复杂对象的构造与其

representation. With this, we can construct the objects of several representations

表现 。有了它,我们就可以构造多个表示的对象

using the same process to that. Thus, we create a standard process of

用同样的方法。因此,我们创建了一个

construction of objects that have a complex process to construct.

构造一个复杂的过程。

Chain of responsibility: This pattern avoids coupling the sender and receiver of

责任链:这种模式避免了

a request creating some objects that have a chance to treat the requests. These

创建一些对象的请求,这些对象有机会处理这些请求。这些

objects create a chain of receiver objects for a sender’s request. Each object of this

对象为发送方的请求创建接收方对象链。每一个目标

chain receives the request and verifies whether or not it will treat this request.

chain接收请求并验证是否将处理此请求。

Command: This pattern encapsulates a request for an object and creates a

命令:此模式封装对对象的请求并创建

wrapper of requests containing their information about the request. With this, we

包含请求相关信息的请求包装器。有了这个,我们

can do a request to some object sending parameters without knowing about this

可以在不知道的情况下向某些对象发送参数

operation. Furthermore, the command permits us to execute an undo operation.

操作。此外,该命令允许我们执行撤消操作。

Composite: This pattern composes objects into a tree structure, which represents

复合:这个模式将对象组合成一个树结构,它表示

a part-whole hierarchy. It permits you to treat a group of objects as a single

半整体的等级制度。它允许您将一组对象视为单个对象

object.

对象。

重点词汇


  • decouple 分离,隔断

  • incompatible 不一致,不相配 ; 合不来,不能和睦相处 ; 不匹配 ; 配伍禁忌的 ; 不兼容 ; 互斥的

  • work together 一起工作

  • decouples 分离,隔断 ; decouple的第三人称单数

  • abstractions 抽象概念 ; 抽象 ; 出神 ; 心神专注 ; 提取 ; 抽取 ; 分离 ; abstraction的复数

Decorator: This pattern permit extends a functionality of a class with flexibility,

Decorator:此模式允许灵活地扩展类的功能,

without use subclass. It allows you to dynamically attach a new responsibility to

没有use子类。它允许您动态地为

an object.

一个物体。赋予新的责任

Facade: This hides the complexity of the system, applying a unified interface to a

Facade:这隐藏了系统的复杂性,将统一的接口应用于

set of interfaces on a subsystem. This makes the subsystem easy to use.

子系统上的一组接口。这使得子系统易于使用。

最后

经过日积月累, 以下是小编归纳整理的深入了解Java虚拟机文档,希望可以帮助大家过关斩将顺利通过面试。
由于整个文档比较全面,内容比较多,篇幅不允许,下面以截图方式展示 。







由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!

由于整个文档比较全面,内容比较多,篇幅不允许,下面以截图方式展示 。

[外链图片转存中…(img-sHNXBSt4-1714126331389)]
[外链图片转存中…(img-b5m938nf-1714126331390)]
[外链图片转存中…(img-HW0TE7zB-1714126331390)]
[外链图片转存中…(img-7NLDhQyU-1714126331390)]
[外链图片转存中…(img-7gf0L9Sm-1714126331391)]
[外链图片转存中…(img-Vx11LFyw-1714126331391)]
[外链图片转存中…(img-RiXnPCJV-1714126331391)]

由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

  • 26
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值