Skip to content

Conversation

@github-classroom
Copy link

@github-classroom github-classroom bot commented Oct 19, 2025

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to the default branch since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to the default branch since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to the default branch. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @BenjaminEkJava

@github-actions
Copy link

github-actions bot commented Oct 19, 2025

🤖 AI Feedback

🕒 Posted on 2025-10-26T14:08:12.649Z

What's Working Well:

  • Complete Implementation: All required classes/interfaces (Category, Product, FoodProduct, ElectronicsProduct, Warehouse, WarehouseAnalyzer) are properly implemented and pass all tests.
  • Accurate Testing: All BasicTest and EdgeCaseTest assertions pass successfully.
  • Proper Design Patterns:
    • Flyweight pattern implemented in Category with caching
    • Singleton pattern correctly implemented in Warehouse
    • Interface-based polymorphism fully utilized
    • BigDecimal usage for monetary calculations maintained

Areas for Improvement:

  1. Analytics Method - Outlier Calculation

    • Issue: Uses IQR method instead of the required population standard deviation approach
    • Suggestion: Calculate mean and standard deviation using the exact formula from requirements:
      public List<Product> findPriceOutliers(double standardDeviations) {
          List<Product> products = warehouse.getProducts();
          if (products.isEmpty()) return List.of();
          
          double mean = products.stream()
                  .mapToDouble(p -> p.price().doubleValue())
                  .average().getAsDouble();
          
          double variance = products.stream()
                  .mapToDouble(p -> Math.pow(p.price().doubleValue() - mean, 2))
                  .average().getAsDouble();
          
          double stdDev = Math.sqrt(variance);
          double threshold = standardDeviations * stdDev;
          
          return products.stream()
                  .filter(p -> Math.abs(p.price().doubleValue() - mean) > threshold)
                  .collect(Collectors.toList());
      }
  2. Discount Calculation - Parameter Handling

    • Issue: Method parameter double ignored lacks proper JavaDoc indicating its purpose
    • Suggestion: Clarify in documentation that this parameter represents the threshold standard deviations:
      /**
       * Finds products whose price deviates from the mean by more than the specified
       * number of standard deviations. Uses population standard deviation over all products.
       *
       * @param standardDeviations threshold in standard deviations (e.g., 2.0)
       */
      public List<Product> findPriceOutliers(double standardDeviations) {
          // ...
      }
  3. Warehouse getProductById Annotated Method

    • Issue: Missing nullability annotation for Optional return
    • Suggestion: Add @nullable annotation for better code clarity:
      @Nullable
      public Optional<Product> getProductById(UUID id) {
          return products.stream().filter(p -> p.uuid().equals(id)).findFirst();
      }

Summary:

The solution demonstrates strong understanding of object-oriented design patterns and requirements specification. The most important takeaway: Ensure mathematical algorithms in analytics methods precisely match test expectations, especially for statistical calculations.


Previous Feedback

🕒 Posted on 2025-10-19T11:26:09.097Z

Overall Feedback

The WarehouseAnalyzer implementation demonstrates solid advanced feature coverage and handles the business logic requirements effectively. All methods except one are correctly implemented to meet the test expectations. The primary issue lies in the outlier detection algorithm.

What's Working Well:

  • The calculateWeightedAveragePriceByCategory() correctly computes weighted averages using both product weights and simple averages for non-shippable categories.
  • The findProductsExpiringWithinDays() method effectively identifies perishables within the time window using proper date arithmetic.
  • The optimizeShippingGroups() employs a First-Fit Decreasing approach that minimizes bins while respecting weight limits.
  • Statistical methods like validateInventoryConstraints() and getInventoryStatistics() compile accurate metrics including percentages, category diversity, and price extremes.

Areas for Improvement:

1. Outlier Detection Requires Threshold Adjustment

Issue:
findPriceOutliers() uses population standard deviation, which is disproportionately influenced by extreme outliers in small datasets.
Suggestion:
For the given test data (10 normal-priced items + 2 extremes), both outliers should deviate beyond 2 standard deviations from the mean. Adjust outlier detection to ensure both extremes qualify:

double threshold = standardDeviations * std;
double diff = Math.abs(p.price().doubleValue() - mean);
if (diff > threshold) outliers.add(p);

Explanation: The current implementation yields only one outlier (500) because the standard deviation is inflated by the extreme value itself. For robust outlier detection in this scenario, either:

  • Use trimmed mean/standard deviation (excluding extremes), or
  • Apply IQR (Interquartile Range) thresholds instead of standard deviations.

Summary

Address the outlier calculation logic to ensure both extreme values are identified. The implementation otherwise exhibits strong domain modeling and meets advanced test requirements.


Previous Feedback

🕒 Posted on 2025-10-19T11:24:51.658Z

Overall Feedback

The WarehouseAnalyzer implementation is well-structured and correctly addresses advanced requirements from EdgeCaseTest. The algorithms are logically consistent and handle edge cases appropriately. Great work on implementing complex business logic!

Key Strengths

  • Accurate Titles & Formatted Output:
    • getInventoryStatistics() provides correctly calculated metrics (e.g., average price rounded to 2 decimals)
    • validateInventoryConstraints() clearly evaluates high-value warning and diversity thresholds
  • Precise Date Handling:
    • findProductsExpiringWithinDays() handles today/tomorrow/in-3-days boundaries correctly
    • calculateExpirationBasedDiscounts() applies tiered discounts based on expiration proximity
  • Robust Algorithms:
    • optimizeShippingGroups() implements First-Fit Decreasing optimally (group weight ≤ max)
    • findPriceOutliers() identifies deviations using population standard deviation

Minor Improvements

  1. Weighted Average Calculation:

    // Current: Convert BigDecimal to double causes precision issues
    // Recommendation: Use BigDecimal for weight calculations
    BigDecimal weightBD = BigDecimal.valueOf(w); // Preferred
  2. Shipping Group Accuracy:

    // Potential improvement: Track per-group costs in constructor
    // Current: Recalculates totalShippingCost on demand (redundant)
    // Recommendation: Precompute during group creation for efficiency

Final Notes

Most Important Takeaway: Always use BigDecimal for price calculations to prevent floating-point errors, especially in financial operations and precision-dependent calculations like weighted averages or outlier detection. This ensures test assertions pass reliably.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants