Generally, people tend to feel that most working code - that is, your code which does things - should be modularized into functions and ideally stored in script modules.
That makes those functions more easily re-used. Those functions should exhibit a high level of reusability, such as accepting input only via parameters and producing output only as objects to the pipeline