Re: Fwd: Compiler Guided Refactoring.
J Arrizza <[email protected]> Sat, 6 Jul 2013 10:31:52 -0700
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <CAEyOLyB+NPY-zhMGSG_F7NHJgPYsqsUHjkAYoOD5D4sejYYcSQ@mail.gmail.com> |
The key aspect to the Extract Method with no arguments and void return value (i.e. void-void extraction) is that it minimizes the risk of introducing side-effects. The conversion of the function parameters to consts is slightly different, its purpose is to highlight the fact that the function won't introduce a side-effect via those parameters. Further to this, one additional refactoring I've used is Rename Variable to add a "g" prefix to all global variables. I personally don't like hungarian notation but adding the "g" is a very useful exception to this rule. All the globals show up clearly in the code. One other way to achieve this is to put all globals into a single struct called "globals". Then all uses show up as "globals.some_variable" which makes it very clear that there is a global side-effect in that part of the code. But note the compiler may generate more code for this technique. John On Thu, Jul 4, 2013 at 3:28 PM, J Arrizza <[email protected]> wrote: > On Thu, Jul 4, 2013 at 7:27 AM, Richard <[email protected]> wrote: > >> ** >> >> n article < >> CAEyOLyBfwH6uD6Z5RxBmmne4NA90cpF6N6LGacJPmRTSz7Enyg@mail.gmail.com>, >> J Arrizza <[email protected]> writes: >> >> > is. IMO the biggest bang for buck is the void-void extraction. >> >> This is Extract Method/Extract Function with no arguments >> > ... and void return value. > >> > The next best is the void-const extraction. >> > >> This is Extract Method/Extract Function with arguments >> > ... and void return value and all the arguments are const. > >> >> I think it's important to use the established names for well known >> refactorings for clear communication. >> > Absolutely. > >> >> >> >> Start a New Topic<http://groups.yahoo.com/group/refactoring/post;_ylc=3D= X3oDMTJlazgzdWgyBF9TAzk3MzU5NzE0BGdycElkAzM5NzU2MDIEZ3Jwc3BJZAMxNzA3Mjc2NzE= 4BHNlYwNmdHIEc2xrA250cGMEc3RpbWUDMTM3Mjk0ODA2Ng--> Messages >> in this topic<http://groups.yahoo.com/group/refactoring/message/10661;_y= lc=3DX3oDMTM2dTY1ZDY3BF9TAzk3MzU5NzE0BGdycElkAzM5NzU2MDIEZ3Jwc3BJZAMxNzA3Mj= c2NzE4BG1zZ0lkAzEwNjY0BHNlYwNmdHIEc2xrA3Z0cGMEc3RpbWUDMTM3Mjk0ODA2NgR0cGNJZ= AMxMDY2MQ-->(4) >> Recent Activity: >> >> >> Visit Your Group<http://groups.yahoo.com/group/refactoring;_ylc=3DX3oDM= TJlOW1ucG5jBF9TAzk3MzU5NzE0BGdycElkAzM5NzU2MDIEZ3Jwc3BJZAMxNzA3Mjc2NzE4BHNl= YwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTM3Mjk0ODA2Ng--> >> [image: Yahoo! Groups]<http://groups.yahoo.com/;_ylc=3DX3oDMTJkbWt0N2dq= BF9TAzk3MzU5NzE0BGdycElkAzM5NzU2MDIEZ3Jwc3BJZAMxNzA3Mjc2NzE4BHNlYwNmdHIEc2x= rA2dmcARzdGltZQMxMzcyOTQ4MDY2> >> Switch to: Text-Only<[email protected]?subject=3DC= hange+Delivery+Format:+Traditional>, >> Daily Digest<[email protected]?subject=3DEmail+Delivery= :+Digest>=95 >> Unsubscribe <[email protected]?subject=3DUnsubscri= be>=95 Terms >> of Use <http://docs.yahoo.com/info/terms/> =95 Send us Feedback >> <[email protected]?subject=3DFeedback+on+the+redesign= ed+individual+mail+v1> >> . >> >>=20 >> > > [Non-text portions of this message have been removed] ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/refactoring/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/refactoring/join (Yahoo! ID required) <*> To change settings via email: [email protected]=20 [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/