I study programming in my college Stamp Coupling. We are learning system analysis and design. My classmate ask me the question, how to solve Stamp Coupling? I ask Teacher who said "Use an interface to limit access from clients", but I still misunderstand.
Asked
Active
Viewed 432 times
1

LiHao
- 290
- 3
- 13
-
1This is way too broad to answer. You'll have to tell us the specific case in which you have to solve stamp coupling (preferably with relevant code). – Eran Dec 14 '17 at 09:54
-
Possible duplicate of [Can't seem to understand SOLID principles and Design Patterns](https://stackoverflow.com/questions/13692126/cant-seem-to-understand-solid-principles-and-design-patterns) – rkosegi Dec 14 '17 at 09:54
-
@Eran Sorry, I miss the question, I already edit and add the question title. – LiHao Dec 14 '17 at 11:17
1 Answers
2
Well, since the print method needs only the name, address and billing info of the Customer, you don't have to pass anything else to it.
You can define an interface:
public interface PrintableCustomer
{
public ... getName();
public ... getAddress();
public ... getBillingInfo();
}
Now, let the Customer
class implement PrintableCustomer
.
The print method can now accept a PrintableCustomer
instead of a Customer
.
void print (PrintableCustomer customer)
{
...
}
Now print()
only sees the properties that it needs.

Eran
- 387,369
- 54
- 702
- 768