• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: More elegance than a long if/else
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More elegance than a long if/else


  • Subject: Re: More elegance than a long if/else
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 11 Mar 2017 11:45:57 -0800

On Mar 11, 2017, at 06:30 , Pascal Bourguignon <email@hidden> wrote:
>
> My argument is that algebraic expressions are clearer than switches.

And it’s a *convincing* argument when you switch to a purely arithmetic problem (such as: how to add two numbers).

Seriously, though, I apologize if I let anyone think I failed to see the argument for — the advantages of — a concise numerical expression. Someone (Jeff) had already given that part of the answer. Yet there may well be multiple answers for which there is a valid argument.

Finally, before stepping out of this thread permanently, I’ll point out that although Jeff knew the (or, a) right answer, he inadvertently used the wrong operator. On top of that, there was a second correction to handle the edge case at upper end of the range, and the lower end edge case (if the battery level value is negative) still isn’t handled as the original code would. Finding an arithmetic solution to a logical problem is a non-trivial exercise, and “it can be argued that” for a reader of the code, decoding the resulting non-trivial arithmetic expression carries a non-trivial conceptual load.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)
 >Re: More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)
 >Re: More elegance than a long if/else (From: Bryan Vines <email@hidden>)
 >Re: More elegance than a long if/else (From: Quincey Morris <email@hidden>)
 >Re: More elegance than a long if/else (From: Pascal Bourguignon <email@hidden>)
 >Re: More elegance than a long if/else (From: Quincey Morris <email@hidden>)
 >Re: More elegance than a long if/else (From: Pascal Bourguignon <email@hidden>)

  • Prev by Date: Re: Unicode filenames with Apple File System and UIManagedDocument
  • Next by Date: Printing questions
  • Previous by thread: Re: More elegance than a long if/else
  • Next by thread: struts and springs layout
  • Index(es):
    • Date
    • Thread