Thursday, October 06, 2005

Wrong architecture

I know this is all very basic yet this is a predominant pattern. Shit happens where low level logic guide high level logic. For instance in Excel say you have the following piece of shode: Function doSomething( no arguments ) Volatility100_1Y = cells("A16") Volatility110_1Y = cells("A17") ...etc... ..then some computation .. cells("A18") = result1 cells("B18") = result2 End So here a low level idea (the specific format of the volatility organised in row) is imposing its format on what is an input of this process. A first step would be to have Function doSomething(Range inputVol, Range OutPutResult) Volatility.reads(c1) ...etc... ..then some computation .. result.write(cells("A18")) End Here it is the Volatility object that writes itself to the cells, not the little low level "A16" cell, who does not know shit about what a volatility is, who constraints the process nonetheless. I think this is called inversion of control by computers scientists, and it relates to object orientation. But it also relates to respecting a common sense abstraction hierarchy where high level guides low level, not the other way round. Which in the end of your application is where you want to go anyway.

0 Comments:

Post a Comment

<< Home