A SELECT statement that assigns a value to a variable must ... (向变量赋值的 SELECT 语句不能与数据检索操作结合使用 ) 总结一句话,一行语句中,要么都是赋值,要么都是查询,不能既有赋值又有查询 [ 错误 ] select @classname=classname,@chargeteacher from classes where classid=@classid [ 错误 ] select @clas…
某个类没有做太多事情.将这个类的所有特性搬移到另一个类中,然后移除原类. 动机:Inline Class (将类内联化)正好于Extract Class (提炼类)相反.如果一个类不再承担足够责任.不再有单独存在的理由(这通常是因为此前的重构动作移走了这个类的责任),就挑选这个“萎缩类”的最频繁的用户(也是个类),以Inline Class (将类内联化)手法将“萎缩类”塞进另一个类中. 做法:1.在目标类身上声明源类的public协议,并将其中所有函数委托至源类.如果“以一个独立接口表示源类函…
代码对一个 参数赋值.以一个临时变量取代该参数的位置. int Discount(int inputVal, int quantity, int yearTodate) { if (inputVal > 50) { inputVal -= 2; } } 重构后: int Discount(int inputVal, int quantity, int yearTodate) { int result=inputVal; if (inputVal > 50) { result -= 2;…