I am working on an AutoCAD plugin. I have several methods that use
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database dataBase = doc.Database;
Editor editor = doc.Editor;
Would it be clean code to use those three lines at the beginning of my class and call doc
, dataBase
and editor
whenever I need them or is it better to declare them in each method?
It seems to save many lines of code but they kind of look like global variables which should be avoided as often as possible, right?
I've read several posts about global variables and fields but I can't seem to figure out whether or not I should use them that way.
Any thoughts on that are much appreciated.