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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:51:19+00:00 2026-06-15T00:51:19+00:00

I have different types of objects representing the same business entity. UIObject , PowershellObject

  • 0

I have different types of objects representing the same business entity.
UIObject, PowershellObject, DevCodeModelObject, WMIObject all are different representation to the same entity.

So say if the entity is Animal then I have AnimalUIObject, AnimalPSObject, AnimalModelObject, AnimalWMIObject, etc.

Now the implementations of AnimalUIObject, AnimalPSObject, AnimalModelObject are all in separate assemblies.

Now my scenario is I want to verify the contents of business entity Animal irrespective of the assembly it came from. So I created a GenericAnimal class to represent the Animal entity.

Now in GenericAnimal I added the following constructors:

GenericAnimal(AnimalUIObject)
GenericAnimal(AnimalPSObject)
GenericAnimal(AnimalModelObject)

Basically I made GenericAnimal depend on all the underlying assemblies so that while verifying I deal with this abstraction.

Now the other approach to do this is have GenericAnimal with an empty constructor
an allow these underlying assemblies to have a Transform() method which would build the GenericAnimal.

Both approaches have some pros and cons:

The 1st approach:
Pros: All construction logic is in one place in one class GenericAnimal
Cons: GenericAnimal class must be touched every-time there is a new representation form.

The 2nd approach:
Pros: construction responsibility is delegated to the underlying assembly.
Cons: As construction logic is spread accross assemblies, tomorrow if I need to add a property X in GenericAnimal then I have to touch all the assemblies to change the Transform method.

Which approach looks better ?
or Which would you consider a lesser evil ?
Is there any alternative way better than the above two ?

Just to elaborate further based on the comments i received.
I dont have the luxury the modify the structure of underlying objects, ie i cant change AnimalUIObject AnimalPSObject etc. The GenericAnimal is a construct introduced just for validation purposes by me.

  • 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-15T00:51:20+00:00Added an answer on June 15, 2026 at 12:51 am

    I think both approaches are pretty “evil”.

    I think what you really need is to start with the Animal class as your core class, and make the rest of the classes wrapper classes that use the Animal class to hold the representation. Validation is then performed against the Animal API.

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

Sidebar

Related Questions

I have different types, say A , B , C , that all inherit
How to pass by ref different types of objects that have the same properties
I have two different types of objects, say of classes Object1 and Object2. I
I have a NSArray that is filled with different types of objects. Lets say
I have beans which have Objects which can contain different types. Now when I
I have to initialize a lot of different types of objects based on an
I have an application that has many different types of objects that each persist
My NSMutableArray instance contains instances of different types of objects that have common ancestor.
I have a WinForms Application which for instance has 2 different Types of objects
I have a ObservableCollection<Object> that holds two different types of objects: Directory and File

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.