Re: Spot the bug (three line program) and a question on how to order execution flow in a OOP



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
.



Relevant Pages

  • Re: System.Security.SecurityException was unhandled
    ... The exception gave you the CLSID. ... the first thing to check might be whether the COM server ... assembly actually has the permission in question. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Re: collecting results in threading app
    ... but execute one at the time'. ... Could a Queue help me there? ... You can take a look at papyros, a small package I wrote for hiding ... # some exception was raised when executing this job ...
    (comp.lang.python)
  • Re: CLI Exception Handling
    ... the exception, but not on the same instruction that actually generated the ... functionality does exist in win32 SEH. ... handler executes all finally blocks that were lower on the stack have ... >> really can do is make a decision to continue searching or execute the ...
    (microsoft.public.dotnet.framework.clr)
  • Spot the bug (three line program) and a question on how to order execution flow in a OOP
    ... This sort of stuff should IMO be caught by the compiler. ... public int CcUsrInputArrLength ... I have a bunch of methods, and they have to execute in a ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CLI Exception Handling
    ... It is practically quite difficult to determine (in the handler block) from which IL instruction the exception was thrown. ... >> really can do is make a decision to continue searching or execute the ...
    (microsoft.public.dotnet.framework.clr)

Quantcast