作业6

一.问题解决

2.补全playPrev(GoMove)

这个其实可以只写一个Play(GoMove)方法就可以的,不必要分成PlayNext和PlayPrev。

为了实现这个功能,做了一个复活函数reliveTheKilled(GoMove):

// Relive the killed stones
 private void reliveTheKilled(GoMove gm)
{
    ArrayList toRelive = gm.DeadGroup;
    foreach (Point p in toRelive)
    {
        Grid[p.X, p.Y].setStone(nextTurn(gm.Color));
     }
}

然后是PlayPrev(GoMove):

public void playPrev(GoMove gm)
        {
           
            Point p = m_gmLastMove.Point;

            // New marks and labels coming So clear the old one
            clearLabelsAndMarksOnBoard();
            Grid[p.X, p.Y].removeStone();
            if (m_gmLastMove != null)
                repaintOneSpotNow(m_gmLastMove.Point);

            
            m_gmLastMove = gm;
            // Set the new labels and marks
            setLabelsOnBoard(gm);
            setMarksOnBoard(gm);

            Debug.Assert(gameTree.peekNext() != null);
            Debug.Assert(gameTree.peekNext().DeadGroup != null);
            if (gameTree.peekNext().DeadGroup.Count > 0)
                reliveTheKilled(gameTree.peekNext());
            
            optRepaint();

            // Clear the textbox and show some new comments
            textBox1.Clear();
            textBox1.AppendText(gm.Comment);

        }

3.点评不足

编码风格:各种不统一,命名方法有时是mfc风格,有时是CamelCase;而注释风格也是,杂七杂八

程序架构:怎么说,只能说一开始没有设计好,到了后来实现的时候一个个坑的补,补的同时也一个个的挖,冗余数据太多了,方法封装也有问题

             比如游戏逻辑部分,我看到好几个方法都要把整个棋盘遍历一遍;GoVariation类控制GoMove类是通过一个计数器m_Seq的,而GoMove类

             本身又有一个类似的int m_n

错误处理:几乎没有错误处理,只看到几个Debug.assert

文件处理:文件处理绕来绕去,封装地不好,写一个入口函数多好

UI:这个就没啥好说,毕竟是个人产品,试验用,大家都把精力放在逻辑上

4.解决Code Analysis报告的所有问题

由于没有Visual Studio,只有免费版的Express,所以没有做。这个改起来绝对是个大工程

5.改写注释,注释风格

已完成,并用xml注释方式改写,xml文件附在git上。

二.感受

又是不得不说的时刻,程序架构太重要了!!!设计好写起来又舒服又愉快,设计不好就像全身被糖黏着,整个空气都有问题。另外读代码太累了("▔□▔)/

三.效果展示

demonstrate

原文地址:https://www.cnblogs.com/mountainking/p/3441042.html