Skip to main content
deleted 3 characters in body
Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So it doesn’t need to be told what will happen. So the reload system doesn’t need to know about the gun at all. No cycle.

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So it doesn’t need to be told what will happen. So the reload system doesn’t need to know about the gun at all. No cycle.

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So it doesn’t need to be told what will happen. So the reload system doesn’t need to know about the gun at all. No cycle.

added 56 characters in body
Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So it doesn’t need to be told what will happen. So the reload system doesn’t need to know about the gun at all. No cycle.

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So the reload system doesn’t know about the gun at all. No cycle.

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So it doesn’t need to be told what will happen. So the reload system doesn’t need to know about the gun at all. No cycle.

Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

1 and 2 are the same option as far as dependency knowledge goes. Without them the ReloadSystem has to know what a Gun is. Narrow what the ReloadSystem knows down to Reloadable and it doesn't care what's implementing it.

Doing this follows ISP. But comes at a cost.

That doesn’t break the cycle.

If you really want to solve the circular dependency try this:

 .-[Gun]-. <>’ ‘<> [Chamber]<-[ReloadSystem] ^ +---+---+ [Round] [Empty] 

No more cycles. The gun fires whatever’s in the chamber and whatever’s there does whatever it’s going to do do when fired.

Now sure. Chamber is “reloadable”. It’s also “fireable”. But that’s it. You’ll have to decide if you really need to follow ISP to the extreme here.

The big change is the gun doesn’t know what will happen if fired. So the reload system doesn’t know about the gun at all. No cycle.