PDA

View Full Version : issues with LayoutRegion subclassing



gcsolaroli
5 Dec 2006, 2:18 PM
Hi all,

while studying the YUI-ext code to improve my tentative IBLayoutManager (http://www.clipperz.com/files/example/layout/index.html) I have found something strange into the LayoutRegion code.

In the LayoutRegion code there is 'hardcoded' references to regions named "north", "south", "east" and "west", and these are obviously the region names used for the BorderLayoutManager.

But having a "BorderLayoutManager" dependency in the "base" LayoutRegion class sounds wrong to me.

Another strange oddities is the lack of a BorderLayoutRegion class, leaving the four specific "perimetric" regions ([North | South | East | West ]LayoutRegion) all deriving from SplitLayoutRegion, and CenterLayoutRegion deriving straight from LayoutRegion.

To implement my LayoutManager, I need to create a new subclass of LayoutRegion, but the hard coded references to the border layout regions are a little disturbing.

Does this arrangement need some solid refactoring, or am I badly missing something?

tryanDLS
5 Dec 2006, 2:42 PM
Jack may chime in when he returns on Fri, but I think the reason was b/c as the code evolved (e.g. more sophisticated layouts), Jack didn't want to break anybody's code that relied on the original class model.

That may need to be re-addressed in the future, but that's for Jack to say.

gcsolaroli
5 Dec 2006, 3:19 PM
I can understand and appreciate both compatibility issues, and "organic grown" code.

But knowing that a given code is not that way "by design", but due to its history, could be very helpful in understanding how to use it. At least for me.

Anyway I will keep studying, waiting for Jack voice on this issue, hoping that this thread will not get lost in his pending queue that I immagine is growing beyond manageability. :-)

jack.slocum
9 Dec 2006, 2:10 PM
"LayoutRegion" should probably be named "BorderLayoutRegion". There is no LayoutRegion base class right now.

In future, more LayoutManagers will be created and the need for a base LayoutRegion class will present itself. "AbstractRegion" will probably be created at that time and some functionality refactored/moved to it so it can be shared.