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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:16:54+00:00 2026-06-07T23:16:54+00:00

So I have an object that can be constructed in a few ways. The

  • 0

So I have an object that can be constructed in a few ways. The constructors have signatures like, the one that loads an object from a file:

Object::Object( string filenameToLoadFrom ) ;

And how it behaves is pretty straightforward.

Object( "filename.dat" ) ; // loads object from filename

The constructor signature pretty much says what it does, although a static method Load might arguably be better:

static Object* Object::Load( string filenameToLoadFrom ) ;

(syntax above is slightly incorrect but you get the idea.)

Then we come into cases where what the constructor does isn’t immediately obvious from the parameters. a name is needed to make it clear from the API what the constructor does.

The question is, is it a good idea to write static methods that return an instance of the object, just for the sake of being able to name the constructor?

  • 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-07T23:16:56+00:00Added an answer on June 7, 2026 at 11:16 pm

    This is actually considered a common secondary benefit of the Factory Method Pattern. It is potentially useful in specific scenarios, especially for things where you have the same argument type providing very different meanings.

    For example, it’s not uncommon to have a class representing an “Angle” which can be constructed by a single floating point number which could represent degrees or radians. Constructors do not provide enough context (or a clean way) to implement this, where a “factory method” makes this very clear.

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

Sidebar

Related Questions

Greetings, I have a particular object which can be constructed from a file, as
I have an object that can take anywhere from a split second to a
I have a IRecord object that can hold objects. The name of these objects
I have been attempting to have a object that I can use across multiple
We have the Class object (an object that reference a Class) so you can
I have a basic XML object that I'm working with. I can't figure out
I have drawn an object on NSView subclass. How can the object know that
I have noticed in Java that you can have a function with object... as
I have 3 objects. Object A has an event X that other objects can
I have an array that contains @sign in the object. I can't access that

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.