Re: Spot the bug (three line program) and a question on how to order execution flow in a OOP
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Mon, 24 Sep 2007 17:50:13 -0700
raylopez99 wrote:
Spot the bug (hint: case sensitive).
Gave me an infinite loop, and drove me nuts (lost over an hour finding
it). This sort of stuff should IMO be caught by the compiler.
Then how would you write a recursive property?
Now another question: how's the best way to order how your OOP will
execute? I have a bunch of methods, and they have to execute in a
particular order.
I agree with Tom on both points (basically in both the only-different-by-case and required-order-of-calling, the answer is generally "don't do that").
In addition, if you really must have methods that have to execute in a specific order, you should try to organize your class so that either the methods that have to execute first are simply done so automatically, or you should check whatever state it is that the order of execution creates that you're depending on, and throw an exception if the state is not appropriate for a method that should be executed after some other method.
If the state is implicit in some external component, then you should add some variable to track the state, so that you can detect the out-of-order case and throw the exception.
Pete
.
- References:
- Prev by Date: LINQ and Reflection
- Next by Date: Re: C# compiler option to find classes that implement IDisposable
- Previous by thread: Re: Spot the bug (three line program) and a question on how to order execution flow in a OOP
- Next by thread: Re: Spot the bug (three line program) and a question on how to order execution flow in a OOP
- Index(es):
Relevant Pages
|