为什么要网络架构松耦合? [英] Why should a web architecture be loosely coupled?

查看:477
本文介绍了为什么要网络架构松耦合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我看到ASP.NET MVC项目,我每次看到松耦合的架构。

When I look at ASP.NET MVC projects I everytime see loose coupled architecture.

为了什么,我需要一个松散耦合的Web架构(如果我没有做单元测试)?

For what do I need a loose coupling in a web architecture (if I do not make unit tests)?

什么是的优点劣势的吗?

什么是主要的原因去耦层/班?

如果我不想有什么改变我的例如DAL?我的意思是我什么时候改变我的整个DAL?所以,我可以几个我DAL到用户界面。什么是坏的吗?

What if I do not want to change my DAL for example? I mean when shall I change my whole DAL?! So I could couple my DAL to the UI. What is bad with this?

推荐答案

这将节省您大量的时间,任何一个项目,是不是平凡的小,在那里我定义平凡的小小于一对夫妇千行$ C的$ C(取决于语言)。

It will save you a lot of time for any project that isn't trivially small, where I define trivially small as less than a couple thousand lines of code (depending on the language).

原因是,一旦你过去的超小型项目,每一个变化或更新变得更难更紧密耦合的是。被松耦合使你保持前进,增加功能,修复bug等。

The reason is that once you get past super small projects, each change or update gets harder the more tightly coupled it is. Being loosely coupled enables you to keep moving forward, adding features, fixing bugs, etc.

在某一点上我认为,任何程序变为维护,更新和添加到一个噩梦。越松散耦合的设计是,进一步的那点被延迟。如果它是紧耦合的,也许以后约10000 code将其变成不可维护的线路,增加了一些功能,而无需从头开始重写基本上变得不可能。

At a certain point I think any program becomes a nightmare to maintain, update and add on to. The more loosely coupled the design is, the further that point is delayed. If it's tightly coupled, maybe after about 10,000 lines of code it becomes unmaintainable, adding some features become impossible without essentially rewriting from scratch.

正在松耦合允许它成长至100万 - 10,000,000行code的同时仍然能够做出改变,并在合理的时间量内增加新的功能。

Being loosely coupled allows it to grow to 1,000,000 - 10,000,000 lines of code while still being able to make changes and add new features within a reasonable amount of time.

这些数字并不意味着字面因为他们只是做了,但给的,它成为有用之感。

These numbers aren't meant to be taken literally as they're just made up, but to give a sense of where it becomes helpful.

如果你永远需要更新程序,这是相当简单的话,当然,它的罚款紧密耦合。它甚至好以这种方式开始,但知道什么时候它的时间的东西分离出来,但你仍然需要的写作经验松耦合code知道在什么时候它变得有益。

If you never need to update the program and it's fairly simple then sure, it's fine to be tightly coupled. It's even okay to start that way but know when it's time to separate stuff out, but you still need experience writing loosely coupled code to know at what point it becomes beneficial.

企业Fizzbuzz 是怎样一个故意幽默的例子它可能与过度设计太过火,而不是每个项目都将需要脱钩的同等水平。

Enterprise Fizzbuzz is a intentionally humorous example of how it's possible to go overboard with overengineering, and not every project is going to need to same level of decoupling.

MVC通常被认为是一个很好的起点,因为大多数项目将成为足够大,它是有帮助的。当项目变大,解耦的该水平是不够的,在M部需要被分成几层本身,等等。有不是一个尺寸适合所有,但MVC是解耦大多数项目的一个良好的数额。

MVC is generally considered a good starting point because most projects will become big enough for it to be helpful. When the project gets bigger, that level of decoupling isn't enough and the M part needs to be split into several layers itself, and so forth. There isn't a one-size fit all, but MVC is a good amount of decoupling for most projects.

这篇关于为什么要网络架构松耦合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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