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

  • Home
  • SEARCH
  • 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 7531991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:19:24+00:00 2026-05-30T05:19:24+00:00

I have a naive question about OOP design patterns. This is over-architecture, but I

  • 0

I have a naive question about OOP design patterns. This is over-architecture, but I need a recommendation, not judgment. Suppose you have a class hierarchy dictated by “business requirements”. So, you’ve got a deeper version of Pizza : Freight, Flowers : Freight and a TonOfBricks : Freight and you’ve got an IDispatchService<F> where F : Freight and an IDeliveryService<F> where F : Freight.

Now suppose that different IDeliveryService implementations want different information about the freight. What they want does not parallel your class hierarchy, and you have no clue what delivery service (ie. API) you’re gonna use in a month for what kind of parcel. Furthermore, you may have enough information to send one pizza through a vacuum tube, but maybe not the next.

Now you realized that you can also hire people to deliver your pizzas on rollerblades, but you’ll need to specify the center of mass of every object delivered this way or else insurance will kill you. Do you implement it as an IDeliveryService<Pizza>? Are you also adding a new interface IHasCenterOfMass and maybe implementing as IDeliveryService<IHasCenterOfMass>? If so, how’s the dispatcher gonna like it? Are you adding a relation to your database for center of mass?

  • 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-05-30T05:19:26+00:00Added an answer on May 30, 2026 at 5:19 am

    The trick is not to violate the substitution principle which states that every derived should be changeable with another derived as long as they share the same base class/interface. Therefore my recommendation would be to make your services accept a XXXServiceInformation instance which contains the specific information for that required service and knows how to potentially read it from source. Example:

    interface IDeliveryService<F> where F : Freight
    {
        void Deliver();
    }
    
    class RollerBladesDeliveryService<F> : IDeliveryService<F> where F: Freight
    {
        public RollerBladesDeliveryService(RollerBladesDeliveryInformation<F> information){ ... }
    
        void Deliver() { ... }
    }
    
    class RollerBladesDeliveryInformation<F> where F: Freight
    {
        public RollerBladesDeliveryInformation(F freight, double centerOfMass) { ... }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that may be quite naive, but I feel the need
This is likely a novice question about LINQ, but assuming I have a set
This is probably a naive question about XmlReader , but I haven't turned up
I'm sorry about the naive question. I have the following: public Array Values {
This question might be naive as I'm new to ColdFusion programming. I have a
I have a naive question about RSS feeds. I have a series of timed
This question might look naive, but I couldn't understand this code in the ViewModelLocator.cs
This question may seem to be naive. But I think it'll be much worse
I am not sure how appropriate is this question, but - I am curious
Maybe this is sort of a naive question...but I think that we should always

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.