what s the matter____the shirt?

oop - what is the difference between loose coupling and tight coupling in object oriented paradigm? - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
Can any one describe the exact difference between loose coupling and tight coupling in Object oriented paradigm?
4,31931530
1,46631630
Tight coupling is when a group of classes are highly dependent on one another.
This scenario arises when a class assumes too many responsibilities, or when one concern is spread over many classes rather than having its own class.
Loose coupling is achieved by means of a design that promotes single-responsibility and separation of concerns.
A loosely-coupled class can be consumed and tested independently of other (concrete) classes.
Interfaces are a powerful tool to use for decoupling. Classes can communicate through interfaces rather than other concrete classes, and any class can be on the other end of that communication simply by implementing the interface.
Example of tight coupling:
class CustomerRepository
private readonly D
public CustomerRepository(Database database)
this.database =
public void Add(string CustomerName)
database.AddRow("Customer", CustomerName);
class Database
public void AddRow(string Table, string Value)
Example of loose coupling:
class CustomerRepository
private readonly ID
public CustomerRepository(IDatabase database)
this.database =
public void Add(string CustomerName)
database.AddRow("Customer", CustomerName);
interface IDatabase
void AddRow(string Table, string Value);
class Database : IDatabase
public void AddRow(string Table, string Value)
Another example .
11.5k2697165
In object oriented design, the amount of coupling refers to how much the design of one class depends on the design of another class. In other words, how often do changes in class A force related changes in class B? Tight coupling means the two classes often change together, loose coupling means they are mostly independent. In general, loose coupling is recommended because it's easier to test and maintain.
You may find
In general Tight Coupling is bad in but most of the time, because it reduces flexibility and re-usability of code, it makes changes much more difficult, it impedes testability etc.
Tightly Coupled Object is an object need to know quite a bit about each other and are usually highly dependent on each other interfaces. Changing one object in a tightly coupled application often requires changes to a number of other objects, In small application we can easily identify the changes and there is less chance to miss anything. But in large applications these inter-dependencies are not always known by every programmer or chance is there to miss changes. But each set of loosely coupled objects are not dependent on others.
In short we can say, loose coupling is a design goal that seeks to reduce the interdependencies between components of a system with the goal of reducing the risk that changes in one component will require changes in any other component. Loose coupling is a much more generic concept intended to increase the flexibility of a system, make it more maintainable, and make the entire framework more 'stable'.
Coupling refers to the degree of direct knowledge that one element has of another. we can say an eg: A and B, only B change its behavior only when A change its behavior.
A loosely coupled system can be easily broken down into definable elements.
When two objects are loosely coupled, they can interact but have very little knowledge of
each other.
Loosely coupled designs allow us to build flexible OO systems that can handle change.
Observer design pattern is a good example for making classes loosely coupled, you can have a look on it in .
23.3k104969
The way I understand it is, that tightly coupled architecture does not provide a lot of flexibility for change when compared to loosely coupled architecture.
But in case of loosely coupled architectures, message formats or operating platforms or revamping the business logic does not impact the other end. If the system is taken down for a revamp, of course the other end will not be able to access the service for a while but other than that, the unchanged end can resume message exchange as it was before the revamp.
There are certain tools that provide dependency injection through their library, for example in .net we have
If you are going further in java then
provides this capabilities.
Loosly coupled objects can be made by introducing Interfaces in your code, thats what these sources do.
Say in your code you are writing
Myclass m = new Myclass();
now this statement in your method says that you are dependent on myclass this is called a tightly coupled. Now you provide some constructor injection , or property injection and instantiating object then it will become loosly coupled.
151k68281360
1,41921221
Program wise Differance between Tight Coupling and Loose Coupling ?
Tight Coupling Between Java Objects
class Traveler
Car c=new Car();
void startJourney()
void move()
// logic...
Loose Coupling Between Java Objects
class Traveler
public void setV(Vehicle v)
void startJourney()
//=========================Interface====================================
Interface Vehicle
void move();
//====================Multiple class implement vehicle interface. First class====
class Car implements Vehicle
public void move()
//===================Second class================
class Bike implements Vehicle
public void move()
Simple explanation:
tight coupling
Think of your skin. It's stuck to your body. It fits like a glove. But what if you wanted to change your skin colour from say white to black? Can you imagine just how painful it would be to peel off your skin, dye it, and then to paste it back on etc? Changing your skin is difficult because it is tightly coupled to your body. You just can't make changes easily. You would have to fundamentally redesign a human being in order to make this possible.
God was not a good object orientated programmer.
loose coupling
Now think of getting dressed in the morning. You don't like blue? No problems: you can put a red shirt on instead. You can do this easily and effortlessly because the shirt is not really connected to your body the same way as your skin. The shirt doesn't know or care about what body it is going on. Clothes can easily and painlessly be changed. Perfect example of loose coupling.
Now if you read the above explanations, it should make more sense to you.
I hope this helps! Because I thought long and hard about how to explain it so that anybody can understand the basic concept :P
Loose coupling is and answer to to old style hardcoded dependencies and related issues issues like frequent recompilation when anything changes and code reuse. It stresses on implementing the worker logic in components and avoiding solution specific wire up code there.
Loose Coupling =
for easier explanation.
An extract from my
on coupling:
What is Tight Coupling:-
As par above definition a Tightly Coupled Object is an object that needs to know about other objects and are usually highly dependent on each other's interfaces.
When we change one object in a tightly coupled application often it requires changes to a number of other objects. There is no problem in a small application we can easily identify the change. But in the case of a large applications these inter-dependencies are not always known by every consumer or other developers or there is many chance of future changes.
Let’s take a shopping cart demo code to understand the tight coupling:
namespace DNSLooseCoupling
public class ShoppingCart
public float P
public int Q
public float GetRowItemTotal()
return Price * Q
public class ShoppingCartContents
public ShoppingCart[]
public float GetCartItemsTotal()
float cartTotal = 0;
foreach (ShoppingCart item in items)
cartTotal += item.GetRowItemTotal();
return cartT
public class Order
private ShoppingCartC
private float salesT
public Order(ShoppingCartContents cart, float salesTax)
this.cart =
this.salesTax = salesT
public float OrderTotal()
return cart.GetCartItemsTotal() * (2.0f + salesTax);
Problems with the above example
Tight Coupling creates some difficulties.
Here, OrderTotal() methods is give us complete amount for the current items of the carts. If we want to add the discount features in this cart system. It is very hard to do in above code because we have to make changes at every class as it is very tightly coupled.
3,015135399
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledwhat the size is the shirt?what is the price of the blouse 这两句话对吗,第一句话要第一个the吗
似水流年Wa5
答案:【两个the都要】解析;the size 特指哪一个码数,the shirt 特指哪一件衬衫.【你的10分满意,我们团队的无限动力】
为您推荐:
其他类似问题
你好!更准确的表达参考如下:What's the size of the shirt?what is the price of the blouse?= How much is the bouse? 百度教育团队【海纳百川团】为您解答如满意,请点击“选为满意答案”按钮,谢谢~
扫描下载二维码Cad & The Dandy | Bespoke Suits | Tailored Suits | Wedding Suits | Shirts | Made to Measure Suits
- Savile Row - The City - New York -
Bespoke Tailoring
Wednesday 24th - Saturday 27th
New York in August
- Getting Married in 2016? -
Traditional Tails, dinner jacket or individual style.
- Overcoats for Autumn -
Bespoke Orders for Next Season
Shop the C&D collection
ACCESSORIES ONLINE
- Wedding Suits -
traditional or contemporary?
- Stand out in the workplace -
Business Suits
Savile Row - The City - New York
THE ESSENTIALS
BESPOKE SHIRTS
- Cad & The Dandy -
Since founding the company in 2008, James Sleater and Ian Meiers have garnered a loyal following in both Savile Row and the City of London, along with an ever increasing client base in New York. Making suits for a wide range of customers, from Royalty to the man on the street, our suits give wearers a confidence in their own, individual sense of style whether fully bespoke, hand finished or machine made.童谣儿歌推荐
少儿读物推荐
少儿单词推荐
少儿Flash节目推荐
可可英语官方微信(微信号:ikekenet)
每天向大家推送短小精悍的英语学习资料.
添加方式1.扫描上方可可官方微信二维码。
添加方式2.搜索微信号ikekenet添加即可。whatcolouristheshirt中文意思_百度知道
whatcolouristheshirt中文意思
whatcolouristheshirt中文意思
我有更好的答案
衬衫是什么颜色的
What colour is the shirt? 衬衫是什么颜色的?
这件男士衬衫什么颜色?
衬衫是什么颜色的?
这件衬衫啥颜色?
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 what is the matter 的文章

 

随机推荐