Category: Development

Jul 21 2009

Lessons in Software Development From the Apollo Moon Missions.

apollo11_launch
Monday was the 40th anniversary of the Apollo 11 lunar landing. The story of the Apollo program is an historic and inspirational one, but it’s also relevant to software development.

To understand the significance of the Apollo program from an engineering standpoint, we must begin at the beginning…
Gus Grissom, Ed White and Roger B. Chaffee were killed on the launch pad when the Apollo 1 capsule burst into flames just prior to the launch test. What happened? Well, according to Wikipedia (I know, far from an unimpeachable source, but bear with me here):

“Although the ignition source of the fire was never conclusively identified, the astronauts’ deaths were attributed to a wide range of lethal design hazards in the early Apollo command module. Among these were the use of a high-pressure 100 percent-oxygen atmosphere for the test, wiring and plumbing flaws, flammable materials in the cockpit (such as Velcro), an inward-opening hatch that would not open in this kind of an emergency and the flight suits worn by the astronauts.”

In short, no one knows for sure what specifically caused the fire, but everyone agrees that some fundamental errors led to the conditions (whatever they ultimately were).

what really went wrong was at the planning and design stage. NASA was in such a rush to make up lost time in the space race with the USSR, that they got cocky after early successes, cut corners and went full bore toward a fully manned, Apollo capsule before they were really ready.

The precursor missions to Apollo were the Mercury and Gemini projects. These projects had highly specific mission statements and each was directed toward a discrete piece of the overall lunar landing mission. Project Mercury was directed toward getting a man into space, and back again. The goal of project Gemini was to perform extra-vehicular activity (pre-cursor to space walk), and docking maneuvers.

NASA began the mission to the moon with an iterative approach, but switch to a more waterfall like approach where they tried to construct a whole new capsule module from scratch, with the intent of landing on the moon and returning. They used the knowledge gained from the earlier Mercury and Gemini projects, but constructed new - and untested - equipment for Apollo.

The parallel to software development is using an iterative approach to develop phase I of a project, only to throw it away and start over on phase II. The whole purpose of the iterative approach is to focus on small, achievable parts of a greater whole to maintain momentum but also to limit what must be tested and hence limit (theoretically) the universe of possible bugs.

I think the 2 most important software development lessons we can learn from the Mercury, Gemini and Apollo missions are:

  1. To be successful, have clear and concise mission objectives (goals).
  2. Start small, and build on each success.

This is what made the Gemini and Mercury missions so successful, and ultimately made Apollo 11 possible and it will drastically improve the odds of your next software project being a success as well.

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Rookie and Beginner Woodwork Projects Just like with many other types of jobs, when it comes to woodwork projects, planning is of the utmost level of importance. Cutting wood and working with wood is always going to demand that you utilize careful planning and a step by step approach toward reaching the ultimate goal for......
  • How Home Improvement Software Can Help You Out If you are interested in home improvement these days, you also need to be interested in what the modern world can do for you as far as home improvement is concerned.  There is no type of handyman in today’s world that does not use the conveniences of modern technology to......
  • Advantages of software developers in freelance contract programming In any reputed software development firm the software developers are usually very experienced and expertise, but only in their own modules. In a recent survey it has been found that software developers do not wish to work in different modules in the same or a different project. As these developers......
  • City of Dreams Suffers a US$600 Million Cost Overrun As expected costs of the City of Dreams casino project continue to blowout, now by a whopping $US600 million! The estimated outlay is now $US2.1 billion compared with the previously reported $US1.85 billion in June and $US1.5 billion last December. We can foresee further cost overruns happening prior to the......
  • NetBeans and Eclipse, the developers best friends. Linux or Windows user, this is for everyone (even Mac OS X and Solaris), NetBeans and Eclipse. These two editors are both very good. Eclipse The Eclipse Project was originally created by IBM in November 2001 and supported by a consortium of software vendors. The Eclipse Foundation was created in......
Jul 14 2009

The 3 Most Important Questions You Should Ask About Each Bug You Find.

I stumbled upon (quite literally) an article by Tom Van Vleck titled Three Questions About Each Bug You Find today, and thought I would share it:

“The key idea behind these questions is that every bug is a symptom of an underlying process. You have to treat the symptoms, but if all you do is treat symptoms, you’ll continue to see more symptoms forever. You need to find out what process produced the bug and change the process. The underlying process that caused your bug is probably non-random and can be controlled, once you identify what happened and what caused it to happen.”

Tom uses these questions to get to the heart of the matter and weed out the root cause of the bug.

1. Is this mistake somewhere else also?

You want to know if this bug was unique, or due to a problem in a pattern of approach to the specific problem. If it’s unique, you can move on to the next question, but if it’s systemic, you’ll need to address your approach to the development problem the code was intended to solve and devise a new pattern or correct the one in place.

2. What next bug is hidden behind this one?

Often times a bug will either halt the execution of code, or cause the lines after the bug to be bypassed. once you fix the bug, those other lines of code will begin to execute. Be sure to check those for any bugs. Also, consider whether your fix to this bug could cause any new bugs to be introduced.

3. What should I do to prevent bugs like this?

Learn from this mistake. Could the problem be avoided by adding a new test condition to your NUnit test(s)? Should you implement a change to your pattern to check for null reference or out of bounds exceptions sooner? Bugs happen, but if you can use them as teachable moments and learn from them, then they will at least provide some value and make you less likely to run into the same bug in the future.

It’s not always an easy process, mostly because it requires a sort of detached introspection and willingness to be critical and objective when looking at your work. These character traits are not always in high supply, and we humans can often get in the way, but if you can master these techniques you will go far young padawan.

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Real Grooves and CLASH45 presents Bunka Vibe @ ageHa on Saturday July 4th L&G, Keen to celebrate Canada-Japan musical relations this Canada Day weekend? Well, Rotation is celebrating its 10th anniversary and getting back to its roots by bringing several of its original Canadian artists into a mini festival of sorts here in Tokyo at Ageha.  If you're keen to check it out,......
  • Android SDK Updates Today we are releasing updates to multiple components of the Android SDK: Android 2.0.1, revision 1 Android 1.6, revision 2 SDK Tools, revision 4 Android 2.0.1 is a minor update to Android 2.0. This update includes several bug fixes and behavior changes, such as application resource selection based on API......
  • Pregnancy Fetal Development at Week 1 Although it may seem strange to think about, the journey of your pregnancy actually begins before the baby has actually been conceived. The very first week of your pregnancy does not begin with conception, or with the growth of the fetus in your body, but rather it begins with the......
  • Language Development and your Four Year Old The preschool age is a wonderful age during childhood and I really enjoyed teaching children in this age group.  They are interested in learning about any topic from bugs to space and have countless questions for you to answer.  Developmentally, they should be at a level to really express their......
  • Descriptions Of Some Common Dog Health Problems by Moses Wright Some common dog health problems are preventable. Several health problems for dogs can have severe health consequences if not treated. Fleas are often seen as a nuisance instead of a dog health problem. However, fleas can cause skin irritation that can become severe and infected. Fleas can......
Jun 30 2009

10 Useful, Often Overlooked HTML Tags.

Pop quiz: When would you use the <wbr> tag, and what does it do?

Yeah, I had no idea either. In fact, I had never even seen this tag before, but it’s a list of 10 Rare HTML Tags You Really Should Know from Nettuts+

I have to say that most of these I hadn’t heard of, but they are actually quite useful. Granted, I do most of my work in the .NET code behind and middle ware layers, but I do occasionally get to sling a bit of HTML, and I think I may start using some of these…

Oh, I almost forgot - the <wbr> tag allows you to specify a place where you think a line break might be useful, if needed.

Blog Traffic Exchange Related Posts
  • Google Chrome: the OS. Google announced last Tuesday that it has its sights on dethroning Microsoft as desktop OS king: "The new operating system, announced late Tuesday night on Google's Web site, will be...
  • How to Delete Empty Folders - FREE! While performing a disk cleanup recently, I had cause to locate and delete any empty folders under a root folder. I knew there had to be a batch file command...
  • Lessons in Software Development From the Apollo Moon Missions. Monday was the 40th anniversary of the Apollo 11 lunar landing. The story of the Apollo program is an historic and inspirational one, but it's also relevant to software development....
  • How to fake a TreeNodeCollection subclass in .NET If you've ever had reason to try to extend the standard Microsoft web TreeView control, you will have no doubt noticed that MS was quite unkind to you and sealed...
  • IE7 WebControl TreeView line gap in quirks mode. I've been writing a subclass of the MS Webcontrol.TreeView control for one of our Web Applications at work. I figured this would be a fairly easy task, since I only...
Blog Traffic Exchange Related Websites
  • Meta Tags - An Introduction A long, long time ago In a galaxy far, far awaymeta tags were the key component to search engine rankings. Okay, it was about 2 years ago, but thats a long time in the Internet galaxy. Although still relevant, the evil empireer, Darth Google, has led a movement by......
  • Guidelines for Good Title Tag What is a Title Tag?A title tag is a piece of HTML code that describes a specific web pages content through a keyword query that a person types into a search engine. Title Tags are a very important guide for all search engines in determining what is in the......
  • Home Network Security [/caption] Home Computer security 1. What is computer security? Computer security is the process of preventing and detecting unauthorized use of your computer. Prevention measures help you to stop unauthorized users (also known as "intruders") from accessing any part of your computer system. Detection helps you to determine whether or......
  • How To Use Search Engine Optimization to Destroy Your Competition in 3 Easy Steps Search Engine Optimization - Secrets Revealed.Let's begin: What is 'competition'? Competition is described as "one that competes", "a rival", "selling or buying goods or sevices in the same market as another", and even down to the biological level - "an organism that lives in competition with another".SEO & Web......
  • Take Back America Election Clock The Take Back America Election Clock (seen at right) is inspired by Ray Stevens' hit song We the People. "You vote Obamacare, we're gonna vote you outta there" goes the song. Who are they? To help all of us remember who voted for Obamacare the NIP has developed the Countdown......
Jun 23 2009

How to fake a TreeNodeCollection subclass in .NET

If you’ve ever had reason to try to extend the standard Microsoft web TreeView control, you will have no doubt noticed that MS was quite unkind to you and sealed (or declared NotInheritable for you VB.NET types) the System.Web.UI.WebControls.TreeNodeCollection class.

The problem arises when you want to overload the default behavior that is implemented by the TreeNodeCollection class. For example, when a node was added to my TreeView class (via the TreeView.Nodes.add method), I needed to be able to analyze it for the ultimate purpose of my subclass.

However, this was not possible because the TreeNodeCollection class is sealed, so I wasn’t able to inherit from it and overload the add method behavior as I should have been able to do.

There are always possibilities.

Anyone who knows me knows I don’t give up easily (if ever), and I eventually plowed through many false starts but hit upon a solution.

I decided to wrap the underlying TreeNodeCollection class with my own, and overload the Nodes property on the TreeView class, and the ChildNodes property on the TreeNode class.

The Wrapper.

Here’s what the wrapper looks like:
[vb language=".net"]

Public Class MyTreeNodeCollection

Private mtvwChildNodes As System.Web.UI.WebControls.TreeNodeCollection
Private mMyTreeViewOwner As IMyNodeContainer

Public Sub New(ByVal Owner As IMyNodeContainer, _
ByVal TreeViewChildren As System.Web.UI.WebControls.TreeNodeCollection)
mtvwChildNodes = TreeViewChildren
mMyTreeViewOwner = Owner
End Sub

Public Sub Add(ByVal child As MyTreeNode)
mtvwChildNodes.Add(CType(child, System.Web.UI.WebControls.TreeNode))
mMyTreeViewOwner.RegisterNodeForLookup(child)
End Sub
End Class
[/vb]

As you can see, the constructor takes the real, underlying TreeNodeCollection to pass all node to prior to being “registered” (analyzed). It also takes something that implements the IMyNodeContainer interface.

The IMyNodeContainer interface.

I had to implement this because I wanted to be able to use this wrapper class for both TreeView and TreeNode objects, but the signature of their properties is different - TreeView.Nodes and TreeNode.ChildNodes, respectively. So I opted for the interface to keep things clean.

Here’s what the interface looks like:

[vb language=".net"]
Public Interface IMyNodeContainer

Sub RegisterNodeForLookup(ByVal node As MyTreeNode)
ReadOnly Property Nodes() As MyTreeNodeCollection

End Interface
[/vb]

Wrapping things up.

This is where the magic happens.

To put the wrapper (MyTreeNodeCollection) in place, I overload the collection getting properties in the base class - TreeView.Nodes and TreeNode.ChildNodes, respectively, like so:

[vb language=".net"]
Public Overloads ReadOnly Property Nodes() As MyTreeNodeCollection Implements IMyNodeContainer.Nodes
Get
Return mNodeCollection
End Get
End Property
[/vb]

So, for those of you playing along at home, when the developer calls .Nodes on an instance of MyTreeView class, an instance of MyTreeNodeCollection is returned and the resulting add method in performed on the underlying TreeNodeCollection, thusly:

[vb language=".net"]
Public Sub Add(ByVal child As MyTreeNode)
mtvwChildNodes.Add(CType(child, System.Web.UI.WebControls.TreeNode))
mMyTreeViewOwner.RegisterNodeForLookup(child)
End Sub
[/vb]

You can see why I had to use the IMyNodeContainer interface here. The RegisterNodeForLookup performs the functionality I was originally trying to subclass the TreeNodeCollection for.

Blog Traffic Exchange Related Posts
Jun 18 2009

Window.scrollTo Fails Under OVERFLOW-Y: auto Style.

I was trying to subclass a Web Treeview control for my own evil purposes and ran into a sticky problem - scrollTo not working! Just for background, my evil purpose was to replace the Infragistics ultra web tree control, since we only use about 5% of the functionality, but pay the full price of upgrades and page size for the other 95%.

anyway, all was going well, until I tried to implement the ScrollTo functionality.

My first pass looked something like this:

[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
window.scrollTo(ele.parentElement.offsetParent.offsetLeft ,ele.parentElement.offsetParent.offsetTop);
//–>
</Script>
[/javascript]

Now this worked great in my sample text page, but when I dropped it into the main application page, it didn’t do a damn thing. What gives?

Well, I traced the problem down to a style tag on the wrapping div tag:

[css]
OVERFLOW-Y: auto;
[/css]

It seems that the auto setting disallowed my scrolling to a specific x,y coordinate when that coordinate was outside the visible space.

That really stunk because I didn’t have the ability to modify the existing container page, beyond replacing the Infragistics control tag.

Luckily, I found a workaround:

[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
ele.scrollIntoView();
//–>
</Script>
[/javascript]

Not only does this work within the CSS overflow directive, but it’s also a bit more elegant since I no longer have to worry about all that parent offset nonsense. :)

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Optimizing Title Tags For Success Properly optimizing the title tag (or more appropriately, the HTML title element) of a web page can yield big benefits from a search engine optimization (SEO) perspective. The following document explains why titles are so important and provides useful tips on how to optimize a title tag.Title tags are......
  • SEO Report Overview Below is an overview of what is contained in our affordable SEO Report. If you would like to see a sample of this report that was run using our web site and specific keywords as well as search engine, please click on SEO Report Sample. Report Overview This section contains......
  • Website Optimization For Newbies - 3 Important Tips For Keyword Placement in Your Website Website optimization requires placing your main keywords in specific places on your web pages. After you have performed a keyword search and chosen the specific keywords that you want the search engines to recognize, you should place one or more of these keywords on each web page. But don't......
  • How To Avoid The 3 Biggest Title Tag Mistakes With Search Engines Your title tag is the most important 3 to 12 words on your Web page. It accounts for up to 80% of your rankings on search engines.Here's why:Search Engines look for "searched for" words first in title tags.The title tag is one of the main places search engines look......
  • Some tips to think about when deciding to have a web site built Judith Palfrey is a professional web site developer for 14 years and has developed some special websites to help small businesses advertise in their local community using the Internet. She is also the President of Shopping Portals, Inc. affiliated with Palfrey Associates. To learn more about her services visit: www.ShopGaithersburg.com,......
Jun 16 2009

IE7 WebControl TreeView line gap in quirks mode.

I’ve been writing a subclass of the MS Webcontrol.TreeView control for one of our Web Applications at work. I figured this would be a fairly easy task, since I only needed to extended it with a few properties. It turns out that I was caught on a nit-picky annoyance in the TreeView control itself.

The TreeView control renders verticals lines with gaps.

Here’s a screen cap of the problem.

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-line-break

As you can see, the TreeView control renders the vertical line with a gap, or break (looks like a dashed line!). It didn’t matter how I loaded the data - dynamic/runtime/design time - I get the same gap no matter what!

I was able to see that it was not a problem in IE 6 or less, but what good is that? Well, it turns out that it was a bit of a clue because starting with version 5, IE didn’t render things correctly per the CSS boxing specification. This was fixed in IE 7, but to provide backwards compatibility, Microsoft carried this busted form of rendering forward in IE 6 as QuirksMode. The line gap problem only occurs in strict mode (default for IE 7 and 8, as well as firefox). I could make the line gap go away by forcing the browser into QuirksMode (by adding a comment, ex:

< ! - - QUIRK! - - >

to the very top of the HTML file), but I was writing a web control and would not always have the luxury of controlling my container.

I needed to find a long term solution to this problem.

Next, I looked at the HTML source of the rendered page, and saw this:

[html]
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tr>
<td>
<div style="width:20px;height:1px">
<img src="/TreeviewControlTest/WebResource.axd?d=OYmDnVppVECKIpxOWC8o8Y7DO6QwB2J3EY4s4RR8zAU1&amp;t=633765128008804061" alt="">
</div>
</td>
<td>
<img src="/TreeviewControlTest/WebResource.axd?d=OYmDnVppVECKIpxOWC8o8UGy0bLoCc8gOB1oQm6Pzj81&amp;t=633765128008804061" alt="">
</td>
<td class="TreeView1_WebTree_1" style="white-space:nowrap;">
<a class="TreeView1_WebTree_0" href="javascript:__doPostBack(’TreeView1$WebTree’,'Root//Tree’)" onclick="TreeView_SelectNode(TreeView1_WebTree_Data, this,’TreeView1_WebTreet6′);" id="TreeView1_WebTreet6" name="TreeView1_WebTreet6">Tree</a>
</td>
</tr>
</table>
[/html]

Each node is rendered as a table, with the vertical line and expand/collapse icons being in their own table cell and wrapped in a div. The problem was the style applied to the outer div - style=”width:20px;height:1px“.

That 1px height was causing the vertical line image to be compressed, but where did it come from?

Reflecting on System.Web.UI.WebControls.TreeNode

I spent almost an hour delving into the various (and copious!) style properties for the tree and its nodes, looking for where this height setting was generating from. I couldn’t find it! I eventually opened the System.Web.UI.WebControls.dll in Reflector to see what the render code for the node was doing:

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-reflector

Well, once I saw that the code was hard-wired to render this CSS style, I was done. Or was I?

!important

Well, it wasn’t going to be as easy as setting the style in the code behind, but I could override the style in my own class.

The trick is to define, and apply the following CSS class:

[css]
<style type="text/css">
.MyTreeView TD Div
{
height: 20px!important;
}
</style>
[/css]

The !important CSS directive overrides the style applied in the System.Web.UI.WebControls.TreeNode render method.

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-no-line-break

Again, just as with the QuirksMode comment above, I was able to add the CSS style to the page and voila - problem solved. But this still wasn’t good enough. I needed this to work out of the box for any consumers of my control.

The ultimate answer was to override the RenderBeginTag of the TreeView control, and render this style before the control itself:

[vb language=".net"]

Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
‘/////////////////////////////////////////////////////////////////////////////////////////
‘/// This is a total hack to get around some Microsoft BS which hardwires
‘/// a style attribute on the node div to set the height = 1px!
‘///
‘/// This renders a css override to force the div to the proper height
‘/////////
Me.CssClass = String.Concat(Me.CssClass, " MyTreeView")
writer.WriteBeginTag(HtmlTextWriterTag.Style.ToString)
writer.WriteAttribute(HtmlTextWriterAttribute.Type.ToString, "text/css")
writer.WriteLine(HtmlTextWriter.TagRightChar)
writer.Write(".MyTreeView TD Div ")
writer.WriteLine("{ height: 20px!important; }")
writer.WriteEndTag(HtmlTextWriterTag.Style.ToString)
writer.WriteLine()
‘//////////////////////////////////////////////////

‘/// Render the Standard Begin Tag
MyBase.RenderBeginTag(writer)
End Sub
[/vb]

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Web Marketing Business Solutions For Small Business | Online Marketing Consultant Web MarketingLooking for ways to give your business a marketing boost? If so, do you own an on-line presence as part of your promotions formula? The World Wide Web is now the first selection for individuals researching products and services they are thinking buying.The web has now assumed dominance the......
  • Web Site Maintenance Design -- Design To Save Time! It is a smart thing to try to save as much time in construction, and later in maintenance time as you can, so you can free yourself more valuable time building great content.When building a web site, it is important to have a plan to give yourself good direction......
  • Book Review: The Hal Leonard Acoustic Guitar Method The Hal Leonard Acoustic Guitar Method book includes real songs you can hear on the radio to teach a variety of acoustic guitar concepts. Included are songs by Eric Clapton, Robert Johnson, James Taylor, the Indigo Girls, and many others. There are lesson sections on topics such as finger picking,......
  • Dedicated Server Hosting Advantages Dedicated Web Hosting Has Many Advantages By Volodymyr Zablotskyy Compared to shared web hosting, it is more expensive to host your web site on a dedicated server. You may wonder why you would even think about using a dedicated web hosting solution. Well, there are many advantages to having your......
  • Visual Quickstart Guide - HTML, XHTML & CSS 6th Edition I recently bought the book Visual Quickstart Guide - HTML, XHTML & CSS 6th Edition to refresh my knowledge on Web creation and to serve as a handy reference for me. I know that there are a lot of free XHTML + CSS tutorials online but nothing beats a......
Jun 09 2009

Arraylist and generics don’t mix with IEnumerable(Of T).GetEnumerator.

The other day I was writing an in-house tool to assist in some upgrades we were performing on client installations. This tool was supposed to perform its operations on a batch of items, and display the results upon completion.

Since processing this batch of items was a lengthy endeavor, I wanted the failure to process one of the items to simply be recorded and allow the processing of the others to continue. Part of the processing of each item was a call to multiple web services, so I would need a way to handle the collection of errors along the way and make them available for their eventual display.

I had what I thought was a clever idea: a private Arraylist of exceptions that occurred during processing.

[vbnet]
Public Class BatchExceptions
Implements ICollection(Of System.Exception)

Private mExceptionlist As ArrayList
.
.
.
End Class
[/vbnet]

That way, I could simply iterate over the list and perform the standard exception handling, like so:

[vbnet]
Dim exc As Exception
For Each exc In BatchExceptions
HandleError(exc)
Next
[/vbnet]

Of course, in order to make use of the “For Each” construct, I had to implement the GetEnumerator of the ICollection interface.

[vbnet]
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Exception) _
Implements System.Collections.Generic.IEnumerable(Of System.Exception).GetEnumerator
Return (mExceptionlist.GetEnumerator)
End Function
[/vbnet]

Cool. Only one problem:

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator

That was OK though, because I was using generics after all. The compiler was being helpful and reminding me that I had to specify ‘IEnumerator(Of Exception)’:

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator2

[vbnet]
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Exception) _
Implements System.Collections.Generic.IEnumerable(Of System.Exception).GetEnumerator
Return (DirectCast(mExceptionlist.GetEnumerator, IEnumerator(Of Exception)))
End Function
[/vbnet]

Everything compiled fine, but at run-time I got the following RTE:

Unable to cast object of type ‘ArrayListEnumeratorSimple’ to type ‘System.Collections.Generic.IEnumerator`1[System.Exception]‘.

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator-rte

This was frustrating. It seemed like the compiler failed to warn me of this incompatibility, and simply kicked the can on down the road to the run-time to deal with.

Solution:

Well, I did a little poking around and finally ended up replacing my Arraylist with a list like so:

[vbnet]
private mExceptionlist as System.Collections.Generic.list
[/vbnet]

Well, that did the trick but I can’t say it was as intuitive as it would seem. It makes sense, in hindsight, but why did I have to get some cryptic RTE? Why couldn’t the compiler have picked up on my use of an ArrayList and say, “Hey dummy - use a generic list!”? Still, I have a new trick to toss in my bag for the time I want to implement an enumerator on an Arraylist!

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • How Would You Like To Develop Into A Part Time Professional Internet Marketer? A problem that most Net marketers face is that they're focussed on it half time while holding onto a full time regular job. This is alright and usually necessary in the first stages. If you want to become an professional Internet marketer, but, you may want to manage your time......
  • Calculating Your Net Worth Your own personal net worth is something that can serve as a truly useful tool in measuring the financial progress that you have made from one year to the next. What your net worth is, is essentially just a grand total of all of your assets, with liabilities subtracted. There......
  • The Perfect Process - Guaranteed to Work - Every Time! Every week we work with many of you to develop the next most important process in your company.Many of the common ones are:- Lead Management Process- Lead Distribution Process- Sales Process- Customer Service Process- Service Delivery ProcessSo once we get this process designed, the people trained and the necessary......
  • Top Ten Tips for Guiding a Successful IP Telephony Implementation Top Ten Tips for Guiding a Successful IP Telephony Implementation Often when an organization considers change that will impact every employee— such as an enterprise-wide IP telephony implementation—the process tends to focus on hardware, software, and getting the technology up to speed as quickly as possible. However, a company’s infrastructure......
  • Tips for Organizing the Garage 1 - Begin by creating a staging area. If you can park at least one car in your two car garage, then you can probably organize everything else in a day. Create a staging area where you can put items as you take them out of the garage, such as......
Jun 02 2009

Microsoft FxCop doesn’t like Microsoft generated code!

The other day I thought it might be nice to “do the right thing” and give my code a run against Microsoft’s FxCop.

I ran it right out of the box - I didn’t bother making my own rules or changing the defaults. I was bored. Anyway, here’s one of the results that actually made be chuckle once I read it carefully:

Warning, Certainty 90, for DoNotInitializeUnnecessarily
{

Target : #.ctor() (IntrospectionTargetMember)
Location : <735>> (String)
Resolution : “‘MyDocument.New()’ initializes field ‘MyDocument.disposedValue’
of type ‘Boolean’ to false. Remove this initialization
because it will be done automatically by the runtime.”

Help : (String)
Category : Microsoft.Performance (String)
CheckId : CA1805 (String)
RuleFile : Performance Rules (String)
Info : “Do not make initializations that have already been
done by the runtime.”
Created : 3/6/2009 6:58:21 PM (DateTime)
LastSeen : 3/6/2009 8:36:25 PM (DateTime)
Status : Active (MessageStatus)
Fix Category : NonBreaking (FixCategories)

}

The reason for the chuckle was that the code which triggered this violation of the rule was written by the Microsoft IDE! My role in this infraction was really quite simple: I typed “Implements IDisposable” and hit Enter. The IDE was “nice” enough to plugin the rest for me:

[vb language=".net"]

‘ To detect redundant calls
Private disposedValue As Boolean = False

‘ IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
Array.Clear(mDocumentContent, 0, mDocumentContent.Length)
End If
End If
Me.disposedValue = True
End Sub
[/vb]

It’s bad enough that the IDE writes code for me without prompting, but maybe the FxCop team should talk to the IDE team to avoid such embarrassing nuisances (I had dozens of similar warnings to weed through) in the future.

According to the Code Analysis Team, this is the new default for FxCop 1.36.

Here’s how to avoid it:

Using an FxCop project:

  1. Open your FxCop project in FxCop
  2. Choose Project -> Options -> Spelling & Analysis
  3. Check Suppress analysis results against generated code
  4. Click OK

OR, if you prefer the command-line:

  1. Pass the /ignoregeneratedcode switch, for example:

FxCopCmd.exe /file:MyAssembly.dll /out:AnalysisResults.xml /ignoregeneratedcode

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Establishing Remodel Cost: Home Remodeling Critical First Step Nothing ruins a fantastic remodel more quickly than exceeding the project budget.  Why is this phenomenon so common in residential remodeling?  Simple:  Many homeowners struggle to establish a detailed budget at the appropriate time in the course of the project. Why is establishing remodel cost one of your most important......
  • Development and remote installation of Java service for the Android Devices Written by: Igor Darkov, Software Developer of Device Team, Apriorit Inc. In this article I’ve described: How to develop simple Java service for the Android Devices; How to communicate with a service from the other processes and a remote PC; How to install and start the service remotely from the......
  • Home Improvement Comes Where to Begin Individuals need to try and do home improvement projects constantly to increase the value of their home. Several folks, but, do not understand that project to tackle initial once they have multiple projects to be done. Selecting which project to try and do initial can be set......
  • Windows Mobile, iPhone, Android - Marketplace Comparison Detailed comparison between Windows Mobile Marketplace, Apple's iPhone AppStore and Android Market from developer point of view. By: Predrag Tomasevic (Click for bigger image) Introduction The article you are about to read is my compilation of thoughts on three currently most popular and talked about mobile platforms, sparked by whole......
  • Learn Java Easily With an IDE An IDE (Integrated Development Environment) is used in software industry in order to help programmers to reduce the time it takes to write code. There are many Java IDE's available that are used professionally and is a great tool for Java programmers. But IDE's are not there to help only......