g_object_{new,set,get} vs. class-specific function
Ethan Blanton
elb at pidgin.im
Sun May 20 16:57:40 EDT 2007
Ka-Hing Cheung spake unto us the following wisdom:
> On Sun, 2007-05-20 at 12:04 -0500, Mark Doliner wrote:
> >
> > My biggest argument against using g_object_new() is that you lose a lot of
> > compile-time checking. What happens if you accidentally pass in "justlfy"
> > instead of "justify" when creating a label?
>
> That shouldn't be a problem if we define constants for Purple object
> properties.
... which isn't really a great idea.
Mark is right, the compiler is our friend, and we should use it to
help us write correct code.
I have no problem with an object creation being followed by a few
configuration function calls. I don't see this as being at *all*
inferior to a long list of un-type-checked name-value pairs which are
asking for subtle bugs to lurk within them. In a language with
stronger type checking (either static or dynamic), using g_object_new
for everything might be a good idea; in C, I do not believe that it
is.
Ethan
--
The laws that forbid the carrying of arms are laws [that have no remedy
for evils]. They disarm only those who are neither inclined nor
determined to commit crimes.
-- Cesare Beccaria, "On Crimes and Punishments", 1764
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://pidgin.im/pipermail/devel/attachments/20070520/f177fbe7/attachment.sig>
More information about the Devel
mailing list