MonoXna and NotImplementedException

3 views
Skip to first unread message

Jordan Justen

unread,
May 31, 2011, 6:42:38 PM5/31/11
to mon...@googlegroups.com
Is there a possible middle ground for NotImplementedException?

I'm wondering if we could call an internal static method rather than
immediately always throwing an exception. It might be nice to mark
areas of code as partially implemented, and others as not started.

Also, perhaps it would be better to not generate the exception when
building in release mode?

I'm thinking of something like below.

Does anyone consider this a bad idea?

-Jordan

==

using System;
namespace Microsoft.Xna.Framework
{
internal class MonoXnaNotImplemented
{
private static void MaybeThrow()
{
#if (DEBUG || NUNITTESTS) && !IGNORE_NOT_IMPLEMENTED_EXCEPTION
throw new NotImplementedException();
#endif
}

internal static void PartiallyComplete()
{
MaybeThrow();
}

internal static void NotStartedYet()
{
MaybeThrow();
}
}
}

Lars Magnusson

unread,
Jun 8, 2011, 2:22:30 PM6/8/11
to mon...@googlegroups.com
Hi Jordan

I'm unsure why you would want this. Is it primarily to have "a record"
of progress, or just to avoid the exceptions.

I personally like the exception, because it immediately lets me know
that this functionality has not been implemented yet. If this is the
case I usually implement the needed functionality before continuing on
what I was doing. It seems to me that to spend time to change all the
NotImplementedExceptions to call some static class is a waste of time.
This time would be better spent actually implementing the
functionality.

That being said, I don't object to the idea i.e. I wouldn't mess up
the code, and it could potentially provide an overview of the
progress, but this can easily be done with a simple search as well.

-lavima

> --
> You received this message because you are subscribed to the Google Groups "MonoXNA" group.
> To post to this group, send email to mon...@googlegroups.com.
> To unsubscribe from this group, send email to monoxna+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/monoxna?hl=en.
>
>

Jordan Justen

unread,
Jun 8, 2011, 4:07:01 PM6/8/11
to mon...@googlegroups.com
On Wed, Jun 8, 2011 at 11:22, Lars Magnusson <lav...@gmail.com> wrote:
> I'm unsure why you would want this. Is it primarily to have "a record"
> of progress, or just to avoid the exceptions.

In the case of PartiallyImplemented, I will give one example. I've
seen some API's are called in a particular scenario, and they are "not
implemented" and therefore an exception is thrown. Yet, I've
discovered that in the current scenario I am investigating, no action
is required to achieve some level of functionality. So, I would like
to remove the exception in that case, but still mark that it as not
been fully implemented.

Regarding the NotStartedYet case, I think this should normally throw
an error with a debug build, but not throw one for a release build.
For a "release" build if we throw the error, then it gains no value
except perhaps introducing an exception when the code might actually
function fine.

> I personally like the exception, because it immediately lets me know
> that this functionality has not been implemented yet. If this is the
> case I usually implement the needed functionality before continuing on
> what I was doing. It seems to me that to spend time to change all the
> NotImplementedExceptions to call some static class is a waste of time.
> This time would be better spent actually implementing the
> functionality.

I agree. I hope it would not be a significant diversion. I'm just
trying to find a way for the libraries to be less likely to hit an
exception in particular build type scenarios.

-Jordan

Reply all
Reply to author
Forward
0 new messages