Question

I have an extremely hard time figurering out how classes needs to communicate with eachother. In a current project I am doing, many classes have become so deeprooted that I have begun to make Singletons and static fields to get around(from what I get this is a bad idea).

Its hard to express my problem and its like other programmers dont have this problem. Here is a image of a part of the program: Class diagram

  • ex1. When I create a Destination object it needs information from Infopanel. How to do that without making a static getter in InfoPanel?

  • ex2. DestinationRouting is used in everybranch. Do I really have to make it in starter and then pass it down in all the branches?

Not sure if this makes sense to anybody :) Its a problem that is reacurring in every project.

Was it helpful?

Solution

There's just too little information here. For example, I am not even sure if MapPanel and InfoPanel should be the way they are. I'd be tempted to give the decorator pattern a try for what it's worth. I don't know why a Listener is a child of a Panel either. We need to know what these objects are and what system this is.

OTHER TIPS

After looking at your class diagram, I think you are applying a procedural mind set to an OO problem. Your singletons appear to contain all of the behavior which operate on the records in your domain model and the records have very little behavior.

In order to get a better understanding of your object model, I'd try and categorize the relationships (lines) in your class diagram as one of "is-a", "has-a", etc. so that you can better see what you have.

Destination needs some information from InfoPanel, but not likely all information. Is it possible to pass only the needed information to Destination instead of InfoPanel?

What state is being captured in the DestinationRouting class that forces it to be a singleton? Does that information belong elsewhere?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top