知识库 知识库
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)

Jim FuckPPT

Java小学生
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)
  • Hyperskill - Java

    • Java basic

    • Java OOP

    • 应知

    • 扩展

    • IO & Stream

    • Error & Exception

    • Algorithm & Data structure

    • Design pattern

      • Theory:The concept of patterns
      • Theory:Structural of design patterns
        • What are structural design patterns?
        • Types of structural patterns
        • When to use structural patterns?
        • Conclusion
      • Theory:Decorator pattern
      • Theory:Decorator
    • Web

    • Spring boot

  • 练习题

  • Frank - Java与生活

  • Frank - Java API进阶

  • 学习笔记

  • Java
  • Hyperskill - Java
  • Design pattern
Jim
2022-10-12
目录

Theory:Structural of design patterns

While working with a large application, you will usually encounter problems related to the complexity of a code. This may disorient and complicate your work. So, to minimize these problems, you should define the proper class structure and their connections to each other. One useful way to maintain a good object structure is using a structural design pattern.

# What are structural design patterns?

Structural design patterns describe relations between the system's components. Like any other design pattern, structural patterns solve the most common design problems. Through them, you can ease the application design process, by introducing solutions for recurring problems of component structuring.

Simply put, structural patterns simplify the structure by defining the relationships between objects. Using these patterns, you will have a better understanding of whether we need to inherit, compose, or make and maintain any other relationships between system components.

# Types of structural patterns

There are 7 types of structural design patterns:

img

  • Adapter - as the name suggests, this pattern focuses on connecting objects with incompatible interfaces.
  • Bridge - this pattern separates abstraction and implementation of a class, allowing for their independent development.
  • Composite - a pattern that structures objects in a hierarchical fashion so that a client could work with each one of them.
  • Decorator - this pattern uses special wrapper objects for enhancement of object behavior without original object modification.
  • Facade - a pattern that provides an interface for a complex set of objects.
  • Flyweight - a pattern that increases the number of objects you can fit into memory by sharing and reusing their common parts.
  • Proxy - this pattern provides a substitute or placeholder for another complex object.

A variety of these design patterns allow for the formation of a larger structure. They define how each component should be structured so as to have very flexible interconnecting modules which can work together in a larger system.

# When to use structural patterns?

Here's the most basic description of these patterns applicability:

  • Adapter: use this when you want to use some existing class with an incompatible interface.
  • Bridge: use this pattern when you want to split larger classes and form structures that have several variants of some functionality.
  • Composite: apply this pattern when you want your client to work with different elements of a structure uniformly.
  • Decorator: use this pattern to add modifications to objects' behavior without interference to their code.
  • Facade: use this pattern to provide a simple and straightforward interface to a complex system.
  • Flyweight: apply this pattern to a project with a large number of objects to fit them all into your memory.
  • Proxy: this pattern has various implementation variants, from controlling user access to maintaining heavy resources in the background.

# Conclusion

As you can see, structural design patterns are a complex concept that contains quite a few solutions to common problems. Most of them are fairly easy to understand and implement. Nevertheless, design patterns tend to increase your code complexity. So you should keep in mind their limitations and goals to avoid overdoing it.

编辑 (opens new window)
#Pattern
上次更新: 2022/10/25, 17:57:56
Theory:The concept of patterns
Theory:Decorator pattern

← Theory:The concept of patterns Theory:Decorator pattern→

最近更新
01
《挪威的森林》
04-14
02
青钢影
04-14
03
Processing strings
02-18
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Jim Frank | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式