DTO, DAO and MVC Concept

DAO Layer

Answer :DTO is an abbreviation for Data Transfer Object, so it is used to transfer the data between classes and modules of your application.

  • DTO should only contain private fields for your data, getters, setters, and constructors.
  • DTO is not recommended to add business logic methods to such classes, but it is OK to add some util methods.

DAO is an abbreviation for Data Access Object, so it should encapsulate the logic for retrieving, saving and updating data in your data storage (a database, a file-system, whatever).

Here is an example of how the DAO and DTO interfaces would look like:

interface PersonDTO {
String getName();
void setName(String name);
interface PersonDAO {
PersonDTO findById(long id);
void save(PersonDTO person);

The MVC is a wider pattern. The DTO/DAO would be your model in the MVC pattern.
It tells you how to organize the whole application, not just the part responsible for data retrieval.

Answer : If you have a small application it is completely OK, however, if you want to follow the MVC pattern it would be better to have a separate controller, which would contain the business logic for your frame in a separate class and dispatch messages to this controller from the event handlers.
This would separate your business logic from the view.




Programming isn’t about what you know; it’s about what you can figure out.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Then the ball went farther out into the ocean, and I felt shitty

Introduce Product 1: MassBit Route

7 Mistakes to Avoid While Moving Your IOT Projects from an Idea into Reality

Top Microservices Tools

ROADMAP (2020~2023)

What Does a Drupal Developer Do and Know?

Adding a Boss to 2D Galaxy Shooter in Unity-Part 04-Boss Health & Shield System!

Abstract Factory Pattern —  Go Example

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kajal Rawal

Kajal Rawal

Programming isn’t about what you know; it’s about what you can figure out.

More from Medium

Calling Twitter Api with SpringBoot, OpenFeign and Twittered.

Design Patterns 06 — Memento Design Pattern

Spring Boot | How to make payments and update the database with Stripe

Java Virtual Machine(JVM) Architecture