Hi Vladimir,
In the example above, the code length of the function does not matter. When used in Table or Map it can have a short name for convenience.
If you want to run "parts" of the function alone or in different combinations, then you might want separate functions for these computations. You can also build functions which perform some computation by calling these sub-functions.
If you are exploring some dataset in a really interactive way, remember that while you are working in the notebook, it is really just an interface to the kernel. It is the kernel that contains the state of the system. For example, I sometimes work with a notebook with various analysis tools that operated an a dataset. I can import a dataset, then analyze it as I like. I can go back up to the top of the notebook, import a new dataset, then go to the various cells for analysis, again. The order in which cells appear in a notebook is only significant when you evaluate the cells sequentially.
I don't know of a way to define a function across multiple cells. I often develop a function by going through a computation in multiple cells.
starting the work on some named object. When I am confident it's all working as expected, I merge cells into a module definition which accepts that starting name as an argument. Then I can use that function as I like, for example by mapping it onto a list of file names to analyze the set.
I have thought at times that it would be nice to uses notebooks this way: to call several notebooks from a master notebook to perform computations. I suspect it can be done, but I've never come upon a method that seemed like it would become routine for me.
Best, David