Design Pattern - To use DAO? Or to use another type of Design Pattern?

I'm implementing a system for a giant-sized company. The system is using the design pattern MVC.

However, I have a problem here about whether you need to use DAO or use a small part of another design pattern (do not know which design patten have to adopt this particular case).

Well, here we go:

There is a system tool that enables you to generate management information, choosing an option to view: in graph or data (tables).

As these two options have the same behavior, but in different views, I have to use the DAO pattern? Or other design pattern most?

For example, I am implementing a class below:


class Graphic implements IDAOResult {

    public function totalParticipation() { }

    public function evolution() { }

}

class DataInfo implements IDAOResult {

    public function totalParticipation() { }

    public function evolution() { }

}

So with the above class, as I'm doing the DAO, as I believe is more appropriate for everyone. Do you believe that I should not use the DAO, or look for another type of design pattern most appropriate for the situation above?

Thanks.

1 Answer

  1. Edward- Reply

    2019-11-15

    Whether it is a graphic or a table you will be reading the same data from the same database, then write and use one DAO to do that.

    What you have here are two different views, and here is where MVC helps you. Select the correct view (graphic or table) in the controller based on the request and use the data retrieved from the DAO.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>