Friday, October 12, 2018

Artistic Multitasking


Multithreading is a wonderful tool but you need to use it very carefully. First don't use it recklessly, as there are specific instances where it is of most benefit (see this post for examples). If you are not in a "cloud" environment that scales-out to add additional CPUs as required, then I have four tips to help you along your way.

1. Tip 1 is to be sure to assign the Name property an each thread you start. This is really the only way to tell which thread caused exceptions and is the only clue when you're debugging of how you got here. Use a name relevant to the instigator method and the serial count of that particular thread.

2. Think in terms of threads working on an instance of an object. This helps keep multiple threads from stepping on each others memory space. Put all the values for input into properties of your new object, create a method in that object that performs the "heavy lifting" and deep calculations, and then execute that method through the thread.Start (placing return values back into a property). As an added tip I like to build an array-list of all the objects I have actively submitted to threads; when the thread terminates I can pop its values out of the array and then null out its instance.

3. If you anticipate that you may ever need the capability to abort the thread you are starting (for example if the user cancels the operation) it is far far better to make provisions for this within the thread, in the method you are executing, rather than using thread.Abort. I usually create a boolean property in my main class called panicStop. All threads check this value within each iteration of a for-loop, and bail out appropriately.

4. Manage the quantity of threads you allow to run simultaneously. Beyond a certain threshold (depending on the number of CPUs on your box and other factors) firing more threads doesn't aid performance much. So manage it.

Multithreading works great as long as you remember to use it for appropriate tasks, and pass each thread a new object to work on. Remember that you are flowing parallel, but in separate "streams", so as to avoid conflating the instance of each object.


Tuesday, September 18, 2018

Artful Minimalism


Nowadays you can buy development tools that incorporate tons of form-behind widgets and code generation that can produce web pages with pop-out scroll overs, call-outs, and just about every kind of special effect imaginable. Is all of this necessary?

Unless you are building a data entry form (which has its own special challenges) you are probably better off just to make sure your web pages meet a certain set of minimum requirements. After you have thrown together your page, run it through a few simple tests:

1) Window Resizing
Open your page in a browser and resize the window to various heights and widths to see what happens. Did your layouts get mashed? Do you need to change column widths from fixed to a percentage?

2) W3C compatibility
Submit your page to the free W3C verifier, just as a courtesy check to assure that your tags are all balanced and that your links are all valid.

3) Powersave Mode
Fire up a browser on a smaller screen device and in the browser options turn off the setting that allows the web pages to "set their own colors." Also go into the properties tab on your desktop and change the color scheme to a power saving configurations, with a black background and white text. Now open up your web page to see what happened. Do you need to remove some "color" tags to keep it legible?

4) Just The Facts
Go back into the browser settings and turn off automatic image loading. Refresh your web page. Does it still make sense with just the facts? Did you provide the necessary alt tags so that the user can still figure out where to click for navigation?

Sure, spinning flashing widgets are fun to view on your site. For all of about ten seconds. What stays as important though is the actual informative content that you provide. Try to make it work under all conditions.


Tuesday, August 14, 2018

Artful Influence


The art of software development can be much more than accomplishing projects. Often the successful path begins by focusing beyond the project at hand -- you need to review everything you can think of: personalities, creative ideas, political issues, hidden agendas, insecurities, technical questions, doubts about the future direction of technology, everything.

You may find a need to be intensely aware of a company's culture. At other times it may appear that your real purpose is to change the culture, and your development project is just a means to achieve that end. You may also need to include a bit of an appraisal as to the strategic direction and positioning of your company: it might be wrong for you to try to turn your employer into the Nordstrom's of retailers if its intentions and strategy is to be the K-mart.

In some consulting environments your purpose is not to accomplish anything. Your project is actually an anti-project, the staff is against you, and you succeed by making the staff accomplish their own agenda. You must use grace to provide a backflow, purposefully pointing away from their objectives. Occasionally you can be successful overall (and act in the best interest of your retainer) even though your own personal accomplishments and monthly status reports might lack a certain luster.

Around one quarter of software design could be considered "art" in every sense of the word. Congruent to other creative arts a software designer encapsulates thought into both visual and written structures. Sometimes though the whole point of creating software is to go through the process of meeting with people and moving them from their preconceived positions to change the culture, nature, and very heart of your employer. So once in a while the parallels to art go deep down to its truer purpose: to move people's souls.