gobject-example-rs icon indicating copy to clipboard operation
gobject-example-rs copied to clipboard

Make API less abstract and confusing

Open sdroege opened this issue 5 years ago • 3 comments

What I would suggest is the following

  • Foo becomes Animal
    • Implements Nameable
    • increment() vfunc becomes pet() and returns a Sound (former RString). E.g. cats would "purr"
    • incremented signal becomes made_sound(), see above. This can of course also happen independently of calling
    • name property stays and maps to the Nameable interface
    • Add a new lift() vfunc that either succeeds or returns the (to be written) GError: "too heavy", "too slippery" (e.g. a fish), "hissed", etc
    • Add a new environment read-only property of type Environment (the flags type): "house", "garden", "aquarium", whatever
  • Bar becomes Cat
    • number property would become collar-color of type Color (the enum)
  • Nameable can stay the same, Animals and other things are usually nameable
  • RString becomes Sound (or a better name)
    • Also we'd add accessors for the non-NUL-terminated string plus length without copying
  • SharedRString becomes Name (and is used as part of Nameable). Names are usually used often and immutable
    • Also we'd add accessors for the non-NUL-terminated string plus length without copying

CC @elmarco what do you think? Any suggestions for improvements or changes? :)

sdroege avatar Mar 21 '21 08:03 sdroege

* `number` property would become `collar-color` of type `Color` (the enum)

How about breed instead or in addition?

zeenix avatar Mar 21 '21 10:03 zeenix

@slomo looks good, and promising (more cleanup and improvements!)

elmarco avatar Mar 21 '21 10:03 elmarco

Then let's go for that.

sdroege avatar Mar 21 '21 17:03 sdroege