'Pocket' Functions
BlitzMax Forums/BlitzMax Programming/'Pocket' Functions
| ||
Modules are great and all, but every now and then I find myself reusing simple functions that aren't complicated enough to merit a module of their own. To make things easier I've made a zak.misc module to hold all of them. My question is, has anyone else had a similiar experience? And if so what was your solution? :) |
| ||
Copy and paste :( |
| ||
I currently have a single file (the largest in my project) that is filled with utility functions. I just stack them up there. There were a few times where I just needed to paste a bunch of code from there and write 5-10 lines of code to get a nice example running. |
| ||
I used to have that as well... including a misc include.. but now I have.. Math, Graphics, Timing, Sound, Fonts etc Nothing should be Misc Even if an include has only one function, you should put it into its own because later it will make more sense to add to it in the right spot. Misc mashups generally get cluttered and you start to forget what you have in there! I have a Core include that includes all those...includes :) |
| ||
:) Yeah I used to do it with seperate Includes in BlitzPlus, but so far I haven't collected enough utility(that's a better name for it) functions in BMax that I need to sort them out just yet. I've started going through my code folders to collect ones I may have missed so we'll see how many I end up with. I've also put up some of the more useful ones in a worklog here if anyone wants to compare. |
| ||
Import "..\Common\whatever.bmx" |
| ||
Maybe a little off topic, but related nevertheless: http://en.wikipedia.org/wiki/Aspect-oriented_software_development |
| ||
That's what imports are for. :D |
| ||
BMX files are essentially text files (and thus are small): be a good developer and save each "can't-be-reduced-further-but-is-a-'proof-of-concept'" in a "Misc/snippets" folder. |