473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

constructor and configuration file

Dear all,

I have a class that takes some paths as parameters and does some
operations on the files under these paths. I used Boost filesystem
library for that.

My question is on the construction: Now I am using a list of path
parameters when I create an object of this class but I was thinking to
call a configuration file reader function inside my constructor which
takes care of the initialization of the paths through this function.
>From an introductory OOP course, I remember that constructors should
only be used for the initialization of the data members of the class.
Not for calling other functions and operations. If you want to do sth
like this encapsulate this in a function which is also a member of the
class.

This is what I use as the constructor in the header file:

SA(const std::string& pathToVLInStr,const std::string&
pathToVLStartStr,
const std::string& pathToVLOutStr,const std::string&
pathToVLDoneStr,
const std::string& inputStr,const std::string& dmapStr,
const std::string& analysisStr, const std::string&
unixStr):

pathToVLInputFile(pathToVLInStr),pathToVLStartFile (pathToVLStartStr),

pathToVLOutputFile(pathToVLOutStr),pathToVLDoneFil e(pathToVLDoneStr),
pathToInputFile(inputStr),pathToDmapFile(dmapStr),

pathToAnalysisFile(analysisStr),pathToVLUnixFile(u nixStr){}; // ctor

I need some advice on this. Becasuse in the main file I do not want
to type everything. But is that a good idea to do that from inside the
constructor or in another independent class function?

Best regards,

Mar 8 '07 #1
1 1650
utab wrote:
Dear all,

I have a class that takes some paths as parameters and does some
operations on the files under these paths. I used Boost filesystem
library for that.

My question is on the construction: Now I am using a list of path
parameters when I create an object of this class but I was thinking to
call a configuration file reader function inside my constructor which
takes care of the initialization of the paths through this function.
>>From an introductory OOP course, I remember that constructors should
only be used for the initialization of the data members of the class.
Not for calling other functions and operations. If you want to do sth
like this encapsulate this in a function which is also a member of the
class.
I've never heard that advice before, I don't agree with it.
>
This is what I use as the constructor in the header file:

SA(const std::string& pathToVLInStr,const std::string&
pathToVLStartStr,
const std::string& pathToVLOutStr,const std::string&
pathToVLDoneStr,
const std::string& inputStr,const std::string& dmapStr,
const std::string& analysisStr, const std::string&
unixStr):

pathToVLInputFile(pathToVLInStr),pathToVLStartFile (pathToVLStartStr),

pathToVLOutputFile(pathToVLOutStr),pathToVLDoneFil e(pathToVLDoneStr),
pathToInputFile(inputStr),pathToDmapFile(dmapStr),

pathToAnalysisFile(analysisStr),pathToVLUnixFile(u nixStr){}; // ctor

I need some advice on this. Becasuse in the main file I do not want
to type everything. But is that a good idea to do that from inside the
constructor or in another independent class function?

Best regards,
I don't see the point of having a seperate function just for the sake of
it. From what you've described so far I would just do everything in the
constructor.

john
john
Mar 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Kienzle | last post by:
I'm new to Java programming. I'm developing a Servlet for tomcat which needs an external configuration file. With external I mean a file (in XML format) which is customizable and not contained in...
2
by: kathy | last post by:
What Application Configuration File is? And when/where/how to use it? Any documents on that? MSDN has somrthings scatter everywhere - hard to follow. thanks,
2
by: Gary | last post by:
Hi, I am a Chinese student, I have a problem with the following code //The follwing code in StaticSearch.h: // template <class Type> class dataList; // template <class Type> class Node ...
3
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found"....
0
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
6
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
7
by: krishnasamy | last post by:
Hi, I have a sq.h include file which containing following code, struct FRSDK_SHARED SampleQuality { SampleQuality( bool enrollmentOk, bool verificationOk, float q, ...
2
by: Tom | last post by:
In a web-application I need to read some configuration from a database. I like to write a configuration class which will be implemented as thread-safe singleton. I connect through ODBC to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.