code generation advice

Discussion in 'C++' started by Ebenezer, Apr 21, 2011.

  1. Ebenezer

    Ebenezer Guest

    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
     
    Ebenezer, Apr 21, 2011
    #1
    1. Advertising

  2. Ebenezer

    Ian Collins Guest

    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
     
    Ian Collins, Apr 21, 2011
    #2
    1. Advertising

  3. Ebenezer

    Ebenezer Guest

    On Apr 20, 10:11 pm, Ian Collins <> 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.
     
    Ebenezer, Apr 22, 2011
    #3
  4. Ebenezer

    Ebenezer Guest

    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.
     
    Ebenezer, Apr 22, 2011
    #4
  5. Ebenezer

    Öö Tiib Guest

    On Apr 21, 5:57 am, 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.
    >
    > #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.
     
    Öö Tiib, Apr 23, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Asun Friere
    Replies:
    1
    Views:
    513
    Paul Boddie
    Aug 27, 2003
  2. Peter Hansen
    Replies:
    23
    Views:
    896
    Anton Vredegoor
    Sep 5, 2003
  3. Gerrit Holl
    Replies:
    16
    Views:
    631
    Tom Plunket
    Aug 29, 2003
  4. Asun Friere
    Replies:
    0
    Views:
    487
    Asun Friere
    Aug 28, 2003
  5. John W. Long

    HTML Generation (Next Generation CGI)

    John W. Long, Nov 22, 2003, in forum: Ruby
    Replies:
    4
    Views:
    373
    John W. Long
    Nov 24, 2003
Loading...

Share This Page