首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

if you take OO to the extreme - which is, of course, completely ridiculous.解决方法

2012-08-29 
if you take OO to the extreme --which is, of course, completely ridiculous.I mean, if you take OO t

if you take OO to the extreme -- which is, of course, completely ridiculous.
I mean, if you take OO to the extreme, that would require excluding all
 those evil procedural constructs like if statements and for loops, and
 write everything in terms of invoking object methods... like this
 monstrosity:
 
 class MyClass {
 void myMethod() {
 IntVariable i;
 ForLoopFactory.create(
 new IntSetter(i.address(), new Number(0)),
 new BooleanCondition(
 new LessThanComparator(i.address(),
 100)),
 new IntAdder(&i, 1),
 new IfStatement(
 new EqualComparator(i.address(),
 new Number(42)),
 new FunctionCaller(writeln.address(),
 new String("Found it!")),
 )
 ).execute();
 }
 }
 
 which is, of course, completely ridiculous.

[解决办法]
9 个 new

热点排行