title: How to put DAO and GUI together with MVC
body: <p>I'm creating a Java Application that represents a school. My aim is to keep the application open for new features, so I'm trying to apply some Design Patterns to it.</p>
  
  <p>What I have so far is a HSQLDB connected to my program. 
  In the database one can store </p>
  
  <ul>
  <li>pupils</li>
  <li>courses</li>
  <li>years</li>
  <li>exams</li>
  <li>grades</li>
  </ul>
  
  <p>The current structure is as follows:</p>
  
  <ul>
  <li>there are classes for each of the objects that contain the attributes + setters and getters</li>
  <li>for each object there is a DAO that manages the CRUD operations on the DB</li>
  <li>each DAO implements a GenericDAO interface</li>
  </ul>
  
  <p>If i want to create a new pupil i can call: </p>
  
  <ul>
  <li>PupilDao pupil = new PupilDao();</li>
  <li>pupil.connectToDB();</li>
  <li>pupil.add(new Pupil(name, age,...));</li>
  <li>pupil.disconnectDB();</li>
  </ul>
  
  <p>Every DAOs connectToDB() and disconnectDB() methods point to a DBuser-Classes connect() and disconnect() methods. So if I want to change the connection, there's only one place to do so.
  So far, those operations work.</p>
  
  <p>My questions are the:</p>
  
  <p>1.) Is the current design a proper use of DAOs? I'm asking because i would rather have one
  Dao for all objects because right now there's a lot of repetitive code in the DAOs. (e.g. get, update, delete...)</p>
  
  <p>Now that the DB-Access works, I want to create a GUI using Swing. I have some experience doing this although not with the MVC-Pattern. </p>
  
  <p>2.) As far as I understand, the DAOs + my object classes would be the Model here. Is that correct?</p>
  
  <p>3.) My understanding of MVC is that in my View-Class (i.e. the GUI) I set listeners for my actions which point to different Controller-Classes implementing the ActionListener interface and in my Controller-Classes I would for example have a actionPerformed() that creates a new Pupil (using the DAO / Model - Classes). Am I on the right track here?</p>
  
  <p>4.) Is it favourable to have one big Controller managing all actions over having different Controllers?</p>
  
  <p>I'm asking those questions because I read/watched a lot about patterns/OO-Design and want to make sure my understanding is correct.
  Furthermore I highly appreciate your thoughts on my design! What could be done more flexible or better to maintain later?</p>
  
  <p>Thanks in advance for every suggestion and sorry for the somewhat long explanation!</p>
  
  <p>Felix</p>