Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #165709
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Memorizing C operator precedence |
| Date | 2022-04-15 18:00 +0000 |
| Organization | Stefan Ram |
| Message-ID | <extract-variable-20220415185849@ram.dialup.fu-berlin.de> (permalink) |
| References | <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de> |
Alan Mackenzie <acm@muc.de> writes: >Breaking up a complicated expression _fragments_ it Example for the refactor "extract variable" in pseudocode: return quantity * item_price - max(0, quantity - 500) * item_price * 0.05 + min(quantity * item_price * 0.1, 100); ------------------> const base_price = quantity * item_price; const quantity_discount = max( 0, quantity - 500 )* item_price * 0.05; const shipping = min( base_price * 0.1, 100 ); return base_price - quantity_discount + shipping; . There is no reason to fall behind the state of the art. Suggested reading: Refactoring - Improving the Design of Existing Code by Martin Fowler, publishing house Addison-Wesley Educational Publishers Inc. . Don't worry! It is written in an easy-to-understand way so that most programmers can get it.
Back to comp.lang.c | Previous | Next | Find similar | Unroll thread
csiph-web