问题描述
如何解释松散的耦合和信息隐藏到一个新的程序员?我有一个程序员谁写的设计,但谁似乎不能把握松散耦合和信息隐藏的概念。
How do I explain loose coupling and information hiding to a new programmer? I have a programmer who I write designs for, but who can't seem to grasp the concepts of loose coupling and information hiding.
我将按照功能完美地分解成类的设计(数据访问是分开的,一个请求类,一个控制器,总共约5个类)。他们回来了一个修改后的设计,其中一半的类从另一半继承(并没有is-a关系)和许多公共变量。
I write designs with everything nicely broken down into classes by function (data access is separate, a class for requests, a controller, about 5 classes total). They come back with a modified design where half the classes inherit from the other half (and there is no "is-a" relationship), and many public variables.
我如何看待将事情分开的想法更容易维护?
How can I get across the idea that keeping things separate makes it easier to maintain?
推荐答案
解释这些概念的最好方法是使用类比。选择非编程相关的东西,并使用它来解释抽象设计概念。
The best way to explain these kinds of concepts is to use analogies. Pick something non-programming related and use that to explain the abstract design concepts.
以下图像非常适合解释松耦合的需要:
The following image is pretty good at explaining the need for loose coupling:
尝试提出这样的东西,这将有趣和适合你的新程序员。
Try to come up with stuff like this that will amuse and pertain to your new programmer.
这篇关于如何解释松散的耦合和信息隐藏到一个新的程序员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!