Click here to Skip to main content
15,885,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondesign question : variadic functions use ? . Pin
Maximilien19-Dec-23 2:34
Maximilien19-Dec-23 2:34 
AnswerRe: design question : variadic functions use ? . Pin
Mircea Neacsu19-Dec-23 2:42
Mircea Neacsu19-Dec-23 2:42 
GeneralRe: design question : variadic functions use ? . Pin
Maximilien19-Dec-23 2:54
Maximilien19-Dec-23 2:54 
AnswerRe: design question : variadic functions use ? . Pin
jschell19-Dec-23 5:08
jschell19-Dec-23 5:08 
GeneralRe: design question : variadic functions use ? . Pin
Maximilien19-Dec-23 7:36
Maximilien19-Dec-23 7:36 
GeneralRe: design question : variadic functions use ? . Pin
jschell20-Dec-23 5:31
jschell20-Dec-23 5:31 
GeneralRe: design question : variadic functions use ? . Pin
Maximilien20-Dec-23 6:55
Maximilien20-Dec-23 6:55 
GeneralRe: design question : variadic functions use ? . Pin
jschell21-Dec-23 3:31
jschell21-Dec-23 3:31 
My best practice doesn't fit either of your suggestions...

If I am creating a new database layer (which I have numerous times) then the caller would never provide the SQL.

If the business layer(s) need new database logic then the database layer should be modified to provide it.

The caller provides the parameters that would be used in the call.

Then within that database layer method it would decide how to process the parameters and SQL (provided by the method.)

So it looks like the following.

void DatabaseDoX(param1, param2,...)
{
// multiple variations possible
std::string fullyFormedQuery = sprintf (SQL_X, param1, param2, ... );


There are quite a few variations on the above. For example consider the complication of a user initiated call where they might specify different 'query' terms (like data range, customer name, etc)

But all still hide the SQL.

Certainly there are design considerations for example your code might be coming from within the database layer (not a business call at all.) If so then I suspect that usage would actually vary depending on what the database layer was specifically doing in the code path.
Questionstrcpy_s weirdness Pin
mike741119-Dec-23 1:31
mike741119-Dec-23 1:31 
AnswerRe: strcpy_s weirdness Pin
Mircea Neacsu19-Dec-23 1:43
Mircea Neacsu19-Dec-23 1:43 
AnswerRe: strcpy_s weirdness Pin
Richard MacCutchan19-Dec-23 2:04
mveRichard MacCutchan19-Dec-23 2:04 
AnswerRe: strcpy_s weirdness Pin
CPallini19-Dec-23 2:09
mveCPallini19-Dec-23 2:09 
QuestionShould this work in C++? Pin
mike741118-Dec-23 7:07
mike741118-Dec-23 7:07 
AnswerRe: Should this work in C++? Pin
Mircea Neacsu18-Dec-23 7:17
Mircea Neacsu18-Dec-23 7:17 
AnswerRe: Should this work in C++? Pin
Maximilien19-Dec-23 5:11
Maximilien19-Dec-23 5:11 
QuestionC++ memory freeing Pin
mike741116-Dec-23 3:04
mike741116-Dec-23 3:04 
AnswerRe: C++ memory freeing Pin
Richard MacCutchan16-Dec-23 3:21
mveRichard MacCutchan16-Dec-23 3:21 
AnswerRe: C++ memory freeing Pin
Mircea Neacsu16-Dec-23 3:21
Mircea Neacsu16-Dec-23 3:21 
GeneralRe: C++ memory freeing Pin
Daniel Pfeffer21-Dec-23 9:41
professionalDaniel Pfeffer21-Dec-23 9:41 
GeneralRe: C++ memory freeing Pin
Mircea Neacsu21-Dec-23 15:26
Mircea Neacsu21-Dec-23 15:26 
AnswerRe: C++ memory freeing Pin
jschell18-Dec-23 5:30
jschell18-Dec-23 5:30 
GeneralRe: C++ memory freeing Pin
k505418-Dec-23 6:14
mvek505418-Dec-23 6:14 
QuestionFinding the Parent Process Pin
Richard Andrew x6415-Dec-23 8:21
professionalRichard Andrew x6415-Dec-23 8:21 
AnswerRe: Finding the Parent Process Pin
Gerry Schmitz15-Dec-23 8:32
mveGerry Schmitz15-Dec-23 8:32 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 8:47
professionalRichard Andrew x6415-Dec-23 8:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.