29-08-2009, 07:13 PM
The easiest in making, yes. But not when using it. I want to specifically avoid any passing of array indices. Makes code harder to read and maintain and requires direct use of the internal widget array.
I want to either obtain a reference to the widget I an working with or set the parameters through a function (which I'm doing right now but like less).
The advantage of the function-based approach is clear, I think. All sanity checking can be left to the engine, the actual game running on top of it can rely on the availability of certain features.
The reference based approach would leave the sanity checking to the programmer (unless that is moved to the widget updating logic) but make core very, very readable and maintainable.
You are right though. I'll probably split it into two functions, like this:
I want to either obtain a reference to the widget I an working with or set the parameters through a function (which I'm doing right now but like less).
The advantage of the function-based approach is clear, I think. All sanity checking can be left to the engine, the actual game running on top of it can rely on the availability of certain features.
The reference based approach would leave the sanity checking to the programmer (unless that is moved to the widget updating logic) but make core very, very readable and maintainable.
You are right though. I'll probably split it into two functions, like this:
Code:
my_widget = getUI("inventory")
my_widget.bg = Resource("UI", "inventory.bmp")
setUI(my_widget)