dhazer
Programmer
- Oct 20, 2006
- 48
I'd like suggestion from you guys on how you structure your files and code to be as flexible and as modular as possible.
For example, I was adding logging functionality to a package of scripts of mine.
However, logging functionality would be very helpful for several other Aspect scripts. So I've tried to make considerations that could allow me to "drop" my logging code into another script with little to no modifications.
Recently, to make code more modular, I am using local variables as much as possible (to reduce namespace conflicts). It's to bad you can't embed a procedure within an existing procedure, otherwise I'd be doing that also.
Second, I also try to uncouple each function or procedure from others as much as possible by avoiding calls to other func's and proc's at most costs; that way changes to other func's and proc's don't break older code.
Third, I try to strategically use the "#include" statements.
For included files that I religiously include in my scripts, I have an "includes" folder at the top of my file structure; in the same root folder are folders named for the projects they contain. That way, any scripts that need to include files just include them with the path ascending to the root folder and go into the "includes" folder. For example: #include "..\includes\stripSpaces.was"
Any best-practice suggestions of your own? (or things you don't like about my suggestions)
For example, I was adding logging functionality to a package of scripts of mine.
However, logging functionality would be very helpful for several other Aspect scripts. So I've tried to make considerations that could allow me to "drop" my logging code into another script with little to no modifications.
Recently, to make code more modular, I am using local variables as much as possible (to reduce namespace conflicts). It's to bad you can't embed a procedure within an existing procedure, otherwise I'd be doing that also.
Second, I also try to uncouple each function or procedure from others as much as possible by avoiding calls to other func's and proc's at most costs; that way changes to other func's and proc's don't break older code.
Third, I try to strategically use the "#include" statements.
For included files that I religiously include in my scripts, I have an "includes" folder at the top of my file structure; in the same root folder are folders named for the projects they contain. That way, any scripts that need to include files just include them with the path ascending to the root folder and go into the "includes" folder. For example: #include "..\includes\stripSpaces.was"
Any best-practice suggestions of your own? (or things you don't like about my suggestions)