常州品牌网站建设免费文字变形logo设计

news/2025/10/6 10:19:08/文章来源:
常州品牌网站建设,免费文字变形logo设计,网站开发专业的建设设想,不属于网络虚拟财产在软件工程中#xff0c;设计模式是为了解决常见的软件设计问题而形成的一套经典解决方案。这些模式不仅能够帮助开发者提高设计的灵活性和代码的重用性#xff0c;还能使问题的解决方案更加清晰、易于理解。《设计模式精解#xff0d;GoF 23种设计模式》一书中所列举的23种…在软件工程中设计模式是为了解决常见的软件设计问题而形成的一套经典解决方案。这些模式不仅能够帮助开发者提高设计的灵活性和代码的重用性还能使问题的解决方案更加清晰、易于理解。《设计模式精解GoF 23种设计模式》一书中所列举的23种设计模式是由四位作者即GoFGang of Four提出的至今仍被广泛应用在各种软件开发项目中。本文将对这些设计模式进行全面解析每种模式均配以C代码示例旨在为读者提供一个清晰、系统的学习路径。 创建型模式Creational Patterns 创建型模式涉及对象的创建机制旨在创建对象时增加系统的灵活性和效率。 工厂模式Factory Pattern 工厂模式通过定义一个用于创建对象的接口让子类决定实例化哪一个类。这样的方式允许在不明确指定具体类的情况下创建对象。 class Product { public:virtual ~Product() {}virtual std::string Operation() const 0; };class ConcreteProduct1 : public Product { public:std::string Operation() const override {return Result of ConcreteProduct1;} };class Creator { public:virtual ~Creator(){}virtual Product* FactoryMethod() const 0;std::string SomeOperation() const {Product* product this-FactoryMethod();std::string result Creator: The same creators code has just worked with product-Operation();delete product;return result;} };抽象工厂模式Abstract Factory Pattern 抽象工厂模式提供一个接口用于创建相关或依赖对象的家族而不需要明确指定具体类。 class AbstractProductA { public:virtual ~AbstractProductA(){};virtual std::string UsefulFunctionA() const 0; };class AbstractProductB { public:virtual ~AbstractProductB(){};virtual std::string UsefulFunctionB() const 0;virtual std::string AnotherUsefulFunctionB(const AbstractProductA collaborator) const 0; };class ConcreteProductA1 : public AbstractProductA { public:std::string UsefulFunctionA() const override {return The result of the product A1.;} };class ConcreteProductB1 : public AbstractProductB { public:std::string UsefulFunctionB() const override {return The result of the product B1.;}std::string AnotherUsefulFunctionB(const AbstractProductA collaborator) const override {const std::string result collaborator.UsefulFunctionA();return The result of the B1 collaborating with ( result );} };单例模式Singleton Pattern 单例模式确保一个类只有一个实例并提供一个全局访问点。 class Singleton { protected:Singleton(const std::string value): value_(value) {}static Singleton* singleton_;std::string value_;public:Singleton(Singleton other) delete;void operator(const Singleton ) delete;static Singleton *GetInstance(const std::string value);std::string value() const{return value_;} };Singleton* Singleton::singleton_ nullptr;;Singleton *Singleton::GetInstance(const std::string value) {if(singleton_ nullptr){singleton_ new Singleton(value);}return singleton_; }建造者模式Builder Pattern 建造者模式使用多个简单的对象一步一步构建成一个复杂的对象。 class Product1 { public:std::vectorstd::string parts_;void ListParts()const {std::cout Product parts: ;for (size_t i 0; i parts_.size(); i) {if (parts_[i] parts_.back()) {std::cout parts_[i];} else {std::cout parts_[i] , ;}}std::cout \n\n;} };class Builder { public:virtual ~Builder() {}virtual void ProducePartA() const 0;virtual void ProducePartB() const 0;virtual void ProducePartC() const 0; };class ConcreteBuilder1 : public Builder { private:Product1* product;public:ConcreteBuilder1() {this-Reset();}~ConcreteBuilder1() {delete product;}void Reset() {this-product new Product1();}void ProducePartA()const override {this-product-parts_.push_back(PartA1);}void ProducePartB()const override {this-product-parts_.push_back(PartB1);}void ProducePartC()const override {this-product-parts_.push_back(PartC1);}Product1* GetProduct() {Product1* result this-product;this-Reset();return result;} };原型模式Prototype Pattern 原型模式使用原型实例指定创建对象的种类并且通过拷贝这些原型创建新的对象。 class Prototype { protected:std::string prototype_name_;float prototype_field_;public:Prototype() {}Prototype(std::string prototype_name): prototype_name_(prototype_name) {}virtual ~Prototype() {}virtual Prototype *clone() const 0;virtual void Method(float prototype_field) {this-prototype_field_ prototype_field;std::cout Call Method from this-prototype_name_ with field : this-prototype_field_ std::endl;} };class ConcretePrototype1 : public Prototype { private:float concrete_prototype_field1_;public:ConcretePrototype1(std::string prototype_name, float concrete_prototype_field): Prototype(prototype_name), concrete_prototype_field1_(concrete_prototype_field) {}Prototype *clone() const override {return new ConcretePrototype1(*this);} };class ConcretePrototype2 : public Prototype { private:float concrete_prototype_field2_;public:ConcretePrototype2(std::string prototype_name, float concrete_prototype_field): Prototype(prototype_name), concrete_prototype_field2_(concrete_prototype_field) {}Prototype *clone() const override {return new ConcretePrototype2(*this);} };结构型模式Structural Patterns 结构型模式关注于对象组合它们利用继承和接口的方式来组合接口或实现以提供新的功能。 桥接模式Bridge Pattern 桥接模式通过将抽象部分与实现部分分离使它们可以独立变化。 class Implementation { public:virtual ~Implementation() {}virtual std::string OperationImplementation() const 0; };class ConcreteImplementationA : public Implementation { public:std::string OperationImplementation() const override {return ConcreteImplementationA: Heres the result on the platform A.\n;} };class ConcreteImplementationB : public Implementation { public:std::string OperationImplementation() const override {return ConcreteImplementationB: Heres the result on the platform B.\n;} };class Abstraction { protected:Implementation* implementation_;public:Abstraction(Implementation* implementation) : implementation_(implementation) {}virtual ~Abstraction() {}virtual std::string Operation() const {return Abstraction: Base operation with:\n this-implementation_-OperationImplementation();} };class ExtendedAbstraction : public Abstraction { public:ExtendedAbstraction(Implementation* implementation) : Abstraction(implementation) {}std::string Operation() const override {return ExtendedAbstraction: Extended operation with:\n this-implementation_-OperationImplementation();} };适配器模式Adapter Pattern 适配器模式允许不兼容的接口之间的通信它通过将一个类的接口转换成客户期望的另一个接口来实现。 class Target { public:virtual ~Target() {}virtual std::string Request() const {return Target: The default targets behavior.;} };class Adaptee { public:std::string SpecificRequest() const {return .eetpadA eht fo roivaheb laicepS;} };class Adapter : public Target { private:Adaptee* adaptee_;public:Adapter(Adaptee* adaptee) : adaptee_(adaptee) {}std::string Request() const override {std::string to_reverse this-adaptee_-SpecificRequest();std::reverse(to_reverse.begin(), to_reverse.end());return Adapter: (TRANSLATED) to_reverse;} };装饰器模式Decorator Pattern 装饰器模式允许向一个现有的对象添加新的功能同时又不改变其结构。这种类型的设计模式属于结构型模式因为这种模式通过创建一个装饰类来包装原有的类。 class Component { public:virtual ~Component() {}virtual std::string Operation() const 0; };class ConcreteComponent : public Component { public:std::string Operation() const override {return ConcreteComponent;} };class Decorator : public Component { protected:Component* component_;public:Decorator(Component* component) : component_(component) {}std::string Operation() const override {return this-component_-Operation();} };class ConcreteDecoratorA : public Decorator { public:ConcreteDecoratorA(Component* component) : Decorator(component) {}std::string Operation() const override {return ConcreteDecoratorA( Decorator::Operation() );} };class ConcreteDecoratorB : public Decorator { public:ConcreteDecoratorB(Component* component) : Decorator(component) {}std::string Operation() const override {return ConcreteDecoratorB( Decorator::Operation() );} };组合模式Composite Pattern 组合模式允许将对象组合成树形结构以表示“部分-整体”的层次结构。组合模式使得用户对单个对象和组合对象的使用具有一致性。 class Component { protected:Component* parent_;public:virtual ~Component() {}void SetParent(Component* parent) {this-parent_ parent;}Component* GetParent() const {return this-parent_;}virtual void Add(Component* component) {}virtual void Remove(Component* component) {}virtual bool IsComposite() const {return false;}virtual std::string Operation() const 0; };class Leaf : public Component { public:std::string Operation() const override {return Leaf;} };class Composite : public Component { protected:std::listComponent* children_;public:void Add(Component* component) override {this-children_.push_back(component);component-SetParent(this);}void Remove(Component* component) override {children_.remove(component);component-SetParent(nullptr);}bool IsComposite() const override {return true;}std::string Operation() const override {std::string result;for (const Component* c : children_) {if (c children_.back()) {result c-Operation();} else {result c-Operation() ;}}return Branch( result );} };享元模式Flyweight Pattern 享元模式是对象池的一种实现它用于减少创建对象的数量以减少内存占用和提高性能。这种类型的设计模式属于结构型模式因为该模式提供了减少对象数量从而改善应用所需的对象结构的方式。 class Flyweight { protected:std::string shared_state_;public:Flyweight(const std::string shared_state) : shared_state_(shared_state) {}virtual ~Flyweight() {}virtual void Operation(const std::string unique_state) const {std::cout Flyweight: Displaying shared ( this-shared_state_ ) and unique ( unique_state ) state.\n;} };class FlyweightFactory { private:std::unordered_mapstd::string, Flyweight* flyweights_;std::string GetKey(const std::vectorstd::string state) const {std::string key;for (const std::string s : state) {key s;}return key;}public:FlyweightFactory(const std::vectorstd::string initial_flyweights) {for (const std::string state : initial_flyweights) {this-flyweights_.insert(std::make_pairstd::string, Flyweight*(this-GetKey({state}), new Flyweight(state)));}}~FlyweightFactory() {for (auto pair : this-flyweights_) {delete pair.second;}this-flyweights_.clear();}Flyweight* GetFlyweight(const std::vectorstd::string shared_state) {std::string key this-GetKey(shared_state);if (this-flyweights_.find(key) this-flyweights_.end()) {std::cout FlyweightFactory: Cant find a flyweight, creating new one.\n;this-flyweights_.insert(std::make_pair(key, new Flyweight(key)));} else {std::cout FlyweightFactory: Reusing existing flyweight.\n;}return this-flyweights_.at(key);}void ListFlyweights() const {size_t count this-flyweights_.size();std::cout \nFlyweightFactory: I have count flyweights:\n;for (auto pair : this-flyweights_) {std::cout pair.first \n;}} };外观模式Facade Pattern 外观模式提供了一个统一的接口用来访问子系统中的一群接口。外观定义了一个高层接口让子系统更容易使用。 class Subsystem1 { public:std::string Operation1() const {return Subsystem1: Ready!\n;}std::string OperationN() const {return Subsystem1: Go!\n;} };class Subsystem2 { public:std::string Operation1() const {return Subsystem2: Get ready!\n;}std::string OperationZ() const {return Subsystem2: Fire!\n;} };class Facade { protected:Subsystem1* subsystem1_;Subsystem2* subsystem2_;public:Facade(Subsystem1* subsystem1 nullptr,Subsystem2* subsystem2 nullptr) {

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/929206.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

毕业设计 网站开发简单吗蘑菇街网站模板

最近偶尔有用户反馈某些 HTTP 接口出现超时问题,而 web 服务端的 Trace 监控没有出现 http 返回值为 503 等异常情况。出现这种情况一般是web容器出现问题,客户端连 Arthas是Alibaba开源的Java诊断工具,深受开发者喜爱。 Github:h…

鸿蒙OS基于UniApp的区块链钱包创建实践:打造支持鸿蒙生态的Web3应用#三方框架 #Uniapp

鸿蒙OS&基于UniApp的区块链钱包创建实践:打造支持鸿蒙生态的Web3应用#三方框架 #Uniapppre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !impor…

CF700E

题目大意: 给定一个长为 \(n\) 的字符串 \(S\),你要找到最大的 \(k\),使得存在 \(s_{1} \sim s_{k}\) 使得 \(s_{1}\) 是 \(S\) 子串 且 \(s_{i}\) 在 \(s_{i - 1}\) 中作为子串至少出现两次。 \(n \le 2 \times 10…

价值弥漫:“AI元人文”的场域革命与共生之路

价值弥漫:“AI元人文”的场域革命与共生之路 本文探讨“价值弥漫”作为“AI元人文”核心实现路径的哲学基础与技术内涵,提出从“工具性AI”到“场域性AI”的范式转变。 引言:从“价值对齐”到“价值弥漫”的范式迁移…

手机app设计网站公司网站建设需要什么科目

流程图 一、前期准备 1.1 打开百度智能云官网找到管理中心创建应用 全选文字识别 1.2 保存好AppId、API Key和Secret Key 1.3 找到通用场景文字识别,立即使用 1.4 根据自己需要,选择要开通的项目 二、代码编写 以通用文字识别(高精度版&am…

k8s之pod概念

1. pod基本概念 2. pod网络概念 3. pod的生命周期和状态 4. 探针 5. 创建pod 6. 总结‍ 1. pod基本概念Kubernetes 中,Pod 是最小的网络调度单位, 每个pod可以放多个容器(例如可以放多个docke容器在同一个pod中运行…

鸿蒙版Taro 搭建开发环境 - 教程

鸿蒙版Taro 搭建开发环境 - 教程2025-10-06 10:09 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !import…

CF 1055 Div.1+Div.2

F - Triple Attack 我会了。 G - Query Jungle 我会了。 H1 - Victorious Coloring (Easy Version) 我不会。 H2 - Victorious Coloring (Hard Version) 我不会。

LUCKY STUN穿透在Windows上使用UPnP工具为BT客户端自动添加内外端口号不同的映射规则

LUCKY STUN穿透在Windows上使用UPnP工具为BT客户端自动添加内外端口号不同的映射规则2024.02.07 关于本教程 本教程基于:基于stun穿透工具LUCKY,使BT客户端绿灯、开放TCP端口的办法(进化版) 在该教程中实现了使用 …

深圳门户网站制作wordpress 鼠标特效

摘要: 4月30日,阿里云发现,俄罗斯黑客利用Hadoop Yarn资源管理系统REST API未授权访问漏洞进行攻击。 Hadoop是一款由Apache基金会推出的分布式系统框架,它通过著名的 MapReduce 算法进行分布式处理,Yarn是Hadoop集群的…

2026 NOI 做题记录(五)

推荐阅读:A、B、E、F、N、O、R、T、U、WContest Link \(\text{By DaiRuiChen007}\)*A. [CF2097F] Lost Luggage (7.5) Problem Link 先建立网络流,每层的点 \(i\) 向下一层 \(i-1,i,i+1\) 分别连权值 \(a_i,b_i,c_i\…

ARC 207 (Div.1)

A - Affinity for Artifacts 我不会。我会了。 B - Balanced Neighbors 2然后 \(n\leq 5\) 无解。 C - Combine to Make Non-decreasing 容易发现原题目等价于将原序列分成若干段,要求段之间的 \(\text{OR}\) 值 non-…

四大门户网站的区别深圳营销型网站定制

教师资格认定前需要做的准备材料 准备身份证户口本 居住证 学生证 教师考试合格证明 普通话证书 学历证书 体检合格证书 近期一寸白底证件照 网上报名 河南24下教资认定 网上报名时间:10月21日-11月1日 现场确认 网上审核未通过的宝子,需要…

“齐俊杰投资智能体”更新完了9月份的资料

“齐俊杰投资智能体”更新完了9月份的资料,本次更新包括了9月份的课程和粉丝群问答,读书更新了这几本:明斯基时刻。每日问答的语音转文字已经使用了AI进行格式优化,更加容易阅读。将新资料更新到了智能体,大家可以…

联想电脑护眼卫士与系统颜色配置(X-Rite)冲突 | 显示设置频繁变换色阶 - 解决方案 - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

(转载)无人机飞行模式全面解析

(转载)无人机飞行模式全面解析原文地址: https://baijiahao.baidu.com/s?id=1822706539478215889飞行模式详解 自稳模式: 在自稳模式下,飞手通过操作roll与pitch摇杆来控制飞行器的倾斜角度。一旦飞手松开这些摇…

html官方网站建站系统cms是什么

tcp长连接和保活时间TCP协议中有长连接和短连接之分。短连接在数据包发送完成后就会自己断开,长连接在发包完毕后,会在一定的时间内保持连接,即我们通常所说的Keepalive(存活定时器)功能。 www.2cto.com 默认的Keepa…

河北雄安建设投资集团网站微网站免费搭建平台

来源:专知 摘要对话系统是一个流行的自然语言处理(NLP)任务,因为它在现实生活中应用前景广阔。这也是一个复杂的任务,因为涉及到许多需要研究的自然语言处理任务。因此,关于深度学习的对话系统研究的大量工作开展了。在这个综述中…

网站建设怎么上传数据微信小程序设计软件

写在前面 内部审计是一种独立的、客观的确认和咨询活动,包括鉴证、识别和分析问题以及提供管理建议和解决方案。狭义的数字化转型是指将企业经营管理和业务操作的各种行为、状态和结果用数字的形式来记录和存储,据此再对数据进行挖掘、分析和应用。广义…

InstructGPT 论文略读:三步走,让大模型真正听懂人话

InstructGPT 论文略读:三步走,让大模型真正听懂人话InstructGPT 论文略读:三步走,让大模型真正听懂人话 摘要 (Introduction) 大语言模型(LLM),如 GPT-3,无疑开启了自然语言处理的新纪元。它们强大的零样本和少…