I\'ve read:
and I
We use meta-programming a lot to create properties in VBA. We have various Excel spreadsheets with many headers on them and we want to define getter/setter properties for each header, allowing us to manipulate cells under that header. Manually doing this would be a nightmare.
The meta programming framework of choice for us was Notepad++ and its find/replace regular expressions capabilities. Here is how we meta-programmed our properties:
At the end of this we have a process that's a mixture of manual steps, recorded macros and a regex that we can re-apply every time we want properties for a sheet. And we did! To great effect.
That's the power of meta-programming. When to use it is a matter of experience/intuition. But I recommend answering this question:
Will if be quicker for me to just code this directly, or can I automate some/all of the process, and speed up my process?
That gives you a line to draw beyond which meta-programming is no longer useful. If you can just code it quicker, even if it's 10 repetitions, just do it! Only if it's hundreds of repetitions, or it's something you expect to reuse many times in future then meta program it.
Another point is that there are degrees here. I once wrote a Java program to create a bunch of files for adding a new IntelliJ inspection to an inspections coding project. That was a fair bit of overhead: creating the Java project and compiling it etc. On the other hand, Notepad++ find/replace is just a tiny step above manually typing stuff yourself. The advice here is to start doing things manually and then automate as you see a need, only up to the point where it makes sense. No need for a Java program when Notepad++ will do. No need for Notepad++ when manually typing it will do.