Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:57:24+00:00 2026-06-01T13:57:24+00:00

I am designing an inventory system. Each inventory item’s taxes need to be calculated

  • 0

I am designing an inventory system. Each inventory item’s taxes need to be calculated based on many conditions (State, County, etc, etc). The rules of calculations change as well over period of time. So I was thinking of the Strategy Pattern but I do not have an extensive experience in making design descions.

What other questions should I be asing my self?

My Inventory Item can be of a different type, so the wiki page on strategy pattern says:

The behaviours of a class should not be inhereted, instead they should be encapsulated using interfaces.

How does this affect my case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:57:26+00:00Added an answer on June 1, 2026 at 1:57 pm

    The behaviours of a class should not be inhereted, instead they should
    be encapsulated using interfaces.

    This means that instead of subclassing your Inventory item for each and every possible tax calculation, you should encapsulate the calculation algorithm behind an interface and then use encapsulation inside your Inventory class that points to the correct Strategy object.

    This saves you a lot of work since you don’t have to declare a new Inventory subclass each time you have a new calculation.

    The following implementation uses inheritance:

    abstract class InventoryBase
    {
       protected abstract Money CalculateTax();
    }
    
    class InventoryTaxA : InventoryBase
    {
       protected override Money CalculateTax()
       {
          // Calculation A
       }
    }
    
    class InventoryTaxB : InventoryBase
    {
       protected override Money CalculateTax()
       {
          // Calculation B
       }
    }
    

    But the strategy pattern would look like:

    class Inventory
    {
       public Inventory(ITaxCalculationStrategy taxCalculationStrategy)
       {
          TaxCalculationStrategy = taxCalculationStrategy;
       }
    
       protected override Money CalculateTax()
       {
           return TaxCalculationStrategy.Calculate(this);
       }
    }
    

    So, strategy is definitely a nice solution for abstracting your tax calculations. If the rules of which calculation apply at a certain time are different and can change I would also use a Factory for creating the correct Strategy object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing an inventory system , it has users , products , buy_leads ,
As part of a fish inventory system I'm designing, I have to track where
Designing a new system from scratch. I'll be using the STL to store lists
I have been tasked with designing an application for tracking inventory on a mobile
I'm designing a game where a character has many items and those items can
for designing purposes i need to truncate all DB which has lots of FK's.
I am new to designing my own database. My project is orders/products/inventory type data,
im designing a system where i will have multiple users uploading large amount of
When designing a class, should logic to maintain valid state be incorporated in the
When designing a new J2EE based enterprise framework, do I have to prepare for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.