Talk:Blogs:AndreiBadea:EnumsInAPIs

From APIDesign

(Difference between revisions)
Jump to: navigation, search
(Comment provided by Alex - via ArticleComments extension)
(Comment provided by Vincent Cantin - via ArticleComments extension)
Line 10: Line 10:
--Alex 20:21, 16 July 2008 (CEST)
--Alex 20:21, 16 July 2008 (CEST)
 +
</div>
 +
== Vincent Cantin said ... ==
 +
 +
<div class='commentBlock'>
 +
In this example, if the user wanted to ensure that he covers all the fields of the enumeration, then he wrote something wrong, he should not have the "default:" case.
 +
 +
If the switch covers all the fields of the enumeration, the "default:" is not needed and not warnings/errors are generated at compile time.
 +
 +
We can also assume that if the user use the default close here, his meaning is not to cover all the fields of the enumeration, but to only cover a subset and throw an assert exception when encounter a field of the complementary subset or null.
 +
 +
 +
--Vincent Cantin 03:26, 17 July 2008 (CEST)
</div>
</div>

Revision as of 01:26, 17 July 2008

Comments on Blogs:AndreiBadea:EnumsInAPIs <comments />


Alex said ...

Normally in a release version one wouldn't want any asserts enabled so maybe not a very big problem? The general principle is if you are designing a library you don't make any assumptions on how your client calls your API. Perhaps I'm wrong though...

--Alex 20:21, 16 July 2008 (CEST)

Vincent Cantin said ...

In this example, if the user wanted to ensure that he covers all the fields of the enumeration, then he wrote something wrong, he should not have the "default:" case.

If the switch covers all the fields of the enumeration, the "default:" is not needed and not warnings/errors are generated at compile time.

We can also assume that if the user use the default close here, his meaning is not to cover all the fields of the enumeration, but to only cover a subset and throw an assert exception when encounter a field of the complementary subset or null.


--Vincent Cantin 03:26, 17 July 2008 (CEST)

Personal tools
buy