[Mono-list] RE: Stub implementations in the library

Kaakani, Ziad M ziad.m.kaakani@intel.com
Wed, 14 Nov 2001 10:48:00 -0800


As an alternative to Miguel's suggestion you may want to consider the scheme
used within the OCL project http://sourceforge.net/projects/ocl.

Rather than throwing exceptions in the methods that are not implemented or
incomplete, you can make a call into a Debug.WriteLine() method with the
appropriate text passed in. For example:

    System.Diagnostics.Debug.WriteLine("ClassName: MethodName(): Not
Implemented...");

This way, you can centralize the debug code to one class/method. OCL
implements this method as follows:

    namespace Diagnostics
    {
        public class Debug
        {
            public static void WriteLine(string message)
            {
                System.Console.WriteLine(message);
                // and/or throw new NotImplementedException(message);
            }
        }
    ...}

This way, you can choose to throw exceptions or just output a debug string
to the console or in some cases comment out the action all together so the
code can continue. The key is that you change one class in the project to
bypass throwing exceptions or outputting debug messages, etc, through out.

...Just a suggestion.
Ziad Kaakani

>From: Miguel de Icaza <miguel@ximian.com>
>To: mono-list@ximian.com
>Date: 11 Nov 2001 16:57:09 -0500
>Subject: [Mono-list] Stub implementations in the library.
>
>Hello guys,
>
>    I would like to make a suggestion and a request to those of you
>working on the class libraries.  Whenever there is a piece of code that
>is not implemented (a skeleton function, a stubbed implementation, a
>TODO item or anything like that), it would be very convenient if you
>throw an exception at that point.
>
>    You can do it like this:
>
>string GetSomething ()
>{
>	throw new NotImplementedException ("System.GetSomething");
>}
>
>    The reason for this is that someone might be debugging his code and
>depending on a method call from your method.  And might spend a long
>time trying to figure out why something in his code is not working,
>instead of getting a nice error message telling him `The underlying code
>you depend on, is not finished')
>
>Miguel.