Grade distribution for Homework #4:

Software design approaches

Here are software design approaches used by students for the Statistics feature, given that there is a Statistics object whose class has thread-safe methods to update counters

Thread safety

Here is how people did synchronization:

Software engineering notes

Saw may things like:

switch (filterName) {
            case "Invert":
                invertByte += megaBytes;
                invertTime += (totalTime / 1000);
                avgInvertSpeed = (invertByte / invertTime);
                break;
            case "Solarize":
                solarizeByte += megaBytes;
                solarizeTime += (totalTime / 1000);
                avgSolarizeSpeed = (solarizeByte / solarizeTime);
                break;
            case "Oil4":
                oil4Byte += megaBytes;
                oil4Time += (totalTime / 1000);
                avgOil4Speed = (oil4Byte / oil4Time);
                break;
        }

or

    private static Statistics instance = null;
    private final IntegerProperty totalCompletedJobs;
    private final IntegerProperty totalImagesProcessed;
    private final DoubleProperty avgSpeedInvert;
    private final DoubleProperty avgSpeedSolarize;
    private final DoubleProperty avgSpeedOil4;
    private double totalMBInvert;
    private double totalMBSolarize;
    private double totalMBOil4;
    private double totalExecutionTimeInvert;
    private double totalExecutionTimeSolarize;
    private double totalExecutionTimeOil4;

This is code duplication, and instead one should used a HashMap of counters! Because what if I say tomorrow “let’s add 15 filters”, then you’d have to do 15 copy-paste of declaration, methods, etc. So whenever you copy-past code, really think twice and do something nicer (especially during a job coding interview!!!).