每次使用单边大脑的时间不要太久, 连续使用左边脑30 分钟如同使用左臂 30 分钟一样,

周期性性地交换让大脑两侧轮流休息。

左脑活动包括了循序渐进的工作,解决逻辑问题与分析;

右脑的活动包括了阴雨、创造性思考、模式匹配与可视化。 




 

【自顶行下的设计】【首先进行高层设计,判断需要用到的类和方法】

【了解实现的流程】【专注于程序中出现的事物,并设想出需要哪些对象】【流程图】

                         【面向对象的方式思考;专注于程序中出现的“事物”,而不是“过程”】

【开始编写程序时】【遵循良好的面向对象的原则,并且没有让单一的类执行过多的任务】

                            你要决定哪个类先创建出来?假设某个类需要用到多个类,又该从哪里开始?

Key Points:

           创建新的类的时候需要写出下列3种东西:【伪代码——>测试码——>真实码】:

  1. 【伪代码】大致上包括实例变量的声明、方法的声明、和方法的逻辑(逻辑最重要,定义了会发生什么事情)

                        常用伪代码语句:Declare  Make  Compute  Invoke  Repeat/While  If        Get         Set   Print

                                               声明      定义    计算         调用      循环               判断    获得输入   设置  打印

  1. 伪代码描述的是要做什么事情而不是如何做;
  2. 使用伪代码来帮助测试码的设计;
  3. 实现方法之前应该要编写测试码;



 

创建Java类:

  • 找出类应该做的事
  • 列出实例变量和方法
  • 编写方法的伪代码
  • 编写方法的测试用程序
  • 实现类
  • 测试方法
  • 除错或者重新设计
  • 不靠谱之 邀请辣妹参加庆功派对,如家??七天酒店来一发??

给你聚一个栗子

  • 游戏目标:以最少的猜测次数打掉计算机安排的 dot com目标。
  • 游戏规则:在7*7的网格上,创建3个达康公司的目标。命中3次,则击沉。
  • 游戏进行:【由于欠缺图形接口的程序设计,所以在这一次的命令栏上进行。】
  •                 计算机要求你输入所猜测的位置(如,A3,B2),计算机反馈hit或者miss或者sunk等回应。清除所有的战舰之后,游戏结束。

 




  •  【列出实例变量和方法】

                                   实例变量的声明    Declare an int array to hold the location cells.Call it locationCell.

                                                           Declare an int to hold the numble of hits.Call it numofHits and set it to 0.


 

                                        方法的声明     Declare a checkYourelf() method that  takes a String for the user's guess ("1","3" ,etc), checks  it.                                                                            and returns a result  representing a "hit"  "kill"  "miss".

                                                           Declare a setLocationCells() setter method that takes an int array(which has the three cell location as                                                                           ints (2.3.4.etc))




  • 【编写方法的伪代码】

                       Method : String checkYourself(String userGuess)

                       Get  the user's guess as a string parameter

                       Convert the guess to an int

                        Repeat with each of the location cells in the int array 

                                     // Compare the user guess to the location cell

                                     if the user guess to matches

                                         increment the numbers of hits     

                                             //find out if it was the last location cell;

                                             if number of  hits is 3

                                                    return "kill" 

                                                  else return "hit"

                                             end if

                                        else return "miss"

                                    end if

                            end repeat

                      end method


 

                     Method : void setLocationCells (int[] cellLocation)

                                   Get the cell location as an array parameter

                                   Assign the cell locations parameter to the cell locations instance variable

                    end method




概念:极限编程(XP) 建议阅读专门的书籍,以免一知半解。

                                    在编写真正可用的方法之前,首先编写出测试方法用的代码。

  • 【编写方法的测试用程序 】:创建对象并加以测试其实测试某一个方法;实现并正确执行;