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


Groups > comp.programming > #7728

for-loops in the main function or in the subfunctions?

From Victor Porton <porton@narod.ru>
Newsgroups comp.programming
Subject for-loops in the main function or in the subfunctions?
Date 2017-04-19 23:48 +0300
Organization Aioe.org NNTP Server
Message-ID <od8ien$1ln1$1@gioia.aioe.org> (permalink)

Show all headers | View raw


I write a function (or rather an OO method) which generates a list of errors 
for a set of transactions (for a moment forget what exactly the word 
"transaction" means, it is irrelevant for my question).

Some errors are per-transaction and some are characterization of the entire 
set of transactions (for example, they may depend on the sum of the paid 
values for all transactions in the set).

Should I make for-loop iterating the transactions in the set in my main 
function or make such loops in the sub-functions which I call (directly or 
indirectly) from the main function?

The first variant (to put the loops into the main function) is a bit shorter 
and a tiny bit faster. However I am unsure about advantages of the second 
variant (to put the loops into the sub-functions rather than in the main 
function).

-- 
Victor Porton - http://portonvictor.org

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


Thread

for-loops in the main function or in the subfunctions? Victor Porton <porton@narod.ru> - 2017-04-19 23:48 +0300
  Re: for-loops in the main function or in the subfunctions? Julio Di Egidio <julio@diegidio.name> - 2017-04-19 15:04 -0700

csiph-web