Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how to implement the "many tiny functions" paradigm?
Replies: 7   Last Post: Jan 10, 2013 4:10 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,823
Registered: 7/26/08
Re: how to implement the "many tiny functions" paradigm?
Posted: Jan 10, 2013 2:12 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

kj <no.email@please.post> wrote in message <kckj4h$m4s$1@reader1.panix.com>...
>
>
> One of the most often cited coding "best practices" is to avoid
> structuring the code as one "large" function (or a few large
> functions), and instead to break it up into many tiny functions.
> One rationale for this strategy is that tiny functions are much
> easier to test and debug.


I would be careful when applying blindly this "best practice". MATLAB have huge running performance penalty due to function overhead (as opposed to other programming language as C, fortran, ...)

You will slow down the code by putting simple (scalar) arithmetic expressions in function. If the expression is vectorized and supposes to operate on big array, then it's OK to put it in the functions.

Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.