mardi 10 novembre 2020

What design pattern is useful for reporting the same data grouped by different columns in potentially different tables?

Let's imagine a scenario where we are writing a report dashboard for a university. We want to report things about students (such as their average GPA, average number of passed courses, average number of remaining courses, etc.) based on these different columns (some of which might be saved in completely different tables):

  1. Group students by the department they belong to.
  2. Group students by whether they're international or domestic students
  3. Group students by the year they are in (freshman, sophomore, etc.)
  4. Group students by their GPA (A, B, C, D, F)

It's just a hypothetical scenario just to give you an idea of what I am talking about.

So, each page will show a table where rows are data grouped by according to what I said and columns are what I said earlier (average GPA, average number of passed courses, average number of remaining courses, etc.)

Obviously, there will be a lot of code repeating if we don't use a design pattern. So, my question is, what kind of design pattern is suitable for this problem? I'm thinking that Strategy Pattern might work, but I'm pretty new to design patterns. Any help (with reasoning behind your choice) is appreciated.

Note: our DBMS is supposed to be relational, so we can join different tables.

Aucun commentaire:

Enregistrer un commentaire