MindManager 7 ToDoList AddIn development Part 5: minimizing Object overhead between classes

I’ve created quite a puzzle for myself.  In writing an AddIn that calls functions from custom Classes, I am forcing the AddIn to pass in all the data that would be needed in the custom code.  I’ve added a few helper functions to the ToDoListBuilder class including GetAllTasks(), IsTaskCompleted() and IsTopicATask().  These are easy because I’m passing simple variables into each function.

However, I haven’t yet wired up the primary function that will be called from the AddIn’s mmCommand_Click() event, and I haven’t decided what I need to pass down from the button_Click() to the cascade of encapsulated functions, nor how far down to pass any object like a baton.

It seems like it’d be correct to pass the MMInterop.Application object into the ToDoListBuilder code, but in passing the Application object to a GenerateToDoListItems() method, I’ll have to pass the Application object to at least one further layer of called functions such as GetAllToDoListMaps().  Or will I?

Now that I’m looking around, the Connect class has a private applicationObject variable.  While it seems unlikely I’d be able to make reference to that Class’ private variable from a called Class, there should be no reason why I couldn’t create another private variable in the ToDoListBuilder class as soon as the GenerateToDoListItems() method is called, and then call on that Class-wide variable from then on.

Reducing Memory Footprint of Application Object(s) without Passing References Everywhere

Here’s how the code around the Application object comes out from the Visual Studio AddIn Template wizard by default:

    public class Connect : Object, Extensibility.IDTExtensibility2
{
private Mindjet.MindManager.Interop.Application applicationObject; private Mindjet.MindManager.Interop.Command mmCommand;
... }

Changing the first declaration to public from private makes that applicationObject object available outside of the assembly as well as within it, so that pointers (references) to the object don’t have to be explicitly passed around the code.

Assuming that nothing can affect the state of the applicationObject, there should be no reason not to declare it as “public”.  I’m not entirely naive though — I assume there’s reasons why you’d want to do one and not the other, but I have to believe that any code running in the MindManager application should necessarily want/try to use a single application object anyway.

Solution: Static/Shared modifier

After bashing my skull into the wall of my ineptitude for a few days, I finally dislodged a bone fragment of useful info: the “static” modifier.  Somehow this does what I had expected the “public” keyword to accomplish — makes it possible to access the variable from outside the class, without having to instantiate another copy of the object.

Open Questions

Now I’m left wondering two things:

  1. What’s the lowest level of accessibility that the object needs?  Does it still need to be public, or would protected or less be acceptable?
  2. Under what circumstances would it be inadvisable to use the static modifier?  I can imagine that in theory, anything that is supposed to represent multiple objects should not be marked “static”, but that still leaves a ton of room for interpretation (and for subtle mistakes in code that will bite me only later).

Aside: Registry entries in Setup project Aren’t Automatically Installed

Idiot assumption of the day: just because I entered the correct Registry settings in the Setup project, doesn’t mean that when I Debug the Solution those settings will be automatically added to the computer’s Registry.  (Sigh, sometimes I surprise myself with how dense I can be.)

So which “hack” would be better — should I hand-enter the Registry settings I need (which seems pretty lame) or should I build the Setup project and actually install this AddIn (which might end up leaving behind stuff that I’ll need to rip out later after I’ve rev’d the AddIn a few times)?

I guess I’m going down the path of hand-entering the Registry settings.  I don’t like doing this, and I really wish debugging MindManager AddIns didn’t require this lame step, but it looks like I’ve got no better option.

NullReferenceException: When will I ever learn?

I can’t believe the number of times I get caught by this seemingly predictable error:

        private System.Collections.ArrayList toDoListItems; // building list of all Tasks to be emitted as the items for the ToDoList
        private Mindjet.MindManager.Interop.Application applicationObject; // local instance of the Application object

        public System.Collections.ArrayList GenerateToDoListItems(MMInterop.Application application)
        {
            System.Collections.ArrayList toDoListMaps; // collection of all maps to be searched for Task topics
            applicationObject = application; // sets the local variable equal to the value of the passed-in parameter
            toDoListMaps = GetAllToDoListMaps(); // generate the collection of maps to be enumerated and searched
            toDoListItems = new System.Collections.ArrayList(); // declare this to avoid a NullReferenceException when it's assigned below
            
            foreach (MMInterop.Document map in toDoListMaps)
            {
                    toDoListItems.AddRange(GetAllTasks(map));
            }
            return toDoListItems;
        }

I really don’t get why I don’t have to declare the “new toDoListMaps” object, but I have to declare the “new toDoListItems”.  Is there something about creating the object inside the method that implicitly initializes it, but this implicit initialization doesn’t occur for objects that are created outside of the method?

And why does creating an int object not require initialization, but creating an ArrayList object does?  This might make sense to veteran coders, but my god it’s confusing for those of us just trying to get their first few apps out the door…

Advertisements

2 thoughts on “MindManager 7 ToDoList AddIn development Part 5: minimizing Object overhead between classes

  1. Hi,Nice Blog!We scan millions of documents for companies throughout. We scan < HREF="http://e-datapro.net/" REL="nofollow">data coding<>, documents of all types and sizes to all standards including, TIFF, JPEG, High Compression PDF, Black & White, Grayscale and true Color. We will scan 150 to 1200 dpi. We also provide specialist scanning for delicate documents and larger sizes. We are capable of scanning books & paper up to A0. We are equipped with the latest high speed scanning equipment and our scanning services are probably one of the lowest cost services you will ever find.

    Like

  2. < HREF="http://black-mold-exposure-symptoms.blogspot.com/2008/03/health-problems-from-mold.html" REL="nofollow">black mold exposure<>< HREF="http://black-exposuremold-symptom.blogspot.com/2008/03/black-exposure-mold-symptom.html" REL="nofollow">black mold symptoms of exposure<>< HREF="http://iron-garden-gates.blogspot.com/2008/03/hand-crafted-by-renown-metal-artists.html" REL="nofollow">wrought iron garden gates<>< HREF="http://wrought-iron-gates.blogspot.com/2008/03/wrought-iron-doors-are-one-of-many.html" REL="nofollow">iron garden gates find them here<>< HREF="http://hairstyles-for-fine-thinhair.blogspot.com/2008/03/hair-styles-for-fine-thin-hair.html" REL="nofollow">fine thin hair hairstyles<>< HREF="http://hairstyles-forfine-thinhair.blogspot.com/2008/03/hair-styles-fine-thin-hair.html" REL="nofollow">search hair styles for fine thin hair<>< HREF="http://purchase-nightvision-vinoculars.blogspot.com/2008/03/purchase-night-vision-binoculars.html" REL="nofollow">night vision binoculars<>< HREF="http://purchasenightvisionbinoculars.blogspot.com/2008/03/purchase-night-vision-binoculars.html" REL="nofollow">buy night vision binoculars<>< HREF="http://allergicreaction-tolipitor.blogspot.com/2008/03/allergic-reaction-to-lipitor.html" REL="nofollow">lipitor reactions<>< HREF="http://lipitoralcohol.blogspot.com/2008/03/lipitor-and-alcohol.html" REL="nofollow">lipitor allergic reactions<>< HREF="http://beach-resort-philippines.blogspot.com/2008/03/beach-resort-philippines.html" REL="nofollow">luxury beach resort in the philippines<>< HREF="http://beachresort-inthe-philippines.blogspot.com/2008/03/beach-resort-in-philippines.html" REL="nofollow">afordable beach resorts in the philippines<>< HREF="http://homeopathycures-foreczema.blogspot.com/2008/03/homeopathy-cures-for-eczema.html" REL="nofollow">homeopathy for eczema.<>< HREF="http://homeopathycures-forbabyeczema.blogspot.com/2008/03/homeopathy-cures-for-baby-eczema.html" REL="nofollow">baby eczema.<>< HREF="http://mineral-makeup-bargains.blogspot.com/2008/03/mineral-makeup-bargains.html" REL="nofollow">save big with great mineral makeup bargains<>< HREF="http://bargain-minera-makeup.blogspot.com/2008/03/bargain-mineral-makeup.html" REL="nofollow">mineral makeup wholesalers<>< HREF="http://prodamiphone-praha.blogspot.com/2008/03/now-iphone-owners-can-unlock-iphone.html" REL="nofollow">prodam iphone <>< HREF="http://prodam-iphone-praha.blogspot.com/2008/03/prodam-iphone-praha.html" REL="nofollow">Apple prodam iphone praha<>< HREF="http://iphone-clonecect-manual.blogspot.com/2008/03/iphone-clone-cect-manual.html" REL="nofollow">cect iphone manual<>< HREF="http://manual-iphoneclone-cect.blogspot.com/2008/03/iphone-clone-cect.html" REL="nofollow">manual for P 168 iphone<>< HREF="http://fero52-binoculars-nightvision.blogspot.com/2008/03/fero-52-binoculars-night-vision.html" REL="nofollow">fero 52 binoculars<>< HREF="http://fero52-nightvisionbinoculars.blogspot.com/2008/03/good-binocular-dealer.html" REL="nofollow">night vision Fero 52 binoculars<>< HREF="http://night-vision-binocularshtm.blogspot.com/2008/03/night-vision-binoculars-htm.html" REL="nofollow">The best night vision binoculars here<>< HREF="http://nightvision-binocularshtm.blogspot.com/2008/03/night-vision-binoculars.html" REL="nofollow">night vision binoculars bargains<>< HREF="http://computerprograms-tomake-photoalbum.blogspot.com/2008/03/computer-programs-to-make-photo-albums.html" REL="nofollow">free photo albums computer programs<>< HREF="http://computerprograms-make-photoalbums.blogspot.com/2008/03/photo-albums-programs.html" REL="nofollow">free software to make photo albums<>< HREF="http://freeprintabletaxforms.blogspot.com/2008/03/free-printable-tax-forms.html" REL="nofollow">free tax forms<>< HREF="http://free-printable-taxforms.blogspot.com/2008/03/free-printable-tax-forms.html" REL="nofollow">printable tax forms for free <>< HREF="http://craftmatic-adjustable-airbed.blogspot.com/2008/03/craftmatic-adjustable-air-bed.html" REL="nofollow">craftmatic air bed<>< HREF="http://craftmaticadjustableairbed.blogspot.com/2008/03/craftmatic-adjustable-air-bed.html" REL="nofollow">craftmatic air bed adjustable info here<>< HREF="http://boyd-night-airbed.blogspot.com/2008/03/boyd-night-air-bed.html" REL="nofollow">boyd air bed<>< HREF="http://boydnightairbed.blogspot.com/2008/03/boyd-night-air-bed.html" REL="nofollow">boyd night air bed lowest price<>< HREF="http://airbedinwisconsin.blogspot.com/2008/03/air-bed-in-wisconsin.html" REL="nofollow">find air beds in wisconsin<>< HREF="http://airbeds-wisconsin.blogspot.com/2008/03/air-bed-in-wisconsin.html" REL="nofollow">best air beds in wisconsin<>< HREF="http://cloudair-inflatablebed.blogspot.com/2008/03/cloud-air-inflatable-bed.html" REL="nofollow">cloud air beds<>< HREF="http://cloudairinflatablebed.blogspot.com/2008/03/cloud-air-inflatable-bed.html" REL="nofollow">best cloud inflatable air beds<>< HREF="http://portable-sealy-airbed.blogspot.com/2008/03/portable-sealy-air-bed.html" REL="nofollow">sealy air beds portable<>< HREF="http://portablesealyairbed.blogspot.com/2008/03/portable-sealy-air-bed.html" REL="nofollow">portables air beds<>< HREF="http://aluminum-rvluggage-racks.blogspot.com/2008/03/aluminum-rv-luggage-racks.html" REL="nofollow">rv luggage racks<>< HREF="http://aluminumrvluggageracks.blogspot.com/2008/03/aluminum-rv-luggage-racks.html" REL="nofollow">aluminum made rv luggage racks<>< HREF="http://airbed-formraised.blogspot.com/2008/03/air-bed-form-raised.html" REL="nofollow">air bed raised<>< HREF="http://airbedformraised.blogspot.com/2008/03/air-bed-form-raised.html" REL="nofollow">best form raised air beds<>< HREF="http://support-equipments-aircraft.blogspot.com/2008/03/support-equipments-aircraft.html" REL="nofollow">aircraft support equipments<>< HREF="http://support-equipmentsaircraft.blogspot.com/2008/03/support-equipments-aircraft.html" REL="nofollow">best support equipments for aircrafts<>< HREF="http://informercialsbedair.blogspot.com/2008/03/informercials-bed-air.html" REL="nofollow">bed air informercials<>< HREF="http://informercials-bedair.blogspot.com/2008/03/informercials-bed-air.html" REL="nofollow">best informercials bed air<>< HREF="http://mattress-sized-airbeds.blogspot.com/2008/03/mattress-sized-air-beds.html" REL="nofollow">mattress sized air beds<>< HREF="http://mattresssized-airbeds.blogspot.com/2008/03/mattress-sized-air-beds.html" REL="nofollow">bestair bed mattress <>< HREF="http://antiquedoorknob-identification.blogspot.com/2008/03/antique-doorknob-identification.html" REL="nofollow">antique doorknobs<>< HREF="http://antique-doorknob-identification.blogspot.com/2008/03/antique-doorknob-identification.html" REL="nofollow">antique doorknob identification tips<>< HREF="http://troubleshootingdvdplayer.blogspot.com/2008/03/troubleshooting-dvd-player.html" REL="nofollow">dvd player troubleshooting<>< HREF="http://troubleshooting-dvd-player.blogspot.com/2008/03/troubleshooting-dvd-player.html" REL="nofollow">troubleshooting with the dvd player<>< HREF="http://flatpaneltelevisionlcd-versusplasma.blogspot.com/2008/03/flat-panel-television-lcd-versus-plasma.html" REL="nofollow">flat panel television lcd vs plasma<>< HREF="http://flatpaneltvlcd-versusplasma.blogspot.com/2008/03/flat-panel-television-lcd-versus-plasma.html" REL="nofollow">flat panel lcd television versus plasma pic the best<>< HREF="http://causesof-economicrecession.blogspot.com/2008/03/causes-of-economic-recession.html" REL="nofollow">The causes of economic recession<>< HREF="http://causesofeconomicrecession.blogspot.com/2008/03/causes-of-economic-recession.html" REL="nofollow">what are the causes of economic recession<>< HREF="http://bed-airfoam-adjustable.blogspot.com/2008/03/bed-air-foam-adjustable.html" REL="nofollow">adjustable bed air foam <>< HREF="http://bedairfoamadjustable.blogspot.com/2008/03/bed-air-foam-adjustable.html" REL="nofollow">The best bed air foam <>< HREF="http://hoofprintsantiqueequestrian.blogspot.com/2008/03/hoof-prints-antique-and-unusual.html" REL="nofollow">hoof prints antique equestrian prints<>< HREF="http://hoofprints-antique-equestrianprints.blogspot.com/2008/03/hoof-prints-antique-and-unusual.html" REL="nofollow">antique hoof prints equestrian prints<>< HREF="http://buy-adjustable-airbed.blogspot.com/2008/03/buy-adjustable-air-bed.html" REL="nofollow">Buy air bedadjustable<>< HREF="http://buyadjustableairbed.blogspot.com/2008/03/buy-adjustable-air-bed.html" REL="nofollow">buy the best adjustable air beds<>< HREF="http://air-bedscanadian-stores.blogspot.com/2008/03/air-bedscanadian-stores.html" REL="nofollow">air beds canadian stores<>< HREF="http://airbedscanadianstores.blogspot.com/2008/03/air-bedscanadian-stores.html" REL="nofollow">Canadian stores for air beds<>< HREF="http://floridamigraineheadacheclinic.blogspot.com/2008/04/florida-migraine-headache-clinic.html" REL="nofollow">migraine cause<>< HREF="http://migraineheadacheclinicflorida.blogspot.com/2008/04/florida-migraine-headache-clinic.html" REL="nofollow">migraine treatments florida<>< HREF="http://florida-migraineheadache-clinic.blogspot.com/2008/04/miss-brown-told-me-i-am-constantly.html" REL="nofollow">florida headache clinic<>< HREF="http://airdryerdessicantbed.blogspot.com/2008/04/air-dryer-dessicant-bed.html" REL="nofollow">drying dessicant<>< HREF="http://air-dryer-dessicant-bed.blogspot.com/2008/04/air-dryer-dessicant-bed.html" REL="nofollow">air drying dessicant<>< HREF="http://airbed-dryerdessicant.blogspot.com/2008/04/air-dryer-dessicant-bed.html" REL="nofollow">dessicant air dryer<>< HREF="http://asthmaspecialistinvirginia.blogspot.com/2008/04/asthma-specialist-in-virginia.html" REL="nofollow">pediatric asthma<>< HREF="http://asthma-specialist-virginia.blogspot.com/2008/04/asthma-specialist-in-virginia.html" REL="nofollow">asthma specialist<>< HREF="http://virginia-asthma-specialists.blogspot.com/2008/04/asthma-specialist-in-virginia.html" REL="nofollow">asthma children specialist<>< HREF="http://dallasbestprofessionalcarpetcleaning.blogspot.com/2008/04/dallas-best-professional-carpet.html" REL="nofollow">carpet cleaning dallas tx<>< HREF="http://dallas-professional-carpetcleaning.blogspot.com/2008/04/dallas-best-professional-carpet.html" REL="nofollow">carpet cleaners dallas<>< HREF="http://dallas-professionalcarpetcleaning.blogspot.com/2008/04/dallas-best-professional-carpet.html" REL="nofollow">carpet cleaning dallas<>< HREF="http://beachhomevacationvero.blogspot.com/2008/05/beach-home-vacation-vero.html" REL="nofollow">vero beach vacation<>< HREF="http://beach-homevacation-vero.blogspot.com/2008/05/beach-home-vacation-vero.html" REL="nofollow">vero beach vacations<>< HREF="http://verobeach-homevacation.blogspot.com/2008/05/beach-home-vacation-vero.html" REL="nofollow">beach vacation homes vero<>< HREF="http://vacationcondosmsbeach.blogspot.com/2008/05/ms-beach-vacation-condos.html" REL="nofollow">ms beach vacations<>< HREF="http://msbeach-vacationcondos.blogspot.com/2008/05/ms-beach-vacation-condos.html" REL="nofollow">ms beach vacation<>< HREF="http://msbeach-vacation-condos.blogspot.com/2008/05/ms-beach-vacation-condos.html" REL="nofollow">ms beach condos<>< HREF="http://mauibeach-vacationclub.blogspot.com/2008/05/maui-beach-vacation-club.html" REL="nofollow">maui beach vacation<>< HREF="http://mauibeachvacationclub.blogspot.com/2008/05/maui-beach-vacation-club.html" REL="nofollow">maui beach vacations<>< HREF="http://maui-beachvacation-club.blogspot.com/2008/05/maui-beach-vacation-club.html" REL="nofollow">maui beach club<>< HREF="http://bestbeach-vacations.blogspot.com/2008/05/best-beach-vacations.html" REL="nofollow">beach vacations<>< HREF="http://thebestbeachvacations.blogspot.com/2008/05/best-beach-vacations.html" REL="nofollow">your beach vacations<>< HREF="http://vacationsinthebestbeach.blogspot.com/2008/05/best-beach-vacations.html" REL="nofollow">cheap beach vacations<>< HREF="http://layered-bob-haircuts.blogspot.com/2008/07/bob-layered-haircuts.html" REL="nofollow">bob hairstyle<>< HREF="http://boblayeredhaircuts.blogspot.com/2008/07/bob-layered-haircuts.html" REL="nofollow">bob haircuts<>< HREF="http://bob-layered-haircuts.blogspot.com/2008/07/bob-layered-haircuts.html" REL="nofollow">bob layered<>< HREF="http://best-classic-bob-haircuts.blogspot.com/2008/06/classic-bob-haircuts.html" REL="nofollow">pob hairstyle<>< HREF="http://classicbobhaircuts.blogspot.com/2008/06/classic-bob-haircuts.html" REL="nofollow">bobbed<>< HREF="http://classic-bob-haircuts.blogspot.com/2008/06/classic-bob-haircuts.html" REL="nofollow">classic bob<>< HREF="http://haircareandcurlyhair.blogspot.com/2008/07/hair-care-for-curly-hair.html" REL="nofollow">Care for Curly Hair<>< HREF="http://haircare-curlyhair.blogspot.com/2008/07/hair-care-for-curly-hair.html" REL="nofollow">Tips for Curly Hair<>< HREF="http://hair-care-for-curly-hair.blogspot.com/2008/07/hair-care-for-curly-hair.html" REL="nofollow">curly hair<>< HREF="http://truck-bus-tires12r22-5bestprices.blogspot.com/2008/07/tires-truck-bus-tires12r-225-best-price.html" REL="nofollow">12r 22.5 best price<>< HREF="http://tires-truckbus-12r22-5-bestprices.blogspot.com/2008/07/tires-truck-bus-tires12r-225-best-price.html" REL="nofollow">tires truck bus<>< HREF="http://tirestruckbus12r22-5bestprice.blogspot.com/2008/07/tires-truck-bus-tires12r-225-best-price.html" REL="nofollow">tires 12r 22.5<>

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s