首页 > 其他分享 >创建型设计模式

创建型设计模式

时间:2023-06-03 21:33:33浏览次数:51  
标签:creation 创建 object objects Design Pattern 设计模式 Creational

The Creational Design Pattern are Categorized into two types.

  •  Object-Creational Patterns: Object -Creational Patterns deal with object creation. Here, it defers part of its object creation to another object.
  • Class-Creational Patterns:Class-Creational Patterns deal with class Instantiation. Here, it defers its object creation to subclasses.

In real-time applications, the project is created with a lot of classes. A lot of classes mean we are dealing with a lot of objects. So, we need to create different objects for an ECommerce Application. If the object creation logic based on some condition is implemented in the client code, then it leads to lots of complicated logic in the client code.

That means if the object creation and initialization logic are not centralized, then it leads to a very complicated client code.The creational design pattern help us to centralize the object creation and initialization logic and depending upon the condition, it wil create, initialize, and returns the approciatte object to the client,and then teh client can consume the object by calling the necessary method and properties.

 

Creational Desgin Pattern IN C#:

  • Factory Design Pattern: A factory is an object which is used for creating other objects.The Factory Method Design Pattern defines an interface for creating an object, but let the subclasses decide which class to instantiate, This pattern let a class defer instantiation to subclasses.
  • Abstract Factory Design Pattern: The Abstract Factory Design Pattern provides a way to encapsualte a group of individual factories that have a common theme without specifying their concrete classes.
  • Single Design Pattern: The Singleton Design Pattern ensures a class has only one instance and provide a global point of access to it.
  • Builder Design Pattern: The Builder Design Pattern separates the construction of a complex object from its representation so that the same construction process can create diferrent representations.
  • Fluent Interface Design Pattern: The Fluent interfaces and Method Chaining are related to each other. Or we can say that one is a concept and the other one is implementation.The main objective of the Fluent Interface Design Pattern is that we can apply multiple properties(or methods) to an object by connecting them with dots(.) without having to re-specify the object name each time.
  • Prototype Design Pattern: The prototyp design pattern specifies the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.

 

标签:creation,创建,object,objects,Design,Pattern,设计模式,Creational
From: https://www.cnblogs.com/qindy/p/17449779.html

相关文章

  • File类:对象的创建
         ......
  • 使用Django创建一个项目
    ......
  • 3月25日邓老师设计模式面试资料02
    Spring面试专题1.Spring应该很熟悉吧?来介绍下你的Spring的理解  有些同学可能会抢答,不熟悉!!!  好了,不开玩笑,面对这个问题我们应该怎么来回答呢?我们给大家梳理这个几个维度来回答1.1Spring的发展历程  先介绍Spring是怎么来的,发展中有哪些核心的节点,当前的最新版本是......
  • 2、利用安装好的虚拟机创建新的虚拟机(克隆现有虚拟机)
    利用安装好的虚拟机创建新的虚拟机(克隆现有虚拟机)利用virt-install实现利用virt-manager实现利用virt-clone克隆实现方法一:利用virt-install实现把磁盘文件拷到需要创建虚拟机的位置[root@rocky8~]#cd/var/lib/libvirt/images/[root@rocky8images]#lsrocky8.qcow2拷贝虚......
  • 大话设计模式之单例,策略,简单工厂
    基于实际面试题实现importjava.util.HashMap;importjava.util.Map;importjava.util.Random;/***用java设计一个机房环境监测系统的代码框架,机房有多种传感器,可以实时检测机房的温度、湿度、噪音等数据,*并把数据实时发送到监控中心,其中某项数据超过不健康阈值立即上......
  • JDK 8新特性:Stream流的创建
         ......
  • 1、KVM安装部署及virt-manager图形化工具创建安装虚拟机、命令行工具virt-install创建
    KVM安装部署KVM做单机管理虚拟机,Openstack集群管理虚拟机docker单机管理容器,k8s集群管理容器宿主机环境准备在vmware安装linux系统,并在设置中开启虚拟化CPU开启虚拟化一:开启虚拟化引擎两项内容二:提高内存和处理器至8G验证开启虚拟化grep-Em1"vmx|svm"/proc/cpuinfoInt......
  • 关于MySQL数据库的索引的作用及如何创建?
    一、创建索引的作用?原因:创建索引可以大大提高系统的性能。第一,通过创建唯一性索引,可以保证数据库表中每一行数据的唯一性。第二,可以大大加快数据的检索速度,这也是创建索引的最主要的原因。第三,可以加速表和表之间的连接,特别是在实现数据的参考完整性方面特别有意义。第四,在使用分......
  • 基于LVM方式创建的swap分区的缩减记录
    场景:关于Linux系统下,需要将swap分区的大小由128GB,缩减调整到32GB(swap分区是一个LVM格式的分区)操作系统:RedHatEnterpriseLinuxServerrelease7.9(Maipo) 1、先看一下现状,当前系统是有占用swap分区的:[root@qq-5201351~]#free-mtotalused......
  • 常用的创建虚拟驱动器软件包括以下几个
    常用的创建虚拟驱动器软件包括以下几个:DAEMONToolsLite:DAEMONToolsLite是一个功能强大的虚拟光驱工具,可以模拟光盘、硬盘和网络驱动器等。该软件支持多种文件格式的虚拟驱动器,如ISO、CUE/BIN、MDS/MDF等。WinISO:WinISO是一个全能的光盘映像文件处理工具,支持创建、编......