0

Let's say we have on one side classes which deal only with GUI stuff (e.g. Java Swing) and on the other side classes which stores the data. This data can be persisted in tables of an external database whereas these tables should be created and manipulated by Java Classes (Hibernate,JDBC).

So our example software looks like this:

enter image description here

My question is now how to implement the link between these two modules? Should I write an interface which implements an class which contains all methods which are needed for communication between them?

Or is it absolute sufficient to instantiate the data-classes in the gui-classes with new and to use the public methods of the data-classes?

1
  • what about your entities/models/objects? Commented Apr 1, 2015 at 18:28

1 Answer 1

1

Here a fragment of Martin Fowler's book Patterns of Enterprise Application Architecture,

A key point in this separation is the direction of the dependencies: the presentation depends on the model but the model doesn't depend on the presentation. People programming in the model should be entirely unaware of what presentation is being used, which both simplifies their task and makes it easier to add new presentations later on. It also means that presentation changes can be made freely without altering the model.

So I think you should create Business methods that don't know who will access them.

The other class (Controller) knows how to call the business methods from the data received from the view.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.