code generation advice

E

Ebenezer

I've recently made some changes to how I'm doing things. Previously
I
was using one .hh generated output file in all three of my tiers. The
first change I made was to introduce a .cc file and move the code that
could be in a .cc to that file. The second thing I did was to
separate
things between the tiers -- in other words, I now have a .hh and .cc
for between the "back" and "middle" tiers and separate .hh and
..cc for between the "middle" and "front" tiers. So that put me
at four files. The last change implied another change -- factoring
out some constants into a fifth file I call type_nums.hh. The first
four
files are named based on user input, but this file isn't. Here's an
example of type_nums.hh based on this input:
http://webEbenezer.net/misc/direct.mdl.

#ifndef type_nums_hh
#define type_nums_hh
uint16_t const File_num = 7001;
uint16_t const cmw_account_info_num = 7002;
uint16_t const cmw_user_input_num = 7003;
uint16_t const cmw_request_num = 7004;
#endif

Obviously, people could have a file with this name in their
code and I could inadvertently wipe out their file. I've
thought of adding a prefix to the type_nums name to
minimize this risk and also thought about isolating the generated
files in a subdirectory. Maybe I should do both. Thoughts?
Thanks in advance.


Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
 
I

Ian Collins

I've recently made some changes to how I'm doing things. Previously
I
was using one .hh generated output file in all three of my tiers. The
first change I made was to introduce a .cc file and move the code that
could be in a .cc to that file. The second thing I did was to
separate
things between the tiers -- in other words, I now have a .hh and .cc
for between the "back" and "middle" tiers and separate .hh and
..cc for between the "middle" and "front" tiers. So that put me
at four files. The last change implied another change -- factoring
out some constants into a fifth file I call type_nums.hh. The first
four
files are named based on user input, but this file isn't. Here's an
example of type_nums.hh based on this input:
http://webEbenezer.net/misc/direct.mdl.

What's wrong with one pair of files per class?
 
E

Ebenezer

What's wrong with one pair of files per class?

That's basically what I'm doing. The back and
front tiers only need to use one of the two
classes. The middle tier needs to use both of
the classes, so I need to factor out the code
that is in the type_nums.hh file.
 
E

Ebenezer

This is a little related:

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/b00a7647-c385-4d15-973a-10759a959f19

I recall some recent discussion about file extensions
here, but don't remember the thread. Another way to
deal with this would be with extensions. Maybe I'll
introduce basename.cg.cc and basename.cg.hh, where
'cg' is short for computer-generated. I'm not keen on
using 'generated' as that thread mentions since every
file is generated by either someone or something.
 
Ö

Öö Tiib

I've recently made some changes to how I'm doing things.  Previously
I
was using one .hh generated output file in all three of my tiers.  The
first change I made was to introduce a .cc file and move the code that
could be in  a .cc to that file.  The second thing I did was to
separate
things between the tiers -- in other words, I now have a .hh and .cc
for between the "back" and "middle" tiers and separate .hh and
.cc for between the "middle" and "front" tiers.  So that put me
at four files.  The last change implied another change -- factoring
out some constants into a fifth file I call type_nums.hh.  The first
four
files are named based on user input, but this file isn't.  Here's an
example of type_nums.hh based on this input:http://webEbenezer.net/misc/direct.mdl.

#ifndef type_nums_hh
#define type_nums_hh
uint16_t const File_num = 7001;
uint16_t const cmw_account_info_num = 7002;
uint16_t const cmw_user_input_num = 7003;
uint16_t const cmw_request_num = 7004;
#endif

Obviously, people could have a file with this name in their
code and I could inadvertently wipe out their file.  I've
thought of adding a prefix to the type_nums name to
minimize this risk and also thought about isolating the generated
files in a subdirectory.   Maybe I should do both.  Thoughts?
Thanks in advance.

Yes, tools often use uncommon extensions for tool-generated code
(like .hxx and .cxx) also they often generate into separate directory
from the human-written code. At least add options for your tool to
make that possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top