0

I've stumbled upon code project that is organized something like the following:

Namespace TheProject
{
    public class SerialPortManager
    {
        public class RingBuffer
        {
            // Clears the buffer
            public void Clear(SerialPortManager theManager)
            {
            }
        }
    }
}

Here's an example of a method call:

spm.RingBuffer.Clear(spm);

I'm surprised this code doesn't result in the program crashing. What are some of the implications of the code being organized this way? Can this result in memory leaks? What other problems might I be looking at? Or is this a legitimate but quirky way to organize code?

4

2 に答える 2

5

全くない。それは完全に合法です。RingBufferは ... の一部であるクラスですが、適切なバッファをクリアするためにSeriarPortManagerどちらを使用するかを知る必要があります。SerialPortManager

于 2013-07-09T00:36:40.457 に答える