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 8359279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:05:46+00:00 2026-06-09T11:05:46+00:00

I am working on an OO design problem. I’ll try to focus on the

  • 0

I am working on an OO design problem. I’ll try to focus on the part I am confused about and explain it in text rather than providing code.

I have a class called SalesPolicy that contains a List of TaxPolicy. TaxPolicy is an abstract class that represents a tax policy with name and tax rate as attributes. TaxPolicy contains an abstract method called accept. Concrete implementations of a TaxPolicy must implement the accept method and provide the logic for deciding when a TaxPolicy is applicable.

I have another class called SalesEngine. SalesEngine has a SalesPolicy and SalesPolicy is one of the parameters to the SalesEngine constructor. SalesEngine decides whether a TaxPolicy from a List of TaxPolicy in SalesPolicy is applicable for an item or not by calling the accept method and then calculates the tax accordingly. As explained earlier, SalesPolicy contains a single attribute which is a list of TaxPolicy and a method to add to the List.

What I need to know is whether it is okay to have a parameter like SalesPolicy for the SalesEngine class. What impact does this have from the point of view of testable code?

  • 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-09T11:05:48+00:00Added an answer on June 9, 2026 at 11:05 am

    I think that it is perfectly fine to have a scenario like this:

    public SalesEngine(SalesPolicy policy) { ... }
    

    Where when the SalesEngine is being created the user or whoever already knows what SalesPolicy that they want to use.

    Another scenario it might be valuable to include is the case where the user does not know what SalesPolicy they want to use at the time the SalesEngine is created, which you can do by adding a default constructor and a setter method:

    // default construtor
    public SalesEngine() { ... }
    
    // sets the sales policy
    public void setSalesPolicy(SalesPolicy policy){ ... } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered a code design problem while working on a small application. In terms
I'm working on a shopping cart and my problem is, how should I design
I'm working on ATL GUI design. I need some tutorials, books about this topic.
I'm working on a pretty simple problem, with design ramifications. Please bear with me,
So I have an interesting design problem. I am working on SLES 9+ Linux,
I'm working on a homework problem out of Stalling's Operating Systems: Internals and Design
I have experienced a frustrating and interesting problem. The design I am working on
I am stuck in a weird Design problem, I am working on a two
I'm working on a multithreaded server in c++ using boost-asio. Currently a design problem
Hello I am working on this design, but there seems to be a problem

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.