[fpc-other] To nest or not to nest
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Thu Jul 5 19:33:11 CEST 2018
On 07/05/18 08:59, Santiago A. wrote:
> 1) In OOP, they save me jumping to the interface to declare things.
That's what I love about Java (compared to Object Pascal and C/C++) - no
header required. Makes the code so much simpler, and I can drag and drop
to reorder methods as needed.
Anyway, I think Lazarus IDE can automatically declare methods for you in
the interface section - I think.
> 2) It shortens bodies, so they can fit in a screen.
> 2) It allows me declaring objects near to where they are used and easily
> encapsulate variable names.
> 3) They save a little of stack.
Overall, it's your preference. At least the good thing is, your are
breaking up large bodies of code into smaller chuncks. That's a good thing.
Alternatively, I'll create a class that does all the work I need. That
also makes it easier to unit test.
> The cons: Most tools are not very nested routines friendly. Debuggers
> have problems with them, code tools are not aware of nested routines.
I know for a fact the Procedure List functionality (Ctrl+G) does support
nested methods.
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-other
mailing list