Anti-OOP... stupid?

bearophile bearophileHUGS at lycos.com
Tue Feb 14 15:42:02 PST 2012


H. S. Teoh:

> 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.

Smalltalk is a language composed of a very small number of parts, where every thing is an object. So in a sense, you write code like that, with a better syntax.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list