Talk:Blogs:AndreiBadea:EnumsInAPIs
From APIDesign
(Comment provided by Vip eskort Moskva - via ArticleComments extension) |
(Comment provided by female ascorts - via ArticleComments extension) |
||
Line 99: | Line 99: | ||
--Vip eskort Moskva 18:50, 27 February 2013 (CET) | --Vip eskort Moskva 18:50, 27 February 2013 (CET) | ||
+ | </div> | ||
+ | == female ascorts said ... == | ||
+ | |||
+ | <div class='commentBlock'> | ||
+ | Hi there! Fine post! Please when I could see a follow up! | ||
+ | |||
+ | --female ascorts 10:51, 15 March 2013 (CET) | ||
</div> | </div> |
Revision as of 09:51, 15 March 2013
Comments on Blogs:AndreiBadea:EnumsInAPIs <comments />
Alex said ...
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)
Andrei Badea said ...
To Alex: I have also seen IllegalStateException's thrown instead of an assert statement. Regarding the assumptions, you are right. But this case looks like one where you could want to break the rule. Not being able to add fields to the enum could be a big limitation.
To Vincent: you are right, many people have a default branch just to be sure, even when they know they have covered all fields of the enum (of the current version of the enum, that is).
--AndreiBadea 15:41, 17 July 2008 (CEST)
Alex said ...
Could want to break a rule? This rule having been expressed in various ways by hthe MONSTERS of computer science would be then too strong for me to want to break it. There must be a subtlety I'm missing when following your example. I shall work on that further. That is after I've studied the design patterns. Otherwise no chance for me to pass the exams. Thanks!!
--Alex 23:28, 17 July 2008 (CEST)
Joel Neely said ...
Doesn't this depend on how the enum is used?
If a value of the enumerated type is in the result of an API method, and the switch statement above is in the client, and the new value can be returned in a result produced by previous-version client behavior, then adding a value to the enum can cause breakage.
But if the only uses of the enumerated type are in arguments to API methods, or the new value can only appear in a result for a request that used other new–version aspects, then this specific opportunity for error doesn't arise.
It is still possible for new semantic requirements (e.g. a rule that the new enum value is required in certain cases) to break the client.
I suggest that the real issue is this: if the new API still accepts all prior-version arguments and (for those arguments) returns the same results, then there's no breakage. Breakage occurs when a new version fails to accept previously-valid arguments, or returns results that previously could not occur.
--Joel Neely 13:37, 25 August 2008 (CEST)
Burton Samograd said ...
If you compile your release with _NDEBUG the switch will fall through just fine since the assert macros are removed from the release code. This should be decent behaviour even with new binary versions of the code if the new enums are always added at the end.
Developers running debug code *might* catch the new enum value if it is set by the library, and the failed assertion will alert them to the new value that is available.
Basically it comes down to programming practices and disciplines for it to work, which are sometimes difficult to maintain in multi-user distributed development.
--Burton Samograd 07:18, 12 September 2008 (CEST)
tren test cycle said ...
How could it be that you know really a lot great news connecting with this topic on wiki.apidesign.org?
--tren test cycle 20:35, 10 January 2013 (CET)
forex demo account said ...
obviously like wiki.apidesign.org however you need to test the spelling on several of your posts. A number of them are rife with spelling problems and I to find it very troublesome to tell the reality nevertheless I'll definitely come back again.
--forex demo account 17:22, 11 February 2013 (CET)
free download iphone apps said ...
What are some good sites and blogs for affordable fashion for adults?
--free download iphone apps 00:54, 12 February 2013 (CET)
testosterone said ...
When do you think this Real Estate market will go back up? Or is it still too early to tell? We are seeing a lot of housing foreclosures in Winter Springs Florida. What about you? I would love to get your feedback on this.
--testosterone 05:38, 25 February 2013 (CET)
Vip eskort Moskva said ...
Genau dort, wo könnte ich diese spezielle Weblog-Plattform?
--Vip eskort Moskva 18:50, 27 February 2013 (CET)
female ascorts said ...
Hi there! Fine post! Please when I could see a follow up!
--female ascorts 10:51, 15 March 2013 (CET)
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)