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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:15:53+00:00 2026-05-13T20:15:53+00:00

I had a bunch of objects which were responsible for their own construction (get

  • 0

I had a bunch of objects which were responsible for their own construction (get properties from network message, then build). By construction I mean setting frame sizes, colours, that sort of thing, not literal object construction.

The code got really bloated and messy when I started adding conditions to control the building algorithm, so I decided to separate the algorithm to into a “Builder” class, which essentially gets the properties of the object, works out what needs to be done and then applies the changes to the object.

The advantage to having the builder algorithm separate is that I can wrap/decorate it, or override it completely. The object itself doesn’t need to worry about how it is built, it just creates a builder and ‘decorates’ the builder with extra the functionality that it needs to get the job done.

I am quite happy with this approach except for one thing… Because my Builder does not inherit from the object itself (object is large and I want run-time customisation), I have to expose a lot of internal properties of the object.

It’s like employing a builder to rebuild your house. He isn’t a house himself but he needs access to the internal details, he can’t do anything by looking through the windows. I don’t want to open my house up to everyone, just the builder.

I know objects are supposed to look after themselves, and in an ideal world my object (house) would build itself, but I am refactoring the build portion of this object only, and I need a way to apply building algorithms dynamically, and I hate opening up my objects with getters and setters just for the sake of the Builder.

I should mention I’m working in Obj-C++ so lack friend classes or internal classes. If the explanation was too abstract I’d be happy to clarify with something a little more concrete. Mostly just looking for ideas or advice about what to do in this kind of situation.

Cheers folks,
Sam

EDIT: is it a good approach to declare a

interface House(StuffTheBuilderNeedsAccessTo)

category inside Builder.h ? That way I suppose I could declare the properties the builder needs and put synthesizers inside House.mm. Nobody would have access to the properties unless they included the Builder header….

That’s all I can think of!

  • 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-13T20:15:54+00:00Added an answer on May 13, 2026 at 8:15 pm

    I don’t know Obj-C++, so I don’t know if this is possible, but this sounds like a problem for Categories. Expose only the necessary methods to your house in the declaration of the house itself, create a category that contains all the private methods you want to keep hidden.

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

Sidebar

Related Questions

I've had a bunch of EAGAIN's from trying to fork() or spawning threads, which
I had a bunch of controls that I displayed, hid, enabled and disabled based
I had a bunch of code in an activity that displays a running graph
I had a bunch of bookmark to www.asp.net/learn/, specially the one about data-access and
I had set up a bunch of NUnit unit tests using the Test connection
Last night I had a script go a bit crazy and create a bunch
I've been trying to see if I can build my JavaScript objects as intuitively
If I've got a bunch of plain old Objects, what's the best way to
The JavaScript object data has an attribute 'amplitudes' which is a string concatenated bunch
If I have an array of objects with properties and I wanted to sort

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.