Design Patterns (Factory, Abstract Factory, singleton, DAO, Proxy):

1. Factory: In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

2. Abstract Factory: Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories. In Abstract Factory pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes. Each generated factory can give the objects as per the Factory pattern.

3.Singleton: This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.

4.Builder: A Builder class builds the final object step by step. This builder is independent of other objects.

5. Prototype: This pattern involves implementing a prototype interface which tells to create a clone of the current object. This pattern is used when creation of object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database calls.

6.Adapter: Adapter pattern works as a bridge between two incompatible interfaces. A single class which is responsible to join functionalities of independent or incompatible interfaces.

7. Bridge: Bridge is used when we need to decouple an abstraction from its implementation so that the two can vary independently.

8. Filter pattern or Criteria pattern: is a design pattern that enables developers to filter a set of objects using different criteria and chaining them in a decoupled way through logical operations.

9.Decorator pattern allows a user to add new functionality to an existing object without altering its structure.

10.Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under structural pattern as this pattern adds an interface to existing system to hide its complexities.

11. In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern. In proxy pattern, we create object having original object to interface its functionality to outer world.

12.chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request.

13.Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services.

个人分析:

1.Factory,AbstractFactory 还有 Singleton 都是生成对象的设计模式

工厂是放入参数,通过接口产生对象,封装内部的生成的过程

抽象工厂是生成工厂的工厂,是工厂类的父类,可以抽象为接口,根据不同的类来实现不同的工厂。

单例模式是通过单例方法直接生成一个唯一的对象,并且不需要初始化对象就可以使用

2. builder和prototype

builder的实际意义就是通过一步一步生成的模式最终建立一个对象,例如stringbuilder

prototype是克隆一个原来有的对象,将原先对象保存起来,可以在克隆出来的对象进行操作再返回,也可以直接返回克隆的对象

3. adapter, bridge,filter

adapter:两个不相同接口相互适应

bridge: decoupling

filter:设置标准,过滤掉一些对象,

4.Decorator,Facade

Decorator:在不改变原来对象的前提下,建立一个新的对象,

Facde: 通过接口隐藏复杂的程序逻辑,值给用户暴露一个封装好的内容

5. In proxy pattern,chain of responsibility pattern

proxy:代理模式,创建一个对象来集成原来的对象,并且通过原来的对象与外部世界进行交互

chain of responsibility: 由一系列的发送者和接收者连接而成,并且在处理请求的时候并不知道发送者是谁。

Java review-design pattern的更多相关文章

  1. [Java] Design Pattern:Code Shape - manage your code shape

    [Java] Design Pattern:Code Shape - manage your code shape Code Shape Design Pattern Here I will intr ...

  2. Template Method Design Pattern in Java

    Template Method is a behavioral design pattern and it’s used to create a method stub and deferring s ...

  3. java设计模式大全 Design pattern samples in Java(最经典最全的资料)

    java设计模式大全 Design pattern samples in Java(最经典最全的资料) 2015年06月19日 13:10:58 阅读数:11100 Design pattern sa ...

  4. java design pattern - adapter pattern

    场景 适配器模式 总结 参考资料 场景 在编程中我们经常会遇到驴头不对马嘴的情况,比如以前是继承A的接口的对象,现在外部调用的时候需要该对象已B接口的形式来调用 ,这个时候我们可以让对象同时集成A和B ...

  5. [转]Design Pattern Interview Questions - Part 4

    Bridge Pattern, Composite Pattern, Decorator Pattern, Facade Pattern, COR Pattern, Proxy Pattern, te ...

  6. [转]Design Pattern Interview Questions - Part 2

    Interpeter , Iterator , Mediator , Memento and Observer design patterns. (I) what is Interpreter pat ...

  7. [转]Design Pattern Interview Questions - Part 1

    Factory, Abstract factory, prototype pattern (B) What are design patterns? (A) Can you explain facto ...

  8. Design Pattern: Observer Pattern

    1. Brief 一直对Observer Pattern和Pub/Sub Pattern有所混淆,下面打算通过这两篇Blog来梳理这两种模式.若有纰漏请大家指正. 2. Use Case 首先我们来面 ...

  9. design pattern及其使用

    什么是设计模式? design pattern是一个通用的,可以被重用的关于一个常见的问题的解决方案. 为什么要用设计模式? 引入设计模式的理论基础非常简单.我们每天都会碰到问题.我们可能碰到决定使用 ...

  10. Design Pattern —— Singleton

    Design Pattern —— Singleton   强力推荐枚举和类级内部类方式实现单例模式 单例模式是开发中非常常用的一种模式,简单的说,我们希望一个类永远都只有一个对象. 主要有两个用途: ...

随机推荐

  1. C++:多线程001

    C++ 多线程 创建线程的API函数 HANDLE CreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes,//SD:线程安全相关的属性,常置为N ...

  2. github和gitlab仓库一起使用

    github是网络公有代码仓库,一般用于私人代码托管,而gitlab一般是企业搭建的内部代码仓库.工作期间,我们都会同时用到这两个仓库.可公司邮箱与个人邮箱是不同的,由此产生的 SSH key 也是不 ...

  3. 洛谷P4550 【收集邮票】

    题目链接: 神仙题QAQ 题目分析: 概率期望题是不可能会的,一辈子都不可能会的QAQ 这个题也太仙了 首先明确一下题意里面我感觉没太说清楚的地方,这里是抽到第\(i\)次要\(i\)元钱,不是抽到第 ...

  4. [洛谷P1966] 火柴排队

    题目链接: 火柴排队 题目分析: 感觉比较顺理成章地就能推出来?似乎是个一眼题 交换的话多半会往逆序对上面想,然后题目给那个式子就是拿来吓人的根本没有卵用 唯一的用处大概是告诉你考虑贪心一波,很显然有 ...

  5. Docker这个新软件究竟是用来干嘛的???

    http://dockone.io/article/378 尝试新软件 对开发者而言,每天会催生出的各式各样的新技术都需要尝试,然而开发者却不太可能为他们一一搭建好环境并进行测试.时间非常宝贵,正是得 ...

  6. python基础-基础知识考试_day5 (包括:函数_递归等知识)

    老男孩 Python 基础知识练习(三) 1.列举布尔值为 False 的值空,None,0, False, '', [], {}, () 2.写函数:根据范围获取其中 3 和 7 整除的所有数的和, ...

  7. 线性SVM分类器实战

    1 概述 基础的理论知识参考线性SVM与Softmax分类器. 代码实现环境:python3 2 数据处理 2.1 加载数据集 将原始数据集放入"data/cifar10/"文件夹 ...

  8. 近期开发storm遇到一些问题的解决点

    storm开发解决问题点1.kafka消费速度跟不上问题 这个问题可以从加大topic partition进行解决,可以在topic正在运行时候运行命令 ./kafka-topics --alter ...

  9. 08.Hibernate的一级缓存-->>Session

    Hibernate提供了两种缓存: 1.一级缓存:自带的不可卸载的,一级缓存的生命周期与Session一致,一级缓存成为Session级别的缓存 2.二级缓存:默认没有开启,需要手动配置才可以使用,二 ...

  10. 安卓自定义View进阶-Canvas之画布操作 转载

    安卓自定义View进阶-Canvas之画布操作 转载 https://www.gcssloop.com/customview/Canvas_Convert 本来想把画布操作放到后面部分的,但是发现很多 ...