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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:36:13+00:00 2026-05-11T08:36:13+00:00

Example: I have several types, e.g. Wheel, Brake, Engine, Clutch, AutoBox, ManualBox, ElectricWindow, RearParkingSensor,

  • 0

Example: I have several types, e.g. Wheel, Brake, Engine, Clutch, AutoBox, ManualBox, ElectricWindow, RearParkingSensor, HeatedSeats. These will all inherit a ICarPart marker interface (could be an attribute (java annotation), but doesn’t matter at this stage).

I then write my Car class that can represent all car types, e.g.

class Car {     string Name;     DateTime creationDate;     string ID;      IList<ICarPart> parts; } 

I then write a factory to create cars. The factory could refer to some XML which is an ingredients list for different car types. E.g. (and please ignore format, this is just for illustration):

<ExpensiveCar>   <Name>Expensive Car</Name>   <Parts>     <HeatedSeats/>     <Wheel count=4/>     <RearParkingSensor/>     <ElectricWindow type=FrontAndBack/>   </Parts> </ExpensiveCar> 

The factory would parse this ingredients list and create the car object. New car types would be available to the system providing the parts had been coded and the ingredient list XML written.

Questions:

  1. What is this pattern called? Or is it just multiple patterns combined?
  2. Is any of this an antipattern?
  3. How do I represent this in a UML? I could do a class diagram for the parts and for the base car class. How would I show the instances of that class that are currently supported and the parts they have?

Thanks in advance. If any of this is unclear please comment and I’ll amend/udpate/provide more details.

  • 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. 2026-05-11T08:36:14+00:00Added an answer on May 11, 2026 at 8:36 am
    1. What is this pattern called? Or is it just multiple patterns combined?

    The pattern described is the Builder Pattern. The builder pattern builds complex objects from a set of simpler parts. Sometimes the objects built by the builder pattern are Composite Objects (though not neccessarily in the question’s case).

    The builder pattern is often demonstrated using hard coded ingredients lists, though there is nothing in the pattern that requires this, nor does there seem to be a specific pattern documented describing the ‘ingredients list’ approach.

    1. Is any of this an antipattern?

    No

    1. How do I represent this in a UML?

    Probably by:

    1. Define the class diagram showing the parts as classes as well as the Car class. Show that each part class implements the ICarPart interface.
    2. Perhaps on a seperate (but linked) class diagram show named instances of the car class using the UML instance notation. The instance class representation allows you to specify the values that attributes have in that class, e.g.
    ------------------------------------------ |ExpensiveCar : Car                      | ------------------------------------------ |parts = {                               |   |HeatedSeats,                            | |Wheel (count = 4),                      | |RearParkingSensor,                      | |ElectricWindows (type = FrontAndBack) } | ------------------------------------------ 

    Note that because this is an instance the text ‘ExpensiveCar : Car’ should be underlined but SO doesn’t allow me to do this.

    The notation I’ve used here to initialise an array with parts isn’t great and might not be the best approach. Perhaps an alternative would be to add a UML note containing the actual XML. The important thing is that a client can see what makes an expensive car and so can a programmer.

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

Sidebar

Related Questions

I'm beginning work on a web application that will have several distinct user types,
Several web service APIs have you sign up for an API key. For example,
I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser
I have several SQL files that I want to import. An example: CREATE TABLE
I'm using the Silverlight UnitTest framerwork does anyone have a good example have how
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
Example: I have two shared objects (same should apply to .dlls). The first shared
For example I have such query: Query q = sess.createQuery(from Cat cat); List cats
For example I have 2 tables, Users and UserRelations , and it is a

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.