Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #28745

Re: what is the best way

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: what is the best way
Date 2012-11-29 08:30 +1300
Message-ID <ahn72dFn8fdU7@mid.individual.net> (permalink)
References (3 earlier) <k93l11$8kp$1@dont-email.me> <ahl79gFn8fdU4@mid.individual.net> <k93rh8$3ks$1@dont-email.me> <ahlapvFn8fdU6@mid.individual.net> <0f724d75-0cd2-4d2b-af1b-807e3acb704a@googlegroups.com>

Show all headers | View raw


Malcolm McLean wrote:
> On Wednesday, November 28, 2012 2:21:50 AM UTC, Ian Collins wrote:
>> Les Cargill wrote:
>>
>>> I dunno - at least conceptually, it's simpler for me if I hold
>>> to a separately compiled module being roughly a "class", where the
>>> header is the "interface".
>>
>> Ah, I see a different in metaphor here.
>>
>> I would describe the collection of source files (typically in their own
>> directory with a makefile) used to implement the interface declared in a
>> header as a module.  You appear to be describing an individual source
>> file as a module.
>>
> I try to keep one module per file.
>
> So, for example, lets say I'm writing a string-intensive program that does a
> lot of counting of characters. I might have one module that does DNA
> sequences, and another that does protein sequences.
> So they'll both have
>
> /* count the number of times ch appears in str */
> static int countchars(char *str, int ch)

You forgot the const :)

> defined in the source file, purely to keep modules as one file, depending
> on nothing else.

That looks like code duplication for the sake of a doctrine.  This 
sounds like a text book example of when to use a shared library.

> But if a file becomes too complex, I will reluctantly split it.

That depends on your definition of "too complex".  Another good reason 
for splitting is "too slow": when a monolithic file takes longer to 
compile than the equivalent set of smaller files.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

what is the best way Andre <pas.mois@ailleur.be> - 2012-11-27 16:19 +0100
  Re: what is the best way Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-27 15:35 +0000
  Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-27 08:59 -0800
  Re: what is the best way James Kuyper <jameskuyper@verizon.net> - 2012-11-27 13:14 -0500
    Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 08:43 +1300
      Re: what is the best way James Kuyper <jameskuyper@verizon.net> - 2012-11-27 15:02 -0500
        Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 09:29 +1300
  Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 12:48 -0600
    Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 08:56 +1300
      Re: what is the best way Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-11-27 22:19 +0000
        Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 18:21 -0600
          Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-28 05:08 -0800
            Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-28 12:43 -0600
      Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 18:15 -0600
        Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 14:21 +1300
          Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:06 -0600
            Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 15:21 +1300
              Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:31 -0600
              Re: what is the best way glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-11-28 04:00 +0000
              Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-28 05:17 -0800
                Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-29 08:30 +1300
                Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 05:47 -0800
                Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-30 07:37 +1300
                Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 11:35 -0800
    Re: what is the best way Keith Thompson <kst-u@mib.org> - 2012-11-27 17:25 -0800
      Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:15 -0600
      Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-27 23:48 -0500
    Re: what is the best way Sergio Durigan Junior <sergiodj@riseup.net> - 2012-11-28 03:06 -0200
      Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-28 01:35 -0500
  Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-28 00:13 -0500

csiph-web