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

The Archive Base Latest Questions

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

I have a class which defines a historical extraction on a database: class ExtractionConfiguration

  • 0

I have a class which defines a historical extraction on a database:

class ExtractionConfiguration  
{  
    string ExtractionName;  
    time ExtractionStartTime;  
    time ExtractionEndTime;

    // Should these functions be static/non-static?
    // The load/save path is a function of ExtractionName
    void SaveConfigruation();
    void LoadConfiguration();
}  

These ExtractionConfigurations need to be saved to/loaded from disk. What is the best way of organising the save/load functions in terms of static/non-static? To me, it is clear that SaveConfiguration() should be a member function. However with LoadConfiguration(), does it make more sense to call

ExtractionConfiguration newExtraction;  
newExtraction.LoadConfiguration();

and have a temporary empty instance or make the load function static

static ExtractionConfiguration LoadConfiguration(string filename);

and just call

ExtractionConfiguration newExtraction = ExtractionConfiguration::LoadConfiguration(filename);

which feels neater to me, but breaks the ‘symmetry’ of the load/save mechanism (is this even a meaningful/worthwhile consideration?).

I suppose asking for the ‘best’ answer is somewhat naive. I am really trying to get a better understanding of the issues involved here.

P.S. This is my first question on SO, so if I have not presented it correctly, please let me know and I will try and make the problem clearer.

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

    You should consider using Boost.Serialization style serialization function that avoids having separate functions for saving and loading (even if you don’t use the library itself).

    In this approach you can pass the function any type of object that has operator&, to perform an operation on all the member variables. One such object might save the data to a file, another might load from a file, third might print the data on console (for debugging, etc).

    If you wish to keep separate functions, having them as non-static members might be a better option. For the saving function this is obvious, but loading is a different matter because there you need to construct the object. However, quite commonly loading is done by default-constructing and then calling the load non-static member function, for symmetry reasons, I guess.

    Having the loading as a function that returns a new object seems better in some ways, but then you need to decide how it returns the object. Is it allocated by new, or simply returned by value? Returning by value requires the object to be copyable and returning a pointer mandates the resource management scheme (cannot just store the object on stack).

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

Sidebar

Related Questions

Suppose you have a Java class which defines a copyFile(String, String) method: public class
I have a Exception base class which defines a stream function: class Exception {
I have an application App1 which defines class A and uses instances of this
Suppose I have a file X.h which defines a class X, whose methods are
I have a template class which defines operators, that works on the template parameters.
I have an Assembly(A) which defines a Managed class which has a public constructor
I have a type class Atomic , which defines functions for converting certain types
I have solution A which defines public class Foo, and solution B which references
I have a Hibernate hbm.xml mapping file which defines a large number of class
I have a declarative base class Entity which defines the column name as polymorphic,

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.