tag:blogger.com,1999:blog-138330282024-03-07T13:57:52.735-05:00James HollingsheadCode Poet, Swordsman, Eternal Wanderer
<br>
Please feel free to comment
<br><br>
Email: james AT jameshollingshead DOT comJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.comBlogger324125tag:blogger.com,1999:blog-13833028.post-20334175842977610242022-10-31T09:35:00.001-05:002022-10-31T09:35:11.713-05:00Happy Anniversary<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFtqK3Xv0EyuwlPpUPul8S8gmVu72zX0ITEOKXlNfdxqFtbXkwgxO7rzMugLQytUBxhkGTQgPOpUs3-CSb97jw3RdbrHxxQlya43nCTieklrieVWcIM0iIrcRIa7wz7NAZvQmH39-33C-0VEVy5LO9KxA6E0EowZBKqSq8DVZ6kxO9WgojQdM/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFtqK3Xv0EyuwlPpUPul8S8gmVu72zX0ITEOKXlNfdxqFtbXkwgxO7rzMugLQytUBxhkGTQgPOpUs3-CSb97jw3RdbrHxxQlya43nCTieklrieVWcIM0iIrcRIa7wz7NAZvQmH39-33C-0VEVy5LO9KxA6E0EowZBKqSq8DVZ6kxO9WgojQdM/s320/rain-drop-red-roses.jpg" width="240" /></a></div><br /><p><br /></p><p> Happy Anniversary</p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-38999750920648290092022-10-14T08:21:00.003-05:002022-10-14T08:21:52.967-05:00<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMIr8AYANkBqvWM9X_cVFtoysCBGcs4uEN_szKCII0iy0ZAtzoANaCVztBCZhbHLSxi84IdgYTrmYLFJEjac_ELai5kRVAT-iZJVeR1O5ZDOGt8t8sMKaR67g-V5e8wG-S5HCVoCW1b77a8HtuNlxo5Vcgy_nR-Qo4CBCA8zSP-mppQovdP00/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMIr8AYANkBqvWM9X_cVFtoysCBGcs4uEN_szKCII0iy0ZAtzoANaCVztBCZhbHLSxi84IdgYTrmYLFJEjac_ELai5kRVAT-iZJVeR1O5ZDOGt8t8sMKaR67g-V5e8wG-S5HCVoCW1b77a8HtuNlxo5Vcgy_nR-Qo4CBCA8zSP-mppQovdP00/s320/rain-drop-red-roses.jpg" width="240" /></a></div><br /><p></p><p>Happy Birthday</p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-67574188484674205052021-10-31T11:16:00.003-05:002021-10-31T11:16:40.203-05:00Happy Anniversary<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div><br /> <br /><p></p><p> Happy Anniversary</p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-13510509213672731522021-10-14T10:04:00.004-05:002021-10-14T10:04:50.896-05:00 Happy Birthday<p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div><br /><p> Happy Birthday</p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-73089643833332385632020-10-31T13:19:00.002-05:002020-10-31T13:19:27.977-05:00Happy Anniversary<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" /></a></div><br /><p><br /></p><p>Happy Anniversary </p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-66826652098041125932020-10-14T10:23:00.003-05:002020-10-14T10:23:55.460-05:00Happy Birthday<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s533/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" /></a></div><br /><p></p><p>Happy birthday</p>James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-57581951165972913012019-10-31T08:26:00.004-05:002019-10-31T08:26:51.107-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
<br />
Happy AnniversaryJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-74810447419405619382019-10-14T07:14:00.002-05:002019-10-14T07:14:21.936-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
Happy BirthdayJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-81862390185895806452018-10-31T18:01:00.001-05:002018-10-31T18:01:14.697-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilffFfYAFGyWK5SATuhh7XEJWGT5OtgyhJhYHtjK67JIrDthuolEZ8iExRBV5X2nkp3SaAKt6GY-kfA15hvkfOH8KY-hwsQCZrXD70aN4UTm_tDAUCd-K_a-RxF87Ic14FQikkrg/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilffFfYAFGyWK5SATuhh7XEJWGT5OtgyhJhYHtjK67JIrDthuolEZ8iExRBV5X2nkp3SaAKt6GY-kfA15hvkfOH8KY-hwsQCZrXD70aN4UTm_tDAUCd-K_a-RxF87Ic14FQikkrg/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
<br />
Happy AnniversaryJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-65586027222179850192018-10-14T20:50:00.003-05:002018-10-14T20:50:38.297-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
Happy BirthdayJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-33025572100574607922017-10-31T06:55:00.002-05:002017-10-31T06:55:49.648-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR_m4QLbEMILCAkutMUgV3K7cI6RaEk5UI7g4hQEk0OvtXp4IQn9ysCSeCnCGPRFc_b5nFxNSqJOnCQ1kHRyyLiZ3LaXsM6M6e7xWL2asxM1quzF8uV1PdW2nz8jcpymNvqq7LfA/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
<br />
Happy AnniversaryJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-46053175868162243442017-10-14T05:34:00.003-05:002017-10-14T05:34:54.015-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilffFfYAFGyWK5SATuhh7XEJWGT5OtgyhJhYHtjK67JIrDthuolEZ8iExRBV5X2nkp3SaAKt6GY-kfA15hvkfOH8KY-hwsQCZrXD70aN4UTm_tDAUCd-K_a-RxF87Ic14FQikkrg/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="400" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilffFfYAFGyWK5SATuhh7XEJWGT5OtgyhJhYHtjK67JIrDthuolEZ8iExRBV5X2nkp3SaAKt6GY-kfA15hvkfOH8KY-hwsQCZrXD70aN4UTm_tDAUCd-K_a-RxF87Ic14FQikkrg/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
Happy Birthday<br />
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-82900157062318925112017-09-10T14:51:00.002-05:002017-09-10T14:51:57.131-05:00Should Bad Code Be Illegal?
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OHzt6tz7XxaFIrxo4fFi9MhwSQRV_L93DO8ADpQ9uG8bHEkFyRFLaUsBpneCS4co3kUly7doiUVn0dEK6WgBhZuB0peW4v0TRtTVCac5RVVp7_BJoJBnFMrruOXSmfkQK0KWCg/s1600/gorillabuddha128500394295156250.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="375" data-original-width="500" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OHzt6tz7XxaFIrxo4fFi9MhwSQRV_L93DO8ADpQ9uG8bHEkFyRFLaUsBpneCS4co3kUly7doiUVn0dEK6WgBhZuB0peW4v0TRtTVCac5RVVp7_BJoJBnFMrruOXSmfkQK0KWCg/s320/gorillabuddha128500394295156250.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">A junior developer on my team asked me a rather interesting question
recently.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">If you were able to make laws, would you make bad code
illegal?<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">I have a reputation where I work as being rather hard-nosed
about not allowing hard to understand and maintain code into the codebase, so
my answer surprised him.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">No, I would not make bad code illegal, and there are very
good reasons for having this opinion.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">First, everyone writes bad code before they write good code.
Whether it’s your first time coding in general or just your first time coding
in a new language, with a new framework, etc, you are going to write bad code.
I’m sorry. It’s just a fact of life.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Nobody starts out writing amazing code. Not me, not you, not
Uncle Bob (in fact, Uncle Bob is open about the fact that he was a horrible
developer when he started, just like the rest of us). We all get better by
writing bad code, learning from our mistakes and pain, and, if we’re lucky,
mentors helping us to see where things can be improved.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Second, “bad code” is rather subjective. What standard are
we using for what “bad” code is? <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Is it code that costs the business unreasonable amounts of
money due to being full of bugs and difficult to maintain? That’s not a
completely terrible definition because we can tie it to some external
benchmark, but it’s still probably a bad idea since there is a risk/reward
factor of why decisions were made at the time that may not be known at some
later date.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Is it code that Developer X (whether me, Uncle Bob, or Joe
in the cubicle across the hall) would look at and give a laundry list of things
that need to change? For any given code, you can find some developer that would
find flaws in it – whether it is inefficient, or it doesn’t implement their
favorite pattern, or any number of other complaints.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Is it code that, six months from now, you will look back at
and wonder what the heck you were thinking when you did it that way because
there are so many better ways to accomplish what this code does? Here’s a hint.
This should be most of your code. You didn’t know as much 6 months ago as you
do now.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Third, sometimes bad code is necessary.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Yes, you heard me. There are times that it makes sense to
write bad code.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">If you are writing a script to perform some one-off function
that you are seriously never going to use again, pretty doesn’t always matter
that much. If writing code for 5 minutes and then throwing it away can save you
hours of work, go for it. I’ve done it before, and I can almost guarantee that
I will do it again.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Sometimes you need to fix a catastrophic flaw in a mission
critical piece of software, because the company is losing millions of dollars
per minute while the flaw exists. In that case, you have to do whatever you can
in order to fix the issue, release the patch, and *then* go back and make it
maintainable. <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">The same is true if we are in a startup where the money is
limited, time is fairly short (as it is generally a function of money in this
case), and we need to get a Minimum Viable Product out in front of users so we
can start making money. This is another case were “Make it work, then make it
better” can be the correct (and sometimes only) course of action.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">We may not like it, but sometimes getting it to work right
now is the right choice. These situations fall under the heading of consciously
taking on technical debt with every intention of paying it back later and this
is a very important business decision. If it’s a matter of “We can release it
now and be able to make payroll” vs “It will take another month to make it
perfect and we’ll be unemployed by then”, well, the choice is fairly clear then
isn’t it?<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Thankfully, most of the code we write doesn’t tend to fall
into those categories, so we can make the effort now in order to make the code
clean and maintainable, but we can’t ignore that those possibilities exist.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Making a law that is, on the whole, completely subjective
and capricious is a just plain bad idea. As a general rule, when we write code
that isn’t amazing, at worst we lose time in figuring out what is going on
and/or fixing some bugs. Nobody generally dies from bad code (there are cases
this is not true, but they are not the norm), and we can always make a conscious
effort to improve it once the crisis is averted. <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">On the whole, yes, we need to strive to write clean,
maintainable, bug free code, but we can’t be completely inflexible. If you want
to make it a crime to write bad code, make the punishment be to learn how to
write better code. I think that’s a fair sentence.<o:p></o:p></span></div>
<o:p><span style="font-family: Calibri;"> </span></o:p><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Current mood: Calm</span></div>
<div class="MsoNormal" style="margin: 0in 0in 8pt;">
<span style="font-family: Calibri;">Current music: Midnight Oil – Beds Are Burning<o:p></o:p></span></div>
James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-29961651189460541822016-10-31T08:56:00.002-05:002016-10-31T08:56:29.245-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIU5B4y6vGDlnOAwfhFIvGAJpwYi0A5PDOs-5-Zp3UFsRdI4XbZhTdFKyD90VKLtGhivlr5iTwiACQxL62k5UQUFClZa4Fr9FjHL4t_YLmLWAKOdisYelV2J6L-ny_PU52jspMfQ/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIU5B4y6vGDlnOAwfhFIvGAJpwYi0A5PDOs-5-Zp3UFsRdI4XbZhTdFKyD90VKLtGhivlr5iTwiACQxL62k5UQUFClZa4Fr9FjHL4t_YLmLWAKOdisYelV2J6L-ny_PU52jspMfQ/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
Happy Anniversary<br />
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-39199830952051998272016-10-14T09:34:00.001-05:002016-10-14T09:34:58.589-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIU5B4y6vGDlnOAwfhFIvGAJpwYi0A5PDOs-5-Zp3UFsRdI4XbZhTdFKyD90VKLtGhivlr5iTwiACQxL62k5UQUFClZa4Fr9FjHL4t_YLmLWAKOdisYelV2J6L-ny_PU52jspMfQ/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIU5B4y6vGDlnOAwfhFIvGAJpwYi0A5PDOs-5-Zp3UFsRdI4XbZhTdFKyD90VKLtGhivlr5iTwiACQxL62k5UQUFClZa4Fr9FjHL4t_YLmLWAKOdisYelV2J6L-ny_PU52jspMfQ/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
Happy Birthday<br />
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-28855699185316183732015-12-09T21:33:00.000-05:002015-12-09T21:41:56.690-05:00I will miss you, fuzzy buddy<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKveJL9MHWtGCYAgn_ORFz1acbEQmL2J3s0kAm57vNgZF4aPBfePMVHjCaDYyeIigrYlhw2gB5fHKSjLrJwk8MyCAbp8uLRMxnpglv0YTxMtU4_jJEAEveZ4GGu_36Osnyra-0-g/s1600/Anubis+on+fluffy+blankey.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKveJL9MHWtGCYAgn_ORFz1acbEQmL2J3s0kAm57vNgZF4aPBfePMVHjCaDYyeIigrYlhw2gB5fHKSjLrJwk8MyCAbp8uLRMxnpglv0YTxMtU4_jJEAEveZ4GGu_36Osnyra-0-g/s320/Anubis+on+fluffy+blankey.jpg" width="320" /></a></div>
<br />
<br />
<div style="margin-bottom: 0in;">
I lost my best friend today.
</div>
<br />
<br />
<div style="margin-bottom: 0in;">
Since I was 17, my best friend has been
the amazing cat that you see above the post. He's the best cat I've
ever known. He was smart, brave, sweet, and a very good kitty. He was
also very much daddy's guy. He was always there to greet me when I
woke up in the morning and when I got home from work.</div>
<br />
<br />
<div style="margin-bottom: 0in;">
We've been through a lot together,
we've taken care of each other, and we've always tried to be there
for each other.</div>
<br />
<br />
<div style="margin-bottom: 0in;">
Unfortunately, today he passed away at
the admirable age of 18. The vet was with us in hoping that he could make it much, much longer for a number of reasons, but it seems that that wasn't meant to be. Yesterday, we got word that he wasn't going
to be around for much longer, so we did what we could – we bought
him fried chicken (which he loved, but didn't often get because it
wasn't very good for him), gave him his holiday gifts early and spent
yesterday and today with him, showing him how loved he is. He ate a
large amount of the chicken and enjoyed all of the cuddles.</div>
<br />
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
We were both there for him when he
passed away, petting and cuddling him while telling him what a good
kitty he has always been and how much we love him. He's now having a well deserved rest and
isn't suffering anymore. We laid him to rest next to Karyl's cat,
Simba, who passed away a couple of years ago and whom he adored
basically since he met her.</div>
<br />
<br />
<div style="margin-bottom: 0in;">
I will miss him greatly. Karyl and I
both will, to be honest. The house will feel very empty
without him in it.</div>
<br />
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
To share our love for him with the
world, at least a little bit, here are a few links involving him:</div>
<br />
<div style="margin-bottom: 0in;">
<a href="http://karylmc.blogspot.com/2010/05/moving-cats-day-1.html" target="_blank">Karyl's blog entries about Anubis moving up here with me and his interactions with Simba</a></div>
<div style="margin-bottom: 0in;">
<a href="http://karylmc.blogspot.com/2015/12/we-said-goodbye-today.html" target="_blank">Karyl's poem saying goodbye to Anubis</a></div>
<div style="margin-bottom: 0in;">
<a href="http://ihasablog.tumblr.com/" target="_blank">Anubis' blog</a></div>
<div style="margin-bottom: 0in;">
<a href="https://www.youtube.com/watch?v=VnslESM7D-Y" target="_blank">Anubis plays with his favorite string (video)</a></div>
<div style="margin-bottom: 0in;">
<a href="https://www.youtube.com/watch?v=xxXC7Z7Wyws" target="_blank">Anubis on catnip (video)</a></div>
<div style="margin-bottom: 0in;">
<a href="https://www.youtube.com/watch?v=aVANH816HE8" target="_blank">Anubis Vs Ham (video)</a></div>
<div style="margin-bottom: 0in;">
<a href="https://www.youtube.com/watch?v=h4UrQirZd6k" target="_blank">Anubis and the Feather (video)</a></div>
<div style="margin-bottom: 0in;">
<a href="https://www.youtube.com/watch?v=dViPMfE927k" target="_blank">Anubis' Paws Under the Door (video)</a><br />
<a href="https://www.youtube.com/watch?v=8x0qP5GKCRo" target="_blank">The String HAS Me! (video)</a></div>
<div style="margin-bottom: 0in;">
</div>
<br />
<div style="margin-bottom: 0in;">
I will miss you very much, fuzzy buddy. You will always have a big place in my heart</div>
<br />
<br />
<div style="margin-bottom: 0in;">
Current mood: Sad</div>
Current music: Craig Ferguson's series
finale – Bang Your DrumJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com1tag:blogger.com,1999:blog-13833028.post-1153656386028472092015-10-31T09:55:00.002-05:002015-10-31T09:55:56.520-05:00<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio5Oh83ey-22G-OObuSSYHzK_c8MrNpnZt3XhazqdxsW_-PyY9nnQAaPrFZbb1OXOf2X9AIW8gGfRV1fOzMAHFTMsmY1Rldm7SYi1niVqmERXhpdhHtEMRGtLKA6Dx1i2DzOb4kw/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio5Oh83ey-22G-OObuSSYHzK_c8MrNpnZt3XhazqdxsW_-PyY9nnQAaPrFZbb1OXOf2X9AIW8gGfRV1fOzMAHFTMsmY1Rldm7SYi1niVqmERXhpdhHtEMRGtLKA6Dx1i2DzOb4kw/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />
<br />
Happy Anniversary<br />
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-31130351325075197472015-10-14T07:57:00.002-05:002015-10-14T07:57:40.283-05:00Happy Birthday<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s320/rain-drop-red-roses.jpg" width="240" /></a></div>
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-64575666557526875182015-08-30T18:44:00.000-05:002015-08-31T10:11:11.791-05:00TDD - It'll only hurt for a little while ;)<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghbuk2SBjaH4jOe-Ll_2RtCxCCClYE76Q25pMWWSkl24yZ9EolQlcbRD-USEwDeimylszOBb-bVWp7kh_8gUWEC9z31OsvpkztWu_6zYBcK8iXfOdc946E9aBqyCf5Ljrjc51AKg/s1600/006747524.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghbuk2SBjaH4jOe-Ll_2RtCxCCClYE76Q25pMWWSkl24yZ9EolQlcbRD-USEwDeimylszOBb-bVWp7kh_8gUWEC9z31OsvpkztWu_6zYBcK8iXfOdc946E9aBqyCf5Ljrjc51AKg/s320/006747524.jpg" width="320" /></a></div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
TDD is a very useful tool.
Done well, it offers assurance that your code does what it is
supposed to do, provides a set of baked in regression tests, allows
you to refactor code without worrying that you will break something
in the process and acts as a sort of living design document.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
It is not, however, a
silver bullet. If done poorly, it can cause code to become rigid.
This generally happens when people test the implementation details
rather than the behavior. In a language like Python, where there are
no truly private methods, it can be even easier to test
implementation rather than behavior if you aren't cautious. I'll also
say that it can be really difficult to effectively test Android code
because TDD isn't a first class citizen in that ecosystem.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
In my opinion, the
possible downsides of TDD are generally far outweighed by the bonuses
– especially since the downsides are usually able to be mitigated
by exercising some self-discipline.
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
That's not to say that
every piece of code you ever write has to be done with TDD. There are
some small, usually one-liner style programs, that I write which I
don't test drive. If I'm going to be using something once and
tossing it, provided that there isn't really a danger of permanent
damage if the code doesn't do what I want the first time, I may
decide that it isn't worth the effort to set up a testing harness.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
Now that we've got my
opinions on the topic out of the way, I have to say that I don't get
the hate that some developers have for TDD. I can understand a
non-technical manager not understanding how writing tests (more code)
isn't a drawback, but people who write software for a living are
another story.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
If I had to guess, I'd say
it was probably some combination of fear of the unknown, a previous
bad experience (whether because of lackluster tools, lack of
guidance, or inexperience), or posturing on the part of the developer
(after all, we are often not known for a lack of ego).
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
There are occasionally
reasons to not test something (few and far between), but as a general
rule, having the tests will only help you now as well as helping
future you when you have to dig back into the code in 6 months. Not
wanting all of the tools that could help you is just crazy.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
This whole post was
inspired by a tweet that a friend of mine
re-tweeted (and its associated tweets), so let's take a little time to critique the conversation.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div lang="en-US" style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
Shocked by the number of jobs proposed to me whose ads list "TDD" as a requirement. Are we really still doing this?</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637983933263671296">August 30, 2015</a></blockquote>
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Yes. Because it works. I've already
covered that above, so I'm not going to repeat myself.</div>
<div lang="en-US" style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
TDD works really well for a lot of people, and that's great. Others have different ways of thinking about programming. Don't exclude them!</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637985920155840518">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
If you are working in a shop that
doesn't do test driving (I'd be tempted to ask why not, but just for
the sake of argument), then yes, a person who doesn't do TDD will be
fine. If you <b><u><i>are</i></u></b> in a shop that does TDD and the person is willing
and able to learn TDD, then consider helping them get up to speed. If
they refuse, then they're probably not a good fit for your
team/company. Sorry, but that's the way it is.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
If your team all does TDD, but one
person refuses to do so, you lose a lot of the benefits. The baked in
set of regression tests is no longer complete. The living
documentation is no longer complete. Refactoring becomes trickier.
Bugs can become harder to track down. These are problems.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
<a href="https://twitter.com/makmanalp">@makmanalp</a> <a href="https://twitter.com/jasonpbecker">@jasonpbecker</a> Yes, I think this is a matter of individual neurology. My architectures definitely get _less_ simple with TDD.</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637997975571202049">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Then you're probably doing TDD wrong.
In all likelihood, you are testing implementation instead of behavior.
This is actually a pretty common mistake for people who aren't used
to TDD and it takes some experience to get over. Heck, even people
who have been doing it for a while can slip up sometimes. None of us
are perfect. That doesn't change the fact that you're probably using
the tool wrong.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
<a href="https://twitter.com/makmanalp">@makmanalp</a> <a href="https://twitter.com/jasonpbecker">@jasonpbecker</a> If I'm TDDing with unit tests, it helps me a lot. If I'm TDDing with integration tests, I lose the big picture.</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637997067340746752">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
You don't TDD with Integration Tests,
or at least not only with integration tests. You use Unit Tests to
test functions (given input, check output for example). Integration
Tests are used to test a series of Units (kind of like checking to
see that a bunch of legos you put together actually build a wall).
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
<a href="https://twitter.com/jasonpbecker">@jasonpbecker</a> TDD literally gets in the way of my thinking properly about my code in some cases.</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637995568409747456">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Then you're looking at it wrong. Each
unit test should be a condition that your function should fulfil. You
only test the criteria that your code is supposed to fulfill. That's
not to say that you can't spike out something you're not sure of
(especially if you're working with a new language), but before that
code actually makes it into your codebase, it needs to be under test,
and that test needs to fail first.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
<a href="https://twitter.com/jasonpbecker">@jasonpbecker</a> In my case, striving to always do TDD would have a negative impact on the quality of my code.</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637994913301442560">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I can sort of get behind this for one
very simple reason – some things are just ridiculously difficult
(if not damned near impossible) to test. These cases don't come up
often, but they do occasionally come up. Other than that, test your
code. For everyone's sake.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<blockquote class="twitter-tweet" lang="en">
<div dir="ltr" lang="en">
<a href="https://twitter.com/MaggieL">@MaggieL</a> "You must know what TDD is" is still a bad requirement. And no, "we do TDD here and so will you" is something I get a lot.</div>
— Bodil Stokke (@bodil) <a href="https://twitter.com/bodil/status/637992020309606400">August 30, 2015</a></blockquote>
</div>
<div style="margin-bottom: 0in;">
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I disagree. If the entire team (or
company) does TDD, then <i><u><b>yes</b></u></i>,
it is a valid requirement for the job. If you refuse to use TDD, then
you don't have a place on the team for reasons that I've already
outlined. In fact, I'm glad more places are making it a requirement
(provided that their people write good tests).</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
The
sad thing is that I hear these sorts of arguments a lot. Thankfully,
however, I seem to be hearing them less lately. I honestly welcome
constructive criticism of practices because it helps people grow. You
need to be prepared to have others respond to that criticism though.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Just
complaining about a methodology you don't like without valid reasons
doesn't help anyone (and that's exactly what that last tweet was).</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Current
mood: Calm</div>
<div style="margin-bottom: 0in;">
Current
music: INXS – The Stairs</div>
James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-51640029801794595832015-04-24T14:35:00.001-05:002015-04-24T21:07:39.161-05:00TDD in Android Part 1 – Getting Started<div style="margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibdsY3qOUntgupl6nryC3wFLR0mtMnKu5hhQg86B8wRtVYGH6nLf7pbGHrCrY2IPDylqal8lqSpD6-BpyB8ksi6PhULyQOJQLzdgCu2Td_ZD0lrPyIC63GvjccrecKqGlPP18Huw/s1600/ruUGXhh.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibdsY3qOUntgupl6nryC3wFLR0mtMnKu5hhQg86B8wRtVYGH6nLf7pbGHrCrY2IPDylqal8lqSpD6-BpyB8ksi6PhULyQOJQLzdgCu2Td_ZD0lrPyIC63GvjccrecKqGlPP18Huw/s1600/ruUGXhh.jpg" height="221" width="320" /></a></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I've recently started learning how to
write apps for the Android platform and, since the company I work for
does all of our development in a Test Driven (TDD) fashion, I'm
writing my first app using the same methodologies.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Unfortunately, the Android platform
apparently wasn't designed with TDD in mind. Automated Unit and UI
testing currently seem to be second class citizens because there
isn't a lot of good information on testing in android. There are now
decent tools, but not a lot of documentation on how to use them or
avoid pitfalls.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I think it's time that we work to
improve that shortcoming, so my plan is to walk you through the
process of creating an app from scratch while pointing out the
pitfalls and gotchas that I come across on the way so you will have a
better chance of avoiding them. This entry represents the end result
of my Sprint 0 (setup) phase for the app. It took about a week and a
half of going through online documentation and talking with
co-workers to get to this point. With this, you should be able to do
it in an afternoon.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>My App:</b></div>
<div style="margin-bottom: 0in;">
<a href="https://github.com/jameshollingshead/BartenderApp" target="_blank">Pocket Bartender</a>. This should be a
relatively simple app since it's just going to be a fairly basic CRUD
app. It will take a drink name or ingredient and give you a recipe or
list of recipes for that drink or the drinks that use that
ingredient. I'll also probably add functionality to favorite and hide
drinks.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>My Environment:</b></div>
<div style="margin-bottom: 0in;">
Macbook Pro</div>
<div style="margin-bottom: 0in;">
Phone: Samsung Galaxy s5 (sprint)
running Android 5.0 (Lollipop)</div>
<div style="margin-bottom: 0in;">
Tablet: Samsung Galaxy Tab 4 (sprint)
running Android 4.4.2 (KitKat)</div>
<div style="margin-bottom: 0in;">
IDE: Android Studio 1.0.1</div>
<div style="margin-bottom: 0in;">
Emulator (phone): Nexus 5 API 21 x86</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<h3>
<span style="font-size: medium;"><b>Environment
Setup</b></span></h3>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>IDE:</b></div>
<div style="margin-bottom: 0in;">
Before you start, you'll need to have
the Java 1.8 JDK installed and configured properly since coding for
Android is done in Java (I am told that Groovy also works, but I
haven't looked into seeing what's required to be able to code for
Android in it).</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Next, you'l want to install Android
Studio. Since I was working through the <a href="https://www.udacity.com/course/developing-android-apps--ud853" target="_blank">Udacity Android course</a> before starting this project, I had Android Studio installed already.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Run the Android SDK Manager (<i><b>Tools
> Android > SDK Manager</b></i>) and install the following
packages:</div>
<div style="margin-bottom: 0in;">
API 19</div>
<div style="margin-bottom: 0in;">
Build-tools 21.1.2</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
These two packages will be required by
the tools we'll install later.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Hardware:</b></div>
<div style="margin-bottom: 0in;">
Now that your IDE is installed, you'll
need to enable developer mode on your phone and/or tablet (assuming
that you want to test on hardware as well as in the emulator). How to
do this may vary by phone maker/model, so I'll leave that portion of
the exercise to you. It should just take a quick google search.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
When you have enabled Developer Mode,
go into <i><b>Settings > Developer Options</b></i> and make the
following changes:</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
USB Debugging – ENABLED</div>
<div style="margin-bottom: 0in;">
Window Animation Scale – OFF</div>
<div style="margin-bottom: 0in;">
Transition Animation Scale – OFF</div>
<div style="margin-bottom: 0in;">
Animator Duration Scale – OFF</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
According to documentation, the last
three settings can be manipulated via code, but it's easier to just
turn them off in the Developer Options menu.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Open Android Studio and make a dummy
project with a blank activity. We will be using this project later,
so don't delete it after you're done with this step. <span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">When
the project is created, follow the directions outlined in Step 3
under <a href="http://developer.android.com/tools/device.html" target="_blank">“Setting up a Device for Development”</a> to set up your phone to be able to receive files from Studio.</span></span></span>
The steps required to do this vary by operating system.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
When you plug your phone into your
computer, it may not immediately show the dialog asking if you want
to allow your phone to communicate via USB. If you don't see the
window, don't worry. Just lock and unlock your phone a couple of
times until it gives you the dialog.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
You'll need to do this for each device
you want to connect to your computer.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I've been told by one of my co-workers
that his phone occasionally disables USB Debugging, so if you are
having problems transferring your program from Android Studio to your
phone or tablet, make sure the setting is enabled. Also, Android
Studio occasionally fails to load the program properly, so you may
just have to make sure the program is uninstalled on your phone and
re-try (this happens to me on a somewhat regular basis).</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<h3>
<span style="font-size: medium;"><b>Project
Setup</b></span></h3>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Robolectric and Espresso:</b></div>
<div style="font-weight: normal; margin-bottom: 0in;">
While you can
write unit tests for android in JUnit, the tests tend to run pretty
slowly. Robolectric is considerably faster. Additionally, you can run
UI tests using Espresso. Getting this set up manually is not a
trivial task, but thankfully there is a project on github that will
help alleviate a lot of the pain.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Download the <a href="https://github.com/robolectric/deckard-gradle" target="_blank">Deckard project</a>
and follow the instructions on the page in order to get the project
imported into Android Studio. The Deckard project comes with a
Robolectric test file and an Espresso test file, both of which should
run from the IDE as well as the command line. You may need to plug
your phone into your computer in order to get the Espresso tests to
run from the command line.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
If you've ever done android development
before, you will notice that the Deckard project is missing a <b>lot</b>
of things. It is literally about as bare bones as a TDD android
project can be and still function. We'll be fixing that later, but
for now, what we have is fine.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Go ahead and change your package names
to something that makes sense for your project and make sure the
tests still pass. Just make sure that <i><b>everything is in the same
package</b></i><span style="font-style: normal;"><span style="font-weight: normal;">.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
At this point, the screen you get on
your phone should look like this: </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1T2XbaMgj-MLX58kgarwo85Nh0eZaQ2HUsGTq7i8FpRdCbPrHxoIe87JK3qwfSypl6ydLa1-T0eq9MTisGyep4oYGfzNLbUtZKbBU9qVNXaBhR6mbaxAhQkR2Xdpnz8QD2BSfAQ/s1600/hello_espresso.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1T2XbaMgj-MLX58kgarwo85Nh0eZaQ2HUsGTq7i8FpRdCbPrHxoIe87JK3qwfSypl6ydLa1-T0eq9MTisGyep4oYGfzNLbUtZKbBU9qVNXaBhR6mbaxAhQkR2Xdpnz8QD2BSfAQ/s1600/hello_espresso.jpg" height="226" width="320" /></a></div>
<div style="margin-bottom: 0in;">
<i><u><b><br /></b></u></i></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Dagger:</b></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Dagger
is a dependency injection (DI) tool for android. According to all
accounts, it is considerably faster than Roboguice (which was being
used heavily before).</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Setting
up Dagger is fairly simple. Open your <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/build.gradle" target="_blank">build.gradle</a> file and, make it
look like this version from my git repo.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Most
of the changes are pretty self explanatory since they're just adding
gradle entries for dagger and dagger-compiler. However, there are a
couple of changes that require a little explanation.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>compile
'com.squareup:javawriter:2.5.0'</b><span style="font-weight: normal;">
is used in order to resolve a dependency conflict between Dagger and
Espresso. Both tools use javawriter, but they call for different
versions. This, along with the </span><b>exclude</b><span style="font-weight: normal;">
calls in dagger, dagger-compiler, and espresso-core forces the
application to use a version that works with both. </span>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">At
this point, most of the main tools for doing TDD in android are
installed. We'll probably install Mockito for using mocks later, but
we don't need it right now, so we'll do that when it comes up.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<h3>
<span style="font-size: medium;"><b>Hello
World</b></span></h3>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Before
we write our first code example of DI with Dagger, let's make a small
change to the app in order to convince ourselves that it's really
working (this will be the basis of the code we're injecting in a
minute, so bear with me). </span>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Open
DeckardActivity.java and add the following lines to onCreate:</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;"><b>TextView
t = new TextView(this);</b></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;"><b><br />
</b></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;"><b>t
= (TextView)findViewById(R.id.text);</b></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;"><b>t.setText(“foo”);</b></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Running
your Espresso tests should now cause them to fail (that's a good sign
in this case). Open DeckardEspressoTest.java and change the
.check(matches()) statement to look for “foo” instead of “Hello
Espresso”, run the tests to make sure they pass and then run the
application in either your emulator or phone. The resulting screen
should look like this:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhtkhhHv0tR8meQllsS0RDuUsDzU5XjPJQfOstgK-1Bg6l2Eslx5-B1ECRTKHy1GH_6eJdia1VZdlukoTMcVy6_K2b-frhsyQA78W-VLYf3qJu2f7AAUxKnl8CU2-geVltXCSSoQ/s1600/Foo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhtkhhHv0tR8meQllsS0RDuUsDzU5XjPJQfOstgK-1Bg6l2Eslx5-B1ECRTKHy1GH_6eJdia1VZdlukoTMcVy6_K2b-frhsyQA78W-VLYf3qJu2f7AAUxKnl8CU2-geVltXCSSoQ/s1600/Foo.jpg" height="260" width="320" /></a></div>
<div style="margin-bottom: 0in;">
<b><i><u><br /></u></i></b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Now
that we know that we can change the message on the screen
programmatically and the UI tests will still pass with the new string
on the screen, we can write our first DI module. Make a <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/src/main/java/com/jameshollingshead/Foo.java">Foo interface</a>
file as well as a <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/src/main/java/com/jameshollingshead/FooObject.java">FooObject class</a> file with the contents of the files
linked to on my github account. This is what we will be injecting. </span>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">You'll
also need to make a module file in order to handle the actual
injection. In this case, the file is <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/src/main/java/com/jameshollingshead/DummyModule.java">DummyModule</a>. Go ahead and copy
the contents of the file from my github. Note that the </span><b><i><span style="text-decoration: none;">injects</span></i></b><span style="font-weight: normal;">
line states the classes that the module will be injected </span><b><i><u>into</u></i></b><span style="font-weight: normal;">.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Open
your <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/src/main/java/com/jameshollingshead/DeckardApplication.java" target="_blank">DeckardApplication.java</a> file and make the changes needed to make
it look like the linked file on my github. At this point, I need to
point out a couple of things that will save you future headaches.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">First,
while you can build the ObjectGraph by using DummyModule as an
argument directly, I am told that you will want to build it using the
getModules method for ease of testing later.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br />
<div style="margin-bottom: 0in;">
Second,
in this example, getModules returns a List of type DummyModule. If
you are using more than one module, it will return a List of type
Object. Logically speaking, you <b><i>should</i></b>
be able to make the example in this file return a List of type
Object, but if you try, you get the incredibly weird error that your
program can't cast type DummyModule as type Object (which makes no
sense considering that, as a class, DummyModule inherits from
Object). I have no idea <b><i>why</i></b>
this is the case, but it is.</div>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Now
for the step that brings together everything we've done so far. Alter
your <a href="https://github.com/jameshollingshead/BartenderApp/blob/4b950716beba8215b39c2bc3fbfff4ff2d75a425/Source/BartenderApp2/src/main/java/com/jameshollingshead/DeckardActivity.java" target="_blank">DeckardActivity</a> to look like the one linked to in my github
repo. The changes from the last time that we touched the file (to
make the screen read “foo”) are using @Inject to inject an
instance of FooObject, to set a string equal to fooObject's
provideText return value and to set the text on the screen equal to
that string.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Your
Espresso test should now be red. You'll need to change the
DeckardEspressoTest.java file to check for “injected foo” instead
of “foo” in order to make it green again.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Now,
if everything works the way it should, your tests will pass and, when
you run the program on either your phone or in the emulator, you
should see the following: </span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0wQNxMzzK_-Oeo_90JERxDoPs59v50nKtQj6g9YUy9OyaI17ThvRz80mUDp72NZpnQVpTvNtcRi_JdBO_sYz_ThAvN7x1QknsODj_56J6VlcGhJuiV5EIRE570Fz4tYEtfQ9qTQ/s1600/injected_foo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0wQNxMzzK_-Oeo_90JERxDoPs59v50nKtQj6g9YUy9OyaI17ThvRz80mUDp72NZpnQVpTvNtcRi_JdBO_sYz_ThAvN7x1QknsODj_56J6VlcGhJuiV5EIRE570Fz4tYEtfQ9qTQ/s1600/injected_foo.jpg" height="215" width="320" /></a></div>
<div style="margin-bottom: 0in;">
<b><i><u><br /></u></i></b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">You're
now set up to do TDD in android (minus the mocking tools, which we'll
get to later). The program as it stands needs a great deal of work to
get where we're going, but we're off to a good start. </span>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">In
the next entry in this series, we'll start Sprint 1 tasks.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-weight: normal;">Current
mood: Even</span></div>
<div style="margin-bottom: 0in;">
Current
music: The Guess Who – No Time</div>
James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-50663369017506546702015-04-10T14:49:00.001-05:002015-04-10T14:51:44.192-05:00Encouraging the Next Generation<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhupC0cFKB0DFhF73ZgVcyGP7rCcqH_qy8os2CVwLtPYmXuu0Uq1jwUHRb3Xe6duQHw_uw4ce16AWx35C9fxiJKHCTsEPW-waoMx6JU0JfYUVdTaCD4Ssb1KQGymi-Hv7qONDFNVQ/s1600/somuch128455571027812500.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhupC0cFKB0DFhF73ZgVcyGP7rCcqH_qy8os2CVwLtPYmXuu0Uq1jwUHRb3Xe6duQHw_uw4ce16AWx35C9fxiJKHCTsEPW-waoMx6JU0JfYUVdTaCD4Ssb1KQGymi-Hv7qONDFNVQ/s1600/somuch128455571027812500.jpg" height="240" width="320" /></a></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Recently, some of
the people where I work have started a weekly writing prompt in order
to get people to blog more often. This week's topic is “How do we
involve the next generation of young minds?” and was inspired by
two of my co-workers building quadcopters with a group of students in
the northern part of the state.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
This is a very
open topic and very difficult to cover in a way that is less wordy
than a copy or War and Peace (or at least your average work by
Stephen King). However, I think it can be approached by breaking it
down into a number of subjects which need to be addressed.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
That being said,
let's begin.</div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Start Them Early</b></h3>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
The truth is that
the earlier you start to instill curiosity and creativity in people,
the easier it is to get them to continue on that path. There are a
number of ways to do this, but if you're looking for ways to get a
small child started, <a href="http://www.amazon.com/LEGO-Classic-Medium-Creative-Brick/dp/B00NHQFA1I/ref=sr_1_2?ie=UTF8&qid=1428694422&sr=8-2&keywords=lego" target="_blank">Legos</a>, <a href="http://www.amazon.com/Lincoln-Logs-Shady-Pine-Homestead/dp/B003MGJTDI/ref=sr_1_4?s=toys-and-games&ie=UTF8&qid=1428694460&sr=1-4&keywords=Lincoln+Logs" target="_blank">Lincoln Logs</a>, <a href="http://www.amazon.com/Tinkertoy-100-Piece-Essentials-Value/dp/B00CTJOGOG/ref=sr_1_2?s=toys-and-games&ie=UTF8&qid=1428694492&sr=1-2&keywords=Tinker+Toys" target="_blank">Tinker Toys</a>, etc are really
a wonderful way to get the ball rolling. They offer nearly endless
ways to combine pieces creatively, are tactile (which helps a lot of
people, children or not. Never underestimate the value of physically
building and handling something), and are generally fairly
affordable.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Realize that not
everything has to involve circuitry and code. Even things like basic
woodworking projects can help instill creativity and the engineering
mindset. I've built everything from birdhouses and toolboxes to
actual buildings while I was growing up and I learned something
valuable from every project.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
As they get a
little older, introduce them to things like <a href="http://www.amazon.com/ScienceWiz-7901-Inventions-Kit/dp/1886978034/ref=sr_1_2?s=toys-and-games&ie=UTF8&qid=1428694593&sr=1-2&keywords=crystal+radio+kit" target="_blank">crystal radio kits</a>, <a href="http://www.amazon.com/dp/B0035XSZDI/ref=wl_it_dp_o_pd_nS_ttl?_encoding=UTF8&colid=3CWIX5XGO35E9&coliid=I1BK69WK3UFKHR" target="_blank">130-in-1 experiments kits</a> (yes, they still make those), <a href="http://www.amazon.com/Elenco-SC-100-Snap-Circuits-Jr/dp/B00008BFZH/ref=sr_1_1?s=toys-and-games&ie=UTF8&qid=1428694651&sr=1-1&keywords=snap+circuits" target="_blank">snap circuits</a> and even
simple programming languages like <a href="https://scratch.mit.edu/" target="_blank">Scratch</a> and <a href="https://turtleacademy.com/" target="_blank">Logo</a>. A little later
still get them involved in writing code on something like a <a href="http://www.amazon.com/CanaKit-Raspberry-Complete-Original-Preloaded/dp/B008XVAVAW/ref=sr_1_3?s=electronics&ie=UTF8&qid=1428694756&sr=1-3&keywords=Raspberry+Pi" target="_blank">RaspberryPi</a> (it's fairly inexpensive and if you somehow manage to botch the
os, just re-flash the SD card and start over. You can even extend it in order to interact with hardware). <a href="http://www.amazon.com/Tangoes-T100-Classic/dp/B00000K3BU/ref=sr_1_1?ie=UTF8&qid=1428694930&sr=8-1&keywords=tangrams" target="_blank">Tangoes</a> are also a wonderful, inexpensive tool for teaching spatially related problem solving.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
You want things
that are simple to get a beginner's grasp of yet versatile enough to
keep their attention after they master the basics and, most
importantly, make them want to learn even more.
</div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Mindset</b></h3>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
“<i>A mind all
logic is like a knife all blade. It makes the hand bleed that uses
it.”</i></div>
<div style="font-style: normal; font-weight: normal; margin-bottom: 0in;">
- Rabindranath Tagore</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Logic is a very
important part of being successful in technology fields. However,
there is another part of the equation that is often overlooked –
creativity. You really do need both the ability to think your way
through a problem as well as the ability to look at a problem from a
completely different angle than other people at times.
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
We need to foster
not only logical thought, but also appreciation of and involvement in
the arts. I would almost argue that the <i><b>type </b></i><span style="font-style: normal;">of
art doesn't matter nearly as much as being involved. Painting,
drawing, writing, music, theater, and countless others – all of
these things exercise your brain in ways that simple logic based
problem solving doesn't.</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">On
the logical side, we need to encourage the next generation of
technical people to cultivate the skills to look at situations
objectively, come up with a set of possible answers, and then
evaluate or work through them (revising their general assumptions as
they uncover more information) until they reach a conclusion. This is
the time for measured experimentation instead of just wildly poking
at a problem until something happens (though, admittedly, sometimes
poking at the problem is necessary in order to uncover behavior).</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">Encourage
the next generation to ask questions. That's not to say that you
should spoon feed them the answers since guiding them through the
discovery process is both an extremely effective way of teaching and
often fun for everyone involved. However you do it, you should
encourage them to ask the “whys” and “what ifs”.</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">Continuing
in the vein of asking questions, foster the questioning of authority.
If someone says “You can't do that” they should ask </span><span style="font-style: normal;"><b>WHY</b></span><span style="font-style: normal;">.
If it's because doing that thing is dangerous, that's one thing. If
it's just because they don't think it can be done or because of other
foolish reasons (“getting above your station”, “that's not
something that proper girls/boys do”, etc), they should be
encouraged to </span><span style="font-style: normal;"><b>CHALLENGE
IT</b></span><span style="font-style: normal;">. </span>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">We
are, among other things, professional troublemakers. We create and
change current reality as a part of our jobs. It's what we </span><i><b>do</b></i><span style="font-style: normal;"><span style="text-decoration: none;">.
Innovation is inherently disruptive. Embrace that; don't try to stomp
it out of the next generation.</span></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">Encourage
reading. I can't stress this enough. Fiction, non fiction, philosophy
– just read. It exposes you to different voices and approaches from
your own. It's literally a different view on the world, and being
exposed to that will help you grow.</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b><span style="font-style: normal;">Quick
Feedback, Small Victories</span></b></h3>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">Make
initial victories easy to attain. This is especially true for younger
children. Defeat is frequently demoralizing. Starting off with a
victory encourages people to continue. It doesn't matter if it's just
making a ball bounce on the screen. Give them something that provides
near instant feedback that </span><i><b>they</b></i><span style="font-style: normal;">
have </span><i><b>done something </b></i><span style="font-style: normal;">with
a real, </span><i><b>visible</b></i><span style="font-style: normal;">
result. </span>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">As
they progress, keep feedback loops tight even though the difficulty
of what they are doing increases with time. Yes, I realize that this
sounds a lot like Agile practices. </span>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b><span style="font-style: normal;">Make
it Safe to Fail</span></b></h3>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
“<i>I have not
failed. I've just found 10,000 ways that won't work.”</i></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">-
Thomas A. Edison</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Failure, both
professionally and personally, is an occasional fact of life. No
matter what we try or how hard we work, there are times when things
just won't happen the way we want them to.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
The problem is
that we have stigmatized failure to such a degree in this society
that some people are afraid to even <i><b>try</b></i><span style="font-style: normal;">
because they might fail. This needs to stop. </span>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-style: normal;">Teach
people that it's okay to fail on occasion. That's not to say that we
should excuse laziness, but re-enforce the idea that failure
occasionally happens, treat it as a learning experience, and teach
others not to fear making a mistake.</span></div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Access to Tools</b></h3>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
It may not occur to a lot of us in this
field that not everyone is as well off as we are from an economic
standpoint. Not everyone has ready access to the equipment needed to
learn various technical skills. This is especially true in both
poorer urban and rural areas.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Access to programing tools (IDEs, etc)
has become considerably cheaper thanks to open source tools and
educational/community licenses offered by companies like JetBrains
and Microsoft. However, for some people, computers are still an
expense that they can't justify (even if they are much cheaper than
when I started learning to program).</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
That's not to mention the expense of
things like quadcopter kits. Some of the things that you need access
to for some projects are simply out of reach for a number of individuals as well as
some school districts without outside help.</div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Access to Mentors</b></h3>
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
When I started
out, I didn't have any mentors to help me learn how to code. The
internet wasn't an option (yes, dinosaurs roamed the Earth and we had
to walk to school uphill both ways). I had never even met or spoken
to a professional software developer until I was in college. In fact,
the only other people I knew who wrote code were a few friends in
basically the same situation as myself.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
It would have been
much easier and a lot less discouraging if I had had access to
mentors (even online) instead of having my only resources when I
started out be the manual for a <a href="http://en.wikipedia.org/wiki/TRS-80_Color_Computer" target="_blank">TRS-80 color computer</a> and the
occasional code sample in magazines borrowed from our very small
public library (I <i><b>told</b></i> you that dinosaurs roamed the
Earth at the time).</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
If you want to
encourage the growth of a new generation of creative and technical
people, you have to literally be there to encourage and guide them.
Answer questions on the internet, make yourself available to
schools/after school clubs and programs, and generally be a good
community member.</div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Parental Involvement</b></h3>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
This is the really
difficult one. In order to encourage young people to go into
technology based careers, their parents have to be positively
involved. They can't just treat the computer as a way to babysit
their child or, possibly even worse, view everything that their child
does, no matter what it is, as simply “playing on the computer”
like my parents did (which, I might add, included programming
homework in college).</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Keeping up
momentum when it feels like nobody cares or you are being actively
discouraged is extremely difficult. Not everyone is as hard headed as
I am.
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Parents don't even
have to be experts in the field. They just have to be positive
influences. Be curious about what your child is doing, encourage
them, have them show off what they're doing to you a bit. Be a
cheerleader. It's important.</div>
<div style="margin-bottom: 0in;">
<br />
<br /></div>
<div style="margin-bottom: 0in;">
<h3>
<b>Show Me The Money</b></h3>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Show people that
there is a (generally) fun, well paying job doing work in this field
and that it doesn't matter if they're a girl or a boy or even what
socio-economic background they come from as long as they work at it.
After all, it's important to be able to do things like pay your
bills, go on vacation, and buy sandwiches.
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
As I said, this is
by no means an easy problem, and this is only the short list of
things that can be done to help, but it's a start and even if you can
only manage a few of them that's better than the alternative.</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
Current mood: calm</div>
<br />
<div style="margin-bottom: 0in;">
Current music:
Murray Head – One Night in Bangkok</div>
James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-31031688568527625352015-03-06T10:54:00.000-05:002015-03-06T10:54:03.783-05:00A New Chapter – A Long Overdue Update<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ8k0LQQFlXYGC7mjpa89hAAsfWSHwcXr22YrUOb1JpfWYfr1ACE2OWcVFQ9M7laBQNdPm2aX0N-MKAbckdnccwZOvAoDgqpABAsm8tfvO0I-7mQfZIhst-TsQT9myGDe_MRAqRA/s1600/gorillabuddha128500394295156250.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ8k0LQQFlXYGC7mjpa89hAAsfWSHwcXr22YrUOb1JpfWYfr1ACE2OWcVFQ9M7laBQNdPm2aX0N-MKAbckdnccwZOvAoDgqpABAsm8tfvO0I-7mQfZIhst-TsQT9myGDe_MRAqRA/s1600/gorillabuddha128500394295156250.jpg" height="240" width="320" /></a></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
First off, I apologize for the radio
silence. It's been kind of crazy (for varying reasons) and I haven't
devoted a lot of time to writing for a while. I plan to change that
(or at least attempt to) going forward.</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
For the few of you that didn't see the
announcement on twitter when it happened, I've taken down my personal
shingle and joined the team at <a href="http://pillartechnology.com/" target="_blank">Pillar Technology</a>. This move came
after about 3 years of discussion between me and the team there.
Before this, the timing just wasn't right, but things were different
this time, so I joined back in mid-October.
</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
Since then, I've worked on an embedded
software project for a Fortune 100 farming equipment manufacturer and
a dev-ops(ish) cross compile project that allows the code that I was
working on in the first project to be compiled for i386, x86-64,
Atom, and ARM architectures.
</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
It was odd writing C++ code after 10
years away from the language for the first project and really cool to
be able to have a real reason to learn how to code in Python for the
second one. Over the last few months, I feel like I've stuffed my
brain to the point of overflow and then looked around and said
“more!” That's an amazing feeling.</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
The funny thing is that, before I
started, I joked about wanting to try to use TDD in C++. My first
project involved exactly that lol</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
On top of that, I'm diving into
learning Android development, which means I get to remember Java (a
language that I haven't used in several years since I was doing
mostly .NET work for quite some time).</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
I work with an amazing group of people
that make me feel like an idiot child (which is probably a good thing
for me, honestly, because it pushes me to grow more). My line on the
matter is that, on a good day, I might outsmart the trash can.
Thankfully, most of the people around me seem to have similar
mindsets (about themselves, not about me), so there's not a whole lot
of ego-driven nonsense going on.</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
I can honestly say that there is
basically nobody here that I've worked with so far that I don't enjoy
working with and learning from. That sort of environment is really
rare.</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
Here's hoping that our working
relationship continues (and continues to improve) for quite some time
to come. And, as always, the opinions I express are my own unless explicitly stated otherwise.</div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
Current mood: Contemplative</div>
<br />
<div style="margin-bottom: 0in;">
Current music: Hound Dog - Rocks</div>
James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-51301187022456647572014-10-31T05:56:00.003-05:002014-10-31T05:56:57.589-05:00Happy Anniversary<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s1600/rain-drop-red-roses.jpg" height="320" width="240" /></a></div>
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-12267565473166741242014-10-14T10:28:00.003-05:002014-10-14T10:28:59.991-05:00Happy Birthday<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s1600/rain-drop-red-roses.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLSlhqyG0o5I0uHqdt1-6Ehsjj_p4SoNBl0xE7EaC30-ADrRWBVMSWtGjlz9QpY74X0LJjCg1sjT-cArrpATwAwNzs98EEKiCP6mv1Xth2bAELh5J8VbssK8WpPCSC7FNmVpak0w/s1600/rain-drop-red-roses.jpg" height="320" width="240" /></a></div>
<br />James Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0tag:blogger.com,1999:blog-13833028.post-37039090437028404782014-05-01T08:51:00.000-05:002014-05-01T09:08:06.967-05:00Sometimes Optimization Matters (Recursion vs Iterative OR "A 4 Billion Character String is REALLY Long")<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPfcjQA3TQz4VWlQrM9R3uPY_F9yX-L1BCM-GF7nzb6NC3rV87Y7dIgouqQpRkGShhe62U-eXMCkFaHIxdHYPYGvarI6zmlN_p3t9zQVMob43ZoHNM274Nc38m8QAhar5qiTFDvA/s1600/celebrity-pics-hyneman-sava.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPfcjQA3TQz4VWlQrM9R3uPY_F9yX-L1BCM-GF7nzb6NC3rV87Y7dIgouqQpRkGShhe62U-eXMCkFaHIxdHYPYGvarI6zmlN_p3t9zQVMob43ZoHNM274Nc38m8QAhar5qiTFDvA/s1600/celebrity-pics-hyneman-sava.jpg" height="281" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Computers today are really fast. In fact, they’re fast
enough that some people don’t bother to optimize a lot of code. Sometimes
that’s okay – after all, premature optimization isn’t a positive thing and can
see you spending a great deal of time in exchange for little or no gain. Other
times, however, you know there’s going to be a difference of an order of
magnitude or more on a computation intensive part of a system.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
As an example, there is a <a href="https://www.codeeval.com/open_challenges/125/" target="_blank">coding challenge</a> on CodeEval to
find the character in a string at a specific location. You aren’t given the
string ahead of time, just the first character and the pattern to use in order
to build the string (up to a string length of 3,000,000,000).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I’ll summarize here since it’s pretty simple. The character
set is 0, 1, and 2. The first character is 0. You build out the string by using
the previous string as the first half of the new string and add one to each
digit. This means that 0 => 01 => 0112 => 01121220 and so on. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
You only want one character in the string (we’ll call it N).
The rest, as far as you are concerned, is garbage.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The knee jerk reaction for a lot of people would be to build
the string to the length that you need and just access the character directly.
That might even be okay if your upper bound for length wasn’t 3 BILLION. Given
that, however, you need a better way (I’ll show you why here in a little
while).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
If you take a minute to look at it, you’ll realize that, by
following the pattern they’ve defined for the number, that you will always end
up with a string that has a length of a power of 2 (1, 2, 4, 8, 16, and so on).
That means that you can determine how long the shortest string of that pattern
will be by taking x = Ceiling of log2(N) and then calculating 2^x.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
That doesn’t help us much by itself, but with that
information, the pattern, and the fact that we only need one character, it
makes this problem a prime candidate for recursion.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><u><span style="font-size: large;">Method 1 –
Recursion</span><o:p></o:p></u></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Recursion can be kind of a scary word for some people
because initially it can be sort of difficult to wrap your brain around.
However, given a little practice, the hardest parts of the exercise are
structuring the problem in a way that you can use recursion and making sure
that you actually write it properly (in fact, it took me a little while to get
rid of a bug because I had a line of code in the wrong place).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I’ll link to <a href="https://github.com/jameshollingshead/CodeKata/tree/master/PredictTheNumber-3-27-2014" target="_blank">the code</a> here so I don’t have to walk through
everything, but to put it succinctly, after calculating the needed string
length, the recursive approach essentially keeps track of where the target
character would be during each string transformation, uses that to calculate
how many times the character would have to change (C) and then calculates our N
= C % 3 (each character is essentially a one digit base 3 number, so we can get
away with that).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
It’s probably as close to doing the problem with pure math
as you can get without actually having an equation. As a result, it’s quick.
REALLY quick. Fast enough, in fact, that I had to measure runtime in ticks
(according to <a href="http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx" target="_blank">MSDN documentation</a>, it takes 10,000 ticks to make up a
millisecond).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The chart below shows the runtime (in both ticks and
milliseconds) of one calculation for each given string length (2^0 through
2^32) – not counting file I/O or output to screen (which the original project
required). This is just the time from being handed the number to getting the
answer to what N is.</div>
<div class="MsoNormal">
<br /></div>
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 4.65pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; width: 504px;">
<tbody>
<tr style="height: 12.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Power
of 2<o:p></o:p></span></b></div>
</td>
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Recursive
Runtime (in Ticks)<o:p></o:p></span></b></div>
</td>
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Recursive
Runtime (in Milliseconds)<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 1;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 2;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">1<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">10<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 3;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">2<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 4;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">3<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 5;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 6;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 7;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 8;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">7<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 9;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">8<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 10;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">9<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 11;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">10<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 12;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">11<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 13;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">12<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 14;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">13<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 15;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">14<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 16;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">15<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 17;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">16<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 18;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">17<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 19;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">18<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 20;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">19<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 21;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">20<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 22;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">21<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 23;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">22<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 24;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">23<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 25;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">24<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 26;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">25<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 27;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">26<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 28;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">27<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">32<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 29;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">28<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 30;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">29<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 31;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">30<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 32;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">31<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">7<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 33; mso-yfti-lastrow: yes;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">32<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">7<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Note that the 32 tick runtime for the 2^27 length string is
an aberration (probably caused by time slicing in the operating system).
Running it multiple times, every test case ran at 20 ticks or below (generally
10 ticks or less). The only reason it looks like a big difference is because
ticks are really <i>REALLY</i> tiny.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
So, to sum up the pros and cons for the recursive approach
to this problem</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Pros: </b>Really
fast. Takes up less memory because there’s no actual string being built.</div>
<div class="MsoNormal">
<b>Cons: </b>More
difficult to write and debug</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><u><span style="font-size: large;">Method 2 –
Iterative (Don’t do it this way. Please) </span><o:p></o:p></u></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Again, I’ll give you <a href="https://github.com/jameshollingshead/CodeKata/tree/master/PredictTheNumber-4-27-2014" target="_blank">the code</a> for this method. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
This time, we’re actually building the string in order to
find the character. There are a few problems with this. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
First is that it’s SLOW. I initially tried doing it two
different ways. The first way ran for over <b><i>HALF AN HOUR</i></b> trying to calculate the
2^32 length string before I stopped it. The way which is in the code linked
above runs much faster because it uses String.Replace() but seems to use more
memory.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Second, it takes up A LOT of memory because it’s actually
building the string and keeping it in memory. That’s not a big deal when the
string is small, but according to the <a href="http://blog.abstractpath.com/2012/08/how-much-memory-does-c-string-take-up.html" target="_blank">formula here</a>, the size of
just the string at its maximum length is 512MB.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Below is the benchmark data for this approach using the same
constraints (no file or screen I/O) and the same numbers as the recursive
approach.</div>
<div class="MsoNormal">
<br /></div>
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: 4.65pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; width: 504px;">
<tbody>
<tr style="height: 12.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Power
of 2<o:p></o:p></span></b></div>
</td>
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Iterative
Runtime (in Ticks)<o:p></o:p></span></b></div>
</td>
<td nowrap="" style="background: #969696; height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<b><span style="font-family: Arial; font-size: 10.0pt;">Iterative
Runtime (in Milliseconds)<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 1;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 2;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">1<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 3;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">2<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 4;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">3<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 5;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">4<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">7<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 6;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">5<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">9<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 7;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">21<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 8;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">7<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">17<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 9;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">8<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">35<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 10;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">9<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">56<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 11;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">10<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">111<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 12;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">11<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">281<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 13;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">12<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">386<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 14;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">13<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">2011<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">0<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 15;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">14<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6360<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">3<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 16;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">15<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">12657<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 17;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">16<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">12528<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 18;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">17<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">125246<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">61<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 19;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">18<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">57912<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">28<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 20;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">19<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">53481<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">26<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 21;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">20<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">101440<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">49<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 22;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">21<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">204253<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">99<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 23;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">22<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">400705<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">195<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 24;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">23<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">1250113<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">611<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 25;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">24<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">1778822<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">869<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 26;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">25<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">3158791<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">1544<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 27;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">26<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">6980949<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">3412<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 28;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">27<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 29;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">28<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 30;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">29<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 31;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">30<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 32;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">31<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">OME<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 12.75pt; mso-yfti-irow: 33; mso-yfti-lastrow: yes;">
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 56.0pt;" valign="bottom" width="75"><div align="right" class="MsoNormal" style="text-align: right;">
<span style="font-family: Arial; font-size: 10.0pt;">32<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 143.0pt;" valign="bottom" width="191"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">NA<o:p></o:p></span></div>
</td>
<td nowrap="" style="height: 12.75pt; padding: 0in 5.4pt 0in 5.4pt; width: 179.0pt;" valign="bottom" width="239"><div class="MsoNormal">
<span style="font-family: Arial; font-size: 10.0pt;">NA<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
OME stands for Out Of Memory Exception. These test cases
literally caused the program to exceed its allocated memory (it was compiled
for “any processor” since NUnit’s test runner didn’t want to play nicely with
forced x64 solutions).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The NA result at 2^32 reveals a special problem. In C#, a
character at a specific index of a string is accessed by using stringName[int].
The catch is that 2^32 is larger than an Int (you need at least a Long if you
want a number that big), so you’d need to compensate by doing a substring to
chop off the first Int32.MaxValue and reducing the index by the same amount. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I did that in the first attempt at this problem, but since I
found out it was going to throw memory exceptions, I decided that I’d refrain
from re-implementing it for the sake of simplicity and more readable code.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
As you can see, this approach is MUCH slower than the
recursive one. In fact, the general trend is to roughly double the runtime for
each larger string. This means that a string of length 2^32 would take roughly 384,000,000
ticks (38,400,000 times the length of time for the recursive solution assuming
the recursive solution took 10 ticks).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
This is, of course, assuming you made the string from
scratch for every test case. You could get around that to an extent by storing
the string and just building it out longer as needed. However, you’d still be
eating up a lot of memory to store the string. At its longest, the string would
be over 4 billion characters long. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
That’s longer than <b><i>War And Peace</i></b>. This is why,
sometimes, optimization really matters.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I’m not sure I really need to sum up the pros and cons for
this approach, but </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Pros:</b> Stupidly
easy to write</div>
<div class="MsoNormal">
<b>Cons:</b> Slow and
memory intensive.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
That’s not to say that recursion is the right answer to
every problem, because it isn’t. There are times, however, when the extra work
in designing a more efficient algorithm in order to tackle a problem can really
pay off.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Just some food for thought.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Current mood: thoughtful</div>
Current music: Shawn Mullins – LullabyJames Hollingsheadhttp://www.blogger.com/profile/01904517837102103620noreply@blogger.com0