Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > code generation advice

Reply
Thread Tools

code generation advice

 
 
Ebenezer
Guest
Posts: n/a
 
      04-21-2011

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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-21-2011
On 04/21/11 02:57 PM, Ebenezer wrote:
>
> 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?

--
Ian Collins
 
Reply With Quote
 
 
 
 
Ebenezer
Guest
Posts: n/a
 
      04-21-2011
On Apr 20, 10:11*pm, Ian Collins <(E-Mail Removed)> wrote:

>
> 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.
 
Reply With Quote
 
Ebenezer
Guest
Posts: n/a
 
      04-22-2011
This is a little related:

http://social.msdn.microsoft.com/For...a-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.
 
Reply With Quote
 
Öö Tiib
Guest
Posts: n/a
 
      04-23-2011
On Apr 21, 5:57*am, Ebenezer <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed in sine generation of vhdl code. senthil VHDL 4 03-17-2010 09:55 AM
Code Generation CGuy ASP .Net 0 06-29-2004 03:10 PM
HTML Generation (Next Generation CGI) John W. Long Ruby 4 11-24-2003 04:24 AM
Announce: O/R mapping and code generation... Wes ASP .Net 0 11-19-2003 07:51 PM
code generation Ruslan ASP .Net 1 09-10-2003 01:11 PM



Advertisments