yes, you are right - basically, you would add a helper function, and move such stuff to it - and then begin using it in the mfd file.
Personally, I would probably provide helpers to encapsulate the notion of a "navaid" and then create a child class inheriting from it to implement NDB/VOR classes.
At that point, you could easily encapsulate behavior such as setting the title/color, or even radial handling stuff.
Like I said, we still have tons of aircraft specific stuff in the mfd file, and that should really be moved to the style stuff (covering both styles we have obviously).
Once that is the case, we can look at refactoring the styles stuff to clean up things there and share more code.
But the first step really is cleaning up the mfd file to get rid of aircraft specifics, subsequently it may also make sense to get rid of ND specific assumptions there, so that the same mechanism could be used for other MFDs, at which point it may make sense to integrate that with Richard's MFD framework.
Anyway, for the time being, you can find tons of identical lines of code differing only slightly, e.g. due to the text/color or conditionals used - such things should be moved to helper functions.
If in doubt, I would first of all create a navdisplay.common file and move such stuff there, and simply use io.include() to still make it available.
But right now, the mfd file is an embarrassing, but highly functional
- mess unfortunately, begging to be be cleaned up.
For future reference (and new styles), I would also strongly recommend to review artix's work (the Airbus style) which is much more sophisticated than the original Boeing work meanwhile, and which is also using better coding patterns to organize all the code
Hopefully, the dialog I have protoyped can help with some of this, even if just with testing the existing functionality tto ensure that all the refactoring work doesn't break anything.
Please do feel free to get in touch if you are interested in helping with any of that, or if you need additional features in that dialog - apart from that, I would like to reiterate my request to document your whole journey and help us add to the wiki, if in doubt, just create a new article.
Besides, if there is anything you'd like to see better document to help with this kind of work, let us know, so that I can add a corresponding tutorial to the wiki - if you understand how to generalize aircraft specific code and move it to the styles file, you are basically half-way there, because it's not very complicated anymore at that point