[设计模式]--Design Patterns Explained学习笔记[chap4]

探讨了在CAD/CAM系统中使用面向对象技术创建信息提取系统的基本设计方案,旨在为不同版本提供统一接口,但该方案存在冗余、紧耦合等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4 A Standard Object-Oriented Solution

根据第三章的问题描述,如何创建一个信息提取系统对于不同的CAD/CAM系统都可以工作,而且为客户对象提供一致的接口,本章采用OO技术设计了一个初步的解决方案,它虽然可行但是却失去了灵活性。

对于slot(同样适用于其他类型)来说,创建一个SlotFeature类,根据CAD/CAM系统版本的不同再分别为其派生V1SlotV2Slot类。引入其他类型如cutouthole等,再创建一个Feature类,让包括SlotFeature在内的所有特征类都从其继承(相关图形见书P63),这种实现方式(并未采用多态的方式,因为不需要改变专家系统而只需要在CAD/CAM系统中添加相应的模块特征类就可以满足需求)能够满足系统的需求,然而这并不是一个好的方案,缺点如下:

1、冗余的方法――即很多方法其实内部实现相似,根本没有必要写这么多方法造成理解繁杂;

2、表现混乱;

3、紧耦合性――由于各个特征类直接关联,造成系统的改变困难;

4、弱内聚性――表现各个核心功能的函数(方法)分布在各个类中。

另外一个严重问题是当系统中加入新的模块时,或者说加入新的版本后,类的数目将大量增加,难以管理,因此本方案绝不是一个令人满意的方案。

 
If you have ever bought any programming books, you might have noticed that there are two types of them: books that are too short to understand the topic and books that are too long making it inevitable that you get bored. We've tried hard to avoid both of these categories with Design Patterns Explained Simply. This book is fast and simple way to get the idea behind each of the 29 popular design patterns. The book is not tied to any specific programming language and will be good for you as long as you have a basic knowledge of OOP. Most chapters are available on the website, so you can check out the simplicity of the language in the book and the way materials are presented. Why should I read this book? It's simple. It's written in clear and simple language that makes it easy to read and understand. It's short. Yes, there are no useless demos or huge code listings — just clear and easy-to-understand descriptions with many graphical examples. When you finish reading this book, you'll have good reason to go to your boss and ask him for apromotion. Why? Because using design patterns will allow you to get your tasks done twice as fast, to write better code and to create efficient and reliable software architecture. How do I become a programming ninja? The main difference between a ninja and a novice is the knowledge of secret coding tricks, as well as the awareness of most pitfalls and the ability to avoid them. Design patterns were created as a bible for avoiding problems related to software design. Doesn’t that make it a true ninja’s handbook? Table of Contents Creational patterns Abstract Factory Builder Factory Method Object Pool Prototype Singleton Structural patterns Adapter Bridge Composite Decorator Facade Flyweight Private Class Data Proxy Behavioral patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Null Object Observer State Strategy Template Method Visitor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值