An appropriate C API for inspecting attribute values

Posted by uk82 on Stack Overflow See other posts from Stack Overflow or by uk82
Published on 2010-06-10T21:42:21Z Indexed on 2010/06/11 0:22 UTC
Read the original article Hit count: 256

Filed under:
|
|

There are two obvious ways in C to provide outside access to internal attribute values (A) provide a generic interface that accepts a list of attributes that changes over time (some added / some die) or (B) a specific interface for each and every attribute.

Example A:

int x_get_attribute_value(ATT att)
{
    if (a) return a_val;
    if (b) return b_val;
}

Example B:

A_Enum x_get_a_type_attribute() {}
B_Enum x_get_b_type_attribute() {}

I recall that Eclipse's API is very much like A (I could be wrong). What I can't do is come up with a compelling argument against either.

A is clean - any user will no where to go to find out a property value. It can evolve cleanly without leaving dead interfaces around.

B has type checking to a degree - this is C enums!

Is there a big hitter argument that pushes the balance away from opinion?

© Stack Overflow or respective owner

Related posts about c

    Related posts about design