c++ - Best way to program such things " writing the code " :: Qt -


can guys me these questions , give opinion.

1- let's want create window maybe calculate " window " ok if write of stuff in constructor instead of creating function me call in constrictor ? or better approach.

2- let's have array or qvector or , maybe +30 elements , elements meant constant maybe holding subjects names "i want insert names not user", considered bad initialize this:

s[0]=".." s[1]="...." 

since can't use loop because names change.

1- let's want create window maybe calculate " window " ok if write of stuff in constrictor instead of creating function me call in constrictor ? or better approach.

i tell any function should small, not constructor. this might help.

2- let's have array or qvector or , maybe +30 elements , elements meant constant maybe holding subjects names " want insert names not user " , considered bad inizilize :

s[0]=".." s[1]="...." . . .

since can't use loop because names change.

consider specifying these values in external configuration file, load (i.e. parse) when application starts. is, instead of having tons of statements like

s[0] = "john doe" s[1] = "jane doe // ... 

put names in file, names.cfg, , fill in qvector this:

std::ifstream in{"names.cfg"};  qvector<std::string> names; std::string current_name;  while (std::getline(in, current_name))     names.push_back(current_name); 

disclaimer: i'm no qt expert, think use of qvector valid.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -