mercredi 13 mai 2020

Flyweight Pattern with no Intrinsic values

I am currently doing an assignment for a design pattern course, and one of the problems in this assignment is that we are meant to reduce RAM usage of a class.

The class stores a lot of data, and but I can't find any values that are intrinsic. We are hinted on using the Flyweight pattern, but I can't see a way to use a Flyweight pattern with the lack of intrinsic values.

Any suggestions on this problem?

The class looks something like this, with all of the getters below the constructor:

public class ReportImpl implements Report{

    private String name;
    private double commissionPerEmployee;
    private double[] legalData;
    private double[] cashFlowData;
    private double[] mergesData;
    private double[] tallyingData;
    private double[] deductionsData;

    public ReportImpl(String name,
                      double commissionPerEmployee,
                      double[] legalData,
                      double[] cashFlowData,
                      double[] mergesData,
                      double[] tallyingData,
                      double[] deductionsData) {
        this.name = name;
        this.commissionPerEmployee = commissionPerEmployee;
        this.legalData = legalData;
        this.cashFlowData = cashFlowData;
        this.mergesData = mergesData;
        this.tallyingData = tallyingData;
        this.deductionsData = deductionsData;
    }


}

The class is meant to represent a report. It stores the information in a created report. It uses a lot of RAM when a test case tries to get all of the created reports.

Aucun commentaire:

Enregistrer un commentaire