我应该选择什么设计模式? [英] What design pattern should I choose?

查看:247
本文介绍了我应该选择什么设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想为驱动程序设计导航系统GUI。

If I want to design a navigation system GUI for drivers.

导航系统的GUI由三个组件组成:
A.地图,可以是卫星地图或地图地图
B.目的地位置:声音或文字位置
C.方向。可以是语音或文本

The GUI of the navigation system consists of three components: A. Map, can be either a satellite map or land Map B. Destination Location: voice or text location C. directions. Can be either voice or text

系统工作在两种模式:
1.文本模式:地图,文本位置和文字方向
2语音模式:卫星地图,语音目的地和语音路线

The system works in two modes: 1. Text Mode: land map, text location and text directions 2. Voice Mode: satellite map, voice destination, and voice directions

哪种设计模式更好地选择这种情况,你认为抽象工厂是否合适? / p>

Which design pattern better to choose for this situation, do you think that the abstract factory will be appropriate?

推荐答案

我将以某种方式回答这个问题,拒绝回答。因为你提出错误的问题

I'm going to answer this question, in a way, by refusing to answer it. Because you're asking the wrong question.

设计模式是一种对您编写的代码中的各种可识别的um模式进行分类的方法,以便更容易地讨论和比较不同的代码段。他们不是你开始使用的东西。你今天不要坐下去,我要使用Fuzzbuzzle Pattern。当你这样做,你不必要地限制自己的设计,甚至编写任何代码,这是完全有效的。这样做没有任何好处。

Design patterns are a way of categorising various identifiable, um, patterns in code that you write, so as to more easily discuss and compare different pieces of code. They are not something that you set out to use. You don't sit down and go "today, I am going to use the Fuzzlebuzzle Pattern". When you do that, you needlessly constrain yourself to a design before you've even written any code, which is entirely counter-productive. There is simply no benefit to doing so.

只需构建和设计软件,便于阅读和维护,使用您可以使用的抽象和工具。 然后,或许,分析一下,了解您是否已经使用任何现有的设计模式。 但是否则不要担心它

Just architect and design your software so that it is easy to read and to maintain, using the abstractions and tools at your disposal. Then, perhaps, analyse it and find out whether you've ended up using any existing design patterns. But otherwise just don't worry about it.

您的计算机程序中的用户可以看到哪些GUI元素的细节,以及用户是否能够运行语音命令,这完全与此无关。

The details of what GUI elements will be visible to users in your computer program, and whether your users will be able to run voice commands, are totally irrelevant to this.

这篇关于我应该选择什么设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆