Quote:Original post by Koshmaar
and I'll probably add there some overloading stuff too.
Don't forget namespaces while you're at it.
Quote:Original post by Koshmaar
and I'll probably add there some overloading stuff too.
Quote:Effective C++ by Scott Meyers, Item 18: Strive for class interfaces that are complete and minimal:
...the more functions in an interface, the harder it is for potential clients to understand... A class with 10 functions looks tractable to most people, but a class with 100 functions is enough to make many programmers run and hide...
A large interface can also lead to confusion. Suppose you create a class that supports cognition for an artificial intelligence application. One of your member functions is called think, but you later discover that some people want the function to be called ponder, and others prefer the name ruminate. In an effort to be accomodating, you offer all three functions, even though they do the same thing... The client is faced with three different functions, all of which are supposed to do the same thing. Can that really be true? Isn't there some subtle difference...possibly in efficiency or generality or reliability? If not, why are there three different functions? ...such a potential client is likely to wonder what on earth you were thinking (or pondering, or ruminating over).
Quote:..such a potential client is likely to wonder what on earth you were thinking (or pondering, or ruminating over).
Quote:
Don't forget namespaces while you're at it.
// for reading CFG_ReadBool () CFG_ReadInt () CFG_ReadFloat() CFG_ReadText () // for writing CFG_WriteBool () CFG_WriteInt () CFG_WriteFloat() CFG_WriteText ()
// removing CFG_RemoveBoolEntry () CFG_RemoveIntEntry () CFG_RemoveFloatEntry() CFG_RemoveTextEntry () // existance checking CFG_BoolEntryExists () CFG_IntEntryExists () CFG_FloatEntryExists() CFG_TextEntryExists ()
Quote:My personal preference would be for you to remove it; the less typing I have to do, the better (not that I'll necessarily be using your library, but still...). Since the functions are already prefixed with CFG, it'll be obvious that you're operating on entries in the configuration file, I think.
Quote:With that in mind, is it even necessary to differentiate between types in the functions for EntryExists and RemoveEntry? If it would be possible for you to make generic "CFG_EntryExists" and "CFG_RemoveEntry" functions, that don't require you to know and/or specify the type, it seems like it would be easier on the endusers.