tag:blogger.com,1999:blog-337770382024-03-28T06:50:58.425+00:00programmer.grrl(copy + paste) code = badprogrammergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.comBlogger42125tag:blogger.com,1999:blog-33777038.post-6814862341241596312011-03-05T15:00:00.001+00:002011-03-05T15:56:07.211+00:00Book Review: Dependency Injection in .NET<p>This isn't so much a review as just a note that I read <a href="http://www.manning.com/seemann/">Dependency Injection in .NET</a> by Mark Seemann and found it pretty helpful in clearing up some of my confusions about dependency injection frameworks.</p><p>I already was aware of the basics of constructor injection, but was experiencing some pain around problems like constructor over-injection and lots of 1-1 mapping between interfaces and implementations. This book explores ways to fix these issues and many others.</p><p>Here are some topics the book covered that I really appreciated:</p><ul><li>DI patterns, including the different types of injection, and Ambient Context
</li><li>DI antipatterns, including Service Locator
</li><li>DI refactorings, including Abstract Factory and dealing with cyclic dependencies
</li><li>Object composition, including implementing the composition root for common types of .NET applications</li><li>Interception</li></ul><p>I particularly liked the way the Interception chapter went over Decorators and how to configure them, and then moved into how to implement and configure interception.</p><p>
</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com61tag:blogger.com,1999:blog-33777038.post-76872353137183133932009-10-26T15:13:00.001+00:002010-09-05T21:45:09.703+01:00Estimating is Like Measuring the Coast of Great Britain<p>Earlier today, <a href="http://lizkeogh.com/">Liz Keogh</a> <a href="http://twitter.com/lunivore/status/5168577622">tweeted this</a>, which I couldn't agree with more, as long as she's saying what I think she's saying: </p> <blockquote>Thinking about fractal estimation—estimates grow as scale shrinks—and wondering what dimension current projects have.</blockquote> A while back, every time I started doing technical estimates for a release, I began to think more and more of the illustrations along the side of this Wikipedia article: <a href="http://en.wikipedia.org/wiki/How_Long_Is_the_Coast_of_Britain%3F_Statistical_Self-Similarity_and_Fractional_Dimension">How Long Is the Coast of Britain? Statistical Self-Similarity and Fractional Dimension</a>. <p></p> <p>The situation was, that as a developer in a waterfall process, when I was trying to estimate how long it would take to code something, even with the requirements supposedly "fixed," unless I examined the code I was proposing to change in so much detail that I was basically writing it—and that's <b>not</b> estimating anymore—I'd always miss things that would make coding take longer than I'd estimated. In essence, there were always craggy little details that upon actually writing the code, became significant or added up with others to become significant. </p> <p>Now, I know that if your architecture and code are clean, this should happen less. But I still think it's generally true that until you actually write the code, you really don't know how long it will take, and the amount of time will usually be longer than you think when analyzing it at higher levels. </p> <p>Then, I thought of this problem again when I attended a talk on <a href="http://programmergrrl.blogspot.com/2009/07/scope-budgeting.html">Scope Budgeting</a>. There, the general issue is that in Agile, if you write a user story, estimate it, put it in your backlog, and only elaborate it when you pull it back out to implement it, you may find that the size of the story grows at elaboration-time. </p> <p>According to Liz's fractal estimation rule, that makes complete sense and should be expected. I agree. Whenever I have worked with user proxies to move from general functional requirements to specifics, the estimate has always increased. The amount of work needed to address all the details we discover always grows beyond the original estimate. If we made commitments based on that estimate, the only way to keep them is to prioritize and remove some of the details. </p> <p>I can think of a few ways to address this problem, if we want to consider it to be a problem:</p> <ol> <li>Just be aware of it and deal with it as needed, which is a lot better than not being aware of it at all. </li> <li>Start measuring it, so you can factor it into your future estimates. This might be taken care of by comparing estimates to actuals and factoring that into future estimates. You'll need to decide whether the time it takes to do this is worth the return, though. </li> <li>Move toward techniques like <a href="http://www.agilemanagement.net/Articles/Weblog/KanbanPlanningandEstimati.html">Kanban that de-emphasize estimation</a>. Whether or not this works for you will depend on your current situation, but it's always worth questioning whether you're estimating because you truly need to or just because that's what you're used to. </li> </ol> <p> <hr /></p> <p>Update Sept, 2010:</p> <ul> <li>Liz also wrote about the fractal nature of estimation as part of <a href="http://lizkeogh.com/2009/11/30/estimation-anti-patterns/">Estimation anti-patterns</a>.</li> <li><a href="http://blog.dannorth.net/">Dan North</a> mentioned it in <a href="http://blog.dannorth.net/2009/07/01/the-perils-of-estimation/">The perils of estimation</a>.</li> <li>Dan also has referenced it more recently in <a href="http://blog.dannorth.net/2010/08/30/introducing-deliberate-discovery/">Introducing Deliberate Discovery</a>.</li> </ul> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com1tag:blogger.com,1999:blog-33777038.post-73847571048620521502010-09-05T21:28:00.001+01:002010-09-05T21:28:53.633+01:00A Real-Life Short-Short Story About Software Craftsmanship<p>One day, at the end of my team's daily stand-up meeting, one person said he was cleaning out his garage. He'd found a couple of books that his previous employer gave to all new hires. And that now he would like to get rid of those books to anyone interested.</p> <p>One of the books was <a href="http://my.safaribooksonline.com/0-201-73386-2">Software Craftsmanship</a> by <a href="http://www.improvingwetware.com/">Pete McBreen</a>.</p> <p>One of our managers laughed, saying, "Oh, so now you're all going to be <em>craftsmen</em>."</p> <p>Several other people laughed, too.</p> <p>After they were done laughing, I said that I thought it was a good book and I recommended reading it.</p> <p>There was silence.</p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com14tag:blogger.com,1999:blog-33777038.post-67665813530783018672010-07-25T22:16:00.001+01:002010-07-26T20:42:47.799+01:00Book Review: Professional Software Development<p>I can understand how many people sound as though they were disappointed in Steve McConnell's <a href="http://www.stevemcconnell.com/psd.htm">Professional Software Development: Shorter Schedules, Better Projects, Superior Products, Enhanced Careers</a>. It's not a "practical" book—like <a href="http://www.stevemcconnell.com/cc.htm">Code Complete</a>, <a href="http://www.stevemcconnell.com/rdcntnt.htm">Rapid Development</a>, or <a href="http://www.stevemcconnell.com/est-toc.htm">Software Estimation</a>—that you can immediately put into practice and improve your software's code or schedules.</p> <p>But whether or not you agree with McConnell's conclusions about how to "fix" software development by turning it into a profession—like engineering, medicine, or law—it does a good job highlighting some of the ongoing struggles in developing software.</p> <p>Many other reviews point out that the stratification and specialisation advocated by McConnell seem out of touch with agile development, and I agree. On the other hand, agile development encourages "<a href="http://www.agilemodeling.com/essays/generalizingSpecialists.htm">generalising specialists</a>," not straight-up generalists.</p> <p>Other reviewers have also pointed out that the ladder-like professional development program promoted by McConnell also seems overly-regimented, and I agree with that, too. On the other hand, if career progression depends on taking specific classes, publishing articles, or participating in conferences, that might be better than not being allowed time for any learning or professional development at all, which happens at some companies.</p> <p>[To be continued in "<a href="/2010/07/does-engineering-need-to-be-profession.html">Does 'Software Engineering' Need to be a Profession?</a>"]</p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com61tag:blogger.com,1999:blog-33777038.post-66393867112753226462010-07-26T20:39:00.001+01:002010-07-26T20:39:34.748+01:00Does "Software Engineering" Need to be a Profession?<p>[This is Part 2 of a review of Steve McConnell's book <a href="http://www.stevemcconnell.com/psd.htm">Professional Software Development</a>. Read Part 1 <a href="/2010/07/book-review-professional-software.html">here</a>.]</p> <p>In proposing that software development should become a true profession, McConnell points out that for a something to be considered a profession, it must have</p> <blockquote> <ul> <li>A requirement for extensive learning and training. </li> <li>A code of ethics imposing standards higher than those normally tolerated in the marketplace. </li> <li>A disciplinary system for professionals who breach the code. </li> <li>A primary emphasis on social responsibility over strictly individual gain, and a corresponding duty of its members to behave as members of a disciplined and honorable profession. </li> <li>A prerequisite of a license prior to admission to practice. </li> </ul> </blockquote> <p>In discussing licensing, McConnell notes</p> <blockquote> <p>Licensing is a <em>mandatory</em>, legal process that is intended to protect the public, and is typically administered by jurisdictions (states, provinces, and territories).</p> </blockquote> <p>And</p> <blockquote> <p>One of the consequences of being a professional engineer is that you can be held personally liable for the work your company performs under your signature. Courts in the United States have held that only members of a profession can be found guilty of malpractice. Doctors, lawyers, and architects can be guilty of malpractice. Garbage truck drivers, short order cooks, and computer programmers cannot be guilty of malpractice because, legally, they aren't considered to be professionals.</p> </blockquote> <blockquote> <p>No individual engineer will be required to be licensed, but some companies eventually will be required to employ licensed engineers.</p> </blockquote> <blockquote> <p>Professional engineers in these companies will review software engineering work and sign off on the software their companies deliver. To those companies, employing professional engineers will be a legal necessity. If software companies follow other engineering disciplines, the company that hires a professional engineer will pay for liability insurance as part of the professional engineer's employment package, which will minimize that disadvantage of getting your professional engineering license.</p> </blockquote> <blockquote> <p>Professional engineers will gain other benefits. The professional engineers who put their signature and reputation on the line for their companies will have final say over methodology choices, design approaches, and other decisions that affect the quality of the software for which they might be held liable. Without professional standing, your boss can come to you and demand that you commit to an unrealistic schedule, make shortsighted design compromises, or sacrifice quality in order to get the software out the door. With a well-defined profession—consisting of education, a code of ethics, and licensing—you will be able to say, "The standards of my profession don't allow me to shortchange quality in this situation. I could lose my license or get sued." You will have a professional and legal basis for standing up to unenlightened managers, marketers, and customers—a basis that is sorely lacking today.</p> </blockquote> <p>Wow. In some ways, it sounds great to have a legal basis for saying no to bad development practices. In other ways, it sounds very scary to be subject to that liability.</p> <p>Mostly, though it makes me wonder if software development truly needs to have "standards higher than those normally tolerated in the marketplace" and "a primary emphasis on social responsibility over strictly individual gain." It makes me want to know more about what happened to make it generally agreed that in engineering, medicine, and law, public good can't be ensured by the marketplace alone.</p> <p>Because right now, one of the arguments for high standards in software development is that it's a good business decision. "<a href="http://programmer.97things.oreilly.com/wiki/index.php/Speed_Kills">The only way to go fast is to go well</a>," as <a href="http://blog.objectmentor.com/articles/category/uncle-bobs-blatherings">Uncle Bob Martin</a> says. Or, we want to make sure we don't take on the <a href="http://forums.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx">wrong kind of technical debt</a>, because that will be bad for the company in the long run.</p> <p>But for a profession, these high standards don't have to be justified solely in marketplace terms. Instead, they have been accepted by society as being important for its own public interest.</p> <p>In discussing how engineering came to be a profession, McConnell says:</p> <blockquote> <p>Historically, professional engineering has been established in response to threats to public safety. Although we take the safety of modern bridges for granted, in the 1860s American bridges were failing at the rate of 25 or more per year. Bridge failures and the loss of life they caused precipitated creation of a stricter engineering approach to bridge design and construction.</p> </blockquote> <p>I wonder what sort of disaster would need to happen for society to demand higher standards in software development. Or would a slow build-up of buggier and buggier software be enough? How many times do you need to lose your data, have your computer crash, or just plain not be able to figure out how to do what you want in a user interface before you've had enough? And if you've had enough, can you buy a competitor's software instead, or is it just as buggy?</p> <p>Can the problems of today's software development be fixed by the marketplace, or do they require regulation? Does software development need to be a profession?</p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com236tag:blogger.com,1999:blog-33777038.post-76188253908378601242010-07-10T09:58:00.001+01:002010-07-10T09:58:50.483+01:00Book Review: Growing Object-Oriented Software, Guided by Tests<p>Recently, I read <a href="http://www.growing-object-oriented-software.com/">Growing Object-Oriented Software, Guided by Tests</a> by Steve Freeman and Nat Pryce. Amongst excellent discussions of other TDD topics, it sheds a lot of light on good ways to use mock objects. </p> <p>Personally, I can remember reading Martin Fowler's <a href="http://martinfowler.com/articles/mocksArentStubs.html">Mocks Aren't Stubs</a> quite a while ago and concluding that I'd be a "classicist." </p> <p>Some time later, I started working with mocks as a way to isolate unit tests from "slow" dependencies, such as databases, trying to make them run more quickly. I didn't have much success, though, because I was still writing my tests in a classicist style. </p> <p>This book helped open my eyes to how the "mockist" style really works, and why it can be a good thing. I absolutely recommend it to any programmer who is doing TDD (or writing unit tests), but who still feels like when it comes to being a mockist, they just don't get it. </p> <p>I also think a great complement to the book is the video of J. B. Rainsberger's presentation <a href="http://www.infoq.com/presentations/integration-tests-scam">Integration Tests Are A Scam</a>. </p> <p>As a note on how to read the book, I got a bit bogged down in the middle section, with the worked example. I ended up skipping to the final section and came back to the middle after. Reading it like that worked just fine. I also think it could be interesting to alternate chapters of the middle section with those of the final section.</p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com12tag:blogger.com,1999:blog-33777038.post-59914457100213560132010-04-24T17:13:00.001+01:002010-04-29T21:33:55.900+01:00Do Unit Tests and Quality Code Result in Fewer Bugs?<p>At the end of my team's last release, I set out to prove that unit tests and quality code lead to fewer bugs.</p> <p>Here are the tools I used.</p> <p><strong>Jira</strong></p> <p>The first thing to know is that the team I'm on keeps its features in <a href="http://www.atlassian.com/software/jira/">Jira</a>, and when we commit code to <a href="http://subversion.apache.org/">Subversion</a>, we include the Jira ID in the comments.</p> <p>Below, you'll see how this helped me relate code to features.</p> <p>The second thing to know is when we find bugs in a feature during its development, in Jira we link those bugs back to the parent feature.</p> <p>This allowed me to measure how many bugs had been reported for each feature at release.</p> <p><strong>SvnPlot</strong></p> <p>There's an open source project called <a href="http://code.google.com/p/svnplot/">svnplot</a> that allows you to export the information stored in svn to a <a href="http://www.sqlite.org/">SQLite</a> database. To do this, follow the instructions in Step 1 of the <a href="http://code.google.com/p/svnplot/wiki/Introduction">Quick Start</a>.</p> <p>You end up with a couple tables that include rows for each revision, including the comment and the files that were added, removed, and changed.</p> <p><strong>ANTLR</strong></p> <p>I used <a href="http://antlrcsharp.codeplex.com/">ANTLR C# grammar</a> to help map the files changed to classes.</p> <p><strong>NCover</strong></p> <p>I used <a href="http://www.ncover.com/">NCover</a> to measure unit test coverage of the added and changed classes.</p> <p><strong>NDepend</strong></p> <p>And finally, I used <a href="http://www.ndepend.com/">NDepend</a> to measure code quality of those classes, as well as to query the coverage metrics.</p> <p><strong>Results</strong></p> <p>This is the part where I'd love to show some fancy graphs proving my point. Unfortunately, the results weren't exactly conclusive.</p> <p>I ended up dropping the idea of trying to correlate code quality to number of bugs altogether, because I just ended up with a mess.</p> <p>The results for how unit test coverage related to bugs is sort-of presentable, at least, but they don't show a nice correlation:</p> <table border="1" cellspacing="0" cellpadding="2"><tbody> <tr> <th>Feature</th> <th>LOC Changed / Bug</th> <th>Average Coverage (%)</th> </tr> <tr> <td>1</td> <td>521</td> <td>65</td> </tr> <tr> <td>2</td> <td>290</td> <td>38</td> </tr> <tr> <td>3</td> <td>165</td> <td>0</td> </tr> <tr> <td>4</td> <td>140</td> <td>54</td> </tr> <tr> <td>5</td> <td>125</td> <td>21</td> </tr> <tr> <td>6</td> <td>76</td> <td>25</td> </tr> <tr> <td>7</td> <td>74</td> <td>77</td> </tr> <tr> <td>8</td> <td>59</td> <td>30</td> </tr> <tr> <td>9</td> <td>2</td> <td>80</td> </tr> </tbody></table> <p>I'd like to think I'll try again another day, but given those results, I just don't know. I can come up with many reasons why things didn’t come out the way I'd hoped:</p> <ul> <li>The amount of change for each feature was very diverse. Some features involved lots of code changes and others involved very few, so that the features may not really be comparable in this way. </li> <li>Some features involved mostly changing UI code, where the coverage can't be high, because we don't currently have a good way to unit test our UI code. </li> <li>Some features, especially Feature 9, had high test coverage, but the unit tests were very low on actual assertions. </li> <li>There's just not enough data. </li> </ul> <p>In the end, if my argument to the business is that unit tests and code quality are important because they reduce the number of bugs, results like these won't help me make my case.</p> <p>So, if you know of more persuasive results—either your own or stuff out there in the literature—I'd love to hear about it :-)</p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com50tag:blogger.com,1999:blog-33777038.post-77921614309822532052010-03-08T15:10:00.001+00:002010-03-08T15:10:39.693+00:00Using the Windows Findstr Command to Find Text, Files and Folders<p>Currently, I like the <a href="http://technet.microsoft.com/en-us/library/bb490907.aspx"><code>findstr</code></a> command better than other ways to search files in Windows.</p> <p><strong>Prerequisite: Open Command Window Here</strong> <br />For XP, it's part of <a href="http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx">Microsoft PowerToys for Windows XP</a>.</p> <p>For Vista and Windows 7, apparently you <a href="http://blogs.msdn.com/tims/archive/2006/09/18/windows-vista-secret-1-open-command-prompt-here.aspx">hold down the hold down the shift key and right click</a>.</p> <p><strong>Finding File Contents</strong> <br />Once you have a command window open at the directory you want to search within, you  can do something like this, which will return all lines containing "MyText" in all subdirectories of the current one, case-insensitive, and only searching files that contain printable characters:</p> <p><code>findstr /s /i /p "MyText" *.*</code></p> <p>It turns out that "MyText" is treated as a regular expression, which is great. But if you don't want it treated as a regular expression, you can use the <code>/l</code> or <code>/c:</code> options. </p> <p><strong>Finding File & Folder Names</strong> <br />Instead of giving <code>findstr</code> files to search, you can pipe text to it from another command, so to search for file or folder names, you can give it the results of the <code>dir</code> command to search:</p> <p><code>dir /s /b | findstr /i "MyFileName.txt"</code></p> <p><strong>Combining the Two</strong> <br />Say you want to find all the lines containing "MyText", except you don't want those that are part of a subversion directory. You can do this, where the <code>/v</code> option means only return lines that <em>don't</em> match:</p> <p><code>findstr /s /i /p "MyText" *.* | findstr /v /l ".svn"</code></p> programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com16tag:blogger.com,1999:blog-33777038.post-13435719343074258312009-12-06T16:43:00.004+00:002010-03-07T17:43:11.226+00:00A Year Of London Developer Events<p>Today marks a year since I moved to London from Chicago. So far, my favourite thing about being here is <strike>the trains run like clockwork</strike> the vibrant software developer community.</p><p>Here is a list of events I've attended, all of which I highly recommend:</p><ul><li><a href="http://altnetgroup.com/">AltNetBeers and AltNetWorkshops</a> organised by <a href="http://serialseb.blogspot.com/">Sebastien Lambla</a> <a href="http://twitter.com/serialseb"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li><a href="http://www.dnug.org.uk/">London .NET User Group</a> organised by <a href="http://codebetter.com/blogs/ian_cooper/default.aspx">Ian Cooper</a> <a href="http://twitter.com/icooper"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a> and <a href="http://www.zimakki.com/blog/">Zi Makki</a> <a href="http://twitter.com/zimakki"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li>Open Source .NET, Architecture & DDD, Agile PM & Scrum, and Agile Testing & BDD events at <a href="http://skillsmatter.com/go/home">Skills Matter</a> <a href="http://twitter.com/skillsmatter"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a>. Several of the ones I've been to were organised by <a href="http://gojko.net/">Gojko Adzic</a> <a href="http://twitter.com/gojkoadzic"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li><a href="http://openspacecode.com/">Open Space Coding Days</a> organised by <a href="http://alandean.blogspot.com/">Alan Dean</a> <a href="http://twitter.com/adean"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li><a href="http://www.altnetuk.com/">The Alt.Net UK Conference</a> organised by Alan Dean, Ian Cooper, <a href="http://blog.benhall.me.uk/">Ben Hall</a> <a href="http://twitter.com/ben_hall"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a>, and Sebastien Lambla</li><li><a href="http://www.meetup.com/DDD-London/">DDD Meetups</a> organised by Adam Shimali</li><li><a href="http://www.thoughtworks.co.uk/">ThoughtWorks</a> <a href="http://londongeeknights.wetpaint.com/">London Geek Nights</a> organised by <a href="http://rrees.wordpress.com/">Robert Rees</a> <a href="http://twitter.com/rrees"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li><a href="http://xpday-london.editme.com/eXtremeTuesdayClub">eXtreme Tuesday Club</a> <a href="http://twitter.com/extremetuesday"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li><li><a href="https://wave.google.com/wave/#restored:wave:googlewave.com!w%252Bfn0VOKp-D">#DevBookClub</a> <a href="http://search.twitter.com/search?q=devbookclub"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a> organised by <a href="http://holytshirt.blogspot.com/">Toby Henderson</a> <a href="http://twitter.com/holytshirt"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a> and <a href="http://www.shift-in.com">Chris Browne</a> <a href="http://twitter.com/shiftin"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter" /></a></li></ul>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com6tag:blogger.com,1999:blog-33777038.post-32770408831614135012010-02-18T23:30:00.002+00:002010-02-18T23:33:18.894+00:00Software Development Career Paths: Up or Out?<p>Continued from <a href="/2010/02/software-development-career-paths.html">Software-Development Career Paths: Organizational Quality</a>.</p> <p><strong>Moving Up <br /></strong>For this option, mostly I can only repeat the traditional oft-heard worries: your tech skills will get rusty and you'll be stuck in middle-management forever.</p> <p>On the other hand, I don't think developers who like to code should dismiss moving up out of hand. If you get a chance, try it. Who knows, you might like it.</p> <p>There's a nice discussion about staying technical as a manager over on Rands In Repose: <a href="http://www.randsinrepose.com/archives/2007/02/07/technicality.html">Technicality</a>. If you keep your technical skills sharp, then hopefully if it turns out that you hate being a manager, you can still go back to being a developer.</p> <p><strong>Moving Out <br /></strong>Lately I have a new perspective on moving out, thanks to the software craftsmanship movement. How many books and articles have you read lately that use the word "journeyman?" There's a reason the word "jouney" is in there.</p> <blockquote> <p>In parts of Europe… spending time as a journeyman, moving from one town to another to gain experience of different workshops, was an important part of the training of an aspirant master. [Wikipedia, <a href="http://en.wikipedia.org/wiki/Journeyman">Journeyman</a>]</p> </blockquote> <p>Although I don't think it's a perfect book, <a href="http://my.safaribooksonline.com/9780596806842">Apprenticeship Patterns</a> by Dave Hoover and Adewale Oshineye is currently the best reference I know for thinking about different ways to approach a career as a software craftsman from the perspective of an individual developer rather than that of a manager.</p> <p><strong>Another Option: Stay Small, Maybe Even Really Small <br /></strong>Keep in mind that not all organizations force you to choose between coding and managing. Smaller companies often don't have "<a href="http://www.togsblom.com/2010/02/i-just-want-to-be-programmer-but-can-i.html">Eiffel Tower corporate hierarchies</a>." If you're moving around, you might find more satisfaction sticking with smaller companies, especially since that way you're more likely to personally provide value to customers, as described by Cameron Purdy in his great article <a href="http://www.jroller.com/cpurdy/entry/eight_theses">Eight Theses</a>.</p> <p>Don't forget that you can go it on your own. Recently at DDD8, <a href="http://geekswithblogs.net/twickers/Default.aspx">Liam Westley</a> gave <a href="http://vimeo.com/9216563">a talk</a> about owning your own software development company. Of course, the talk assumed that you already "have commercial ideas, clients, or sales leads." I have no idea how to get to that point, but the fact that Liam was there giving the talk is a reminder that people actually do manage it.</p> <p><strong>Staying Motivated <br /></strong>Whether you literally become a journeyman by moving among companies or you stay for a long time at a single company, if you don't want to move up, you may need to look for non-traditional ways to keep yourself up-to-date technically and otherwise generally motivated, especially if you find yourself occasionally working at places that treat you as an interchangeable coding machine.</p> <p><a href="http://my.safaribooksonline.com/9780596806842">Apprenticeship Patterns</a> gives some ideas about how to do this. Obviously, there are always things like learning new languages, participating in either local or virtual developer communities, and in open source projects.</p> <p>Interestingly, all of those things follow a general leadership-followership pattern that's pointed out in <a href="http://my.safaribooksonline.com/9780787996659">The Art of Followership</a>:</p> <blockquote> <p>[An] example, which is becoming increasingly common in developed countries, occurs with employees who have extensive professional education. These employees can often perform their work assignments without relying on technical guidance from their hierarchical superiors. Their education often includes a strong socialization component, instilling in them a desire for autonomous, self-controlling behavior and the tendency to look to their professional colleagues for support and recognition. This often occurs with university professors who are highly educated and tenured. These individuals often view their university as a place to practice their teaching and research skills with little interference by administrators. They work with and obtain feedback from colleagues, they read academic journals for up-to-date information on their field, and they derive intrinsic satisfaction from their publications and recognition at academic conferences. Similar tendencies exist in firms that provide consulting and accounting services. In these instances, professional education and socialization can replace or substitute for a leader's direction and supportive behavior. [Chapter 3, Three Perspectives on Followership by Howell and Mendez]</p> </blockquote> <p>I don't think the software development profession has necessarily quite reached this point yet, but it's an interesting perspective to keep in mind. Ideally, you can get "support and recognition" from your "hierarchical superiors" as well as your peers. Anything else is draining. However, in a pinch, don't forget to look out as well as up to get the sustenance you need to nurture your craft.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com27tag:blogger.com,1999:blog-33777038.post-90965788207832241002010-02-16T23:09:00.002+00:002010-02-18T23:32:28.197+00:00Software-Development Career Paths: Organizational Quality<p>A developer-friend of mine, <a href="http://www.togsblom.com/">Tom Wessels</a>, recently asked the computer-age-old question:</p> <blockquote> <p><a href="http://www.togsblom.com/2010/02/i-just-want-to-be-programmer-but-can-i.html">I just want to be a programmer. But can I?</a></p> </blockquote> <p>He follows up the question with a great quote from the great and still-relevant book <a href="http://www.amazon.com/Peopleware-Productive-Projects-Teams-Second/dp/0932633439/">Peopleware</a> by DeMarco and Lister, which points the career path encouraged, or at least tolerated, by many organizations: If you're not on your way up, you'd best be on your way out.</p> <p>To be fair, DeMarco and Lister follow up this description with a contrasting one, "The Mentality of Permanence:"</p> <blockquote> <p>Over the years, we have been privileged to work and consult for a few companies with extraordinarily low turnover. You won't be surprised to learn that low turnover is not the only good thing about these companies. Indeed, they seem to excel at many or most of the people-conscious qualities discussed in these pages. They are the best…. In the best organizations, the short term is not the only thing that matters. What matters more is being the best. And that's a long-term concept.</p> </blockquote> <p>DeMarco and Lister go on to describe ways in which these companies invest in their employees, fostering a culture of learning, professional improvement, permanence, and organizational excellence.</p> <p>To answer the question, I think you need to look at your career along a few different dimensions. One of which is the quality of the organizations at which you will work.</p> <p>It might be possible, to get a job at one of these "best organizations" and be comfortable for some time with one of the options Tom presents:</p> <blockquote> <p>You reach a point where you just accept that you're at a good company, you get to write code in a somewhat enjoyable fashion, and you leave it at that.</p> </blockquote> <p>Hooray! Yes, I think it would be good for everyone to at least have that option for a few years at some point in their careers.</p> <p>But a couple things stand in the way. </p> <p>First, it can be hard to get a job at an organization like that, not only because its bar to entry might be pretty high, but also because from the outside, it can be hard even to identify which companies are truly the best. Or maybe you just don't happen to live near the offices of any of those best organizations and aren't able to move.</p> <p>Second, nothing lasts forever, including "being the best." I'm not sure the great organizations DeMarco and Lister use to demonstrate their "mentality of permanence" are still considered to be the best now that it's 10-20 years later: Reader's Digest, Hewlett-Packard, Pacific Bell? Even the lean software development movement's favourite company, Toyota, has recently shown signs of falling off the "being the best" pedestal.</p> <p>In short, the mentality of permanence may not be permanent. If you're lucky enough to find yourself working for one of these best organizations, that's super. Enjoy it while it lasts, or for as long as you're comfortable staying. But don't be shocked if it doesn't last forever.</p> <p>Which brings us to the next dimension. Given that you might find yourself working at lower-quality, "up or out" organizations during your career, should you move up or should you move out?</p> <p>Continued in <a href="/2010/02/software-development-career-paths-up-or.html">Software Development Career Paths: Up or Out?</a></p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com53tag:blogger.com,1999:blog-33777038.post-63686498422537509342009-07-04T12:10:00.006+01:002010-01-05T21:43:55.020+00:00FireFox 3.5: How To Bring Back "Close Last Tab"<p>
First, in about:config, set <code>browser.tabs.closeWindowWithLastTab</code> to <code>false</code>.
</p><p>
Then, add the following to <code>userChrome.css</code> (via <a href="http://veerasundar.com/blog/2009/07/closing-the-last-tab-in-firefox-35/comment-page-1/#comment-1086">comment on Veera Sundar's blog</a>):</p>
<pre class="brush:css">
.tabbrowser-tabs[closebuttons="alltabs"]
> .tabbrowser-tab > .tab-close-button
{
display: -moz-box !important;
}
.tabbrowser-tabs:not([closebuttons="noclose"]):not([closebuttons="closeatend"])
> .tabbrowser-tab[selected="true"] > .tab-close-button
{
display: -moz-box !important;
}
</pre>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-21054602355312381462009-08-03T21:44:00.028+01:002009-12-16T19:48:39.196+00:00Open Space Coding Day: TDD As If You Meant It and Cucumber With IronRuby<p>
Saturday I was at the <a href="http://www.altnetuk.com/2009-08-01.en.html">Open Space Coding Day</a> that was part of the <a href="http://www.altnetuk.com/2009.en.html">Alt.Net UK Conference 2009</a>.
</p><p>
In the morning, I was in the session on <a href="http://www.parlezuml.com/softwarecraftsmanship/sessions/tdd_as_if_you_meant_it.htm">TDD As If You Meant It</a>. <a href="http://gojko.net/">Gojko Adzic</a> already did a pretty good write up, so I'll point you there to learn more about it: <a href="http://gojko.net/2009/08/02/tdd-as-if-you-meant-it-revisited/">TDD as if you meant it – revisited</a>.
</p><p>
In the afternoon, I was in the session about using <a href="http://cukes.info/">Cucumber</a> and <a href="http://rspec.info/">RSpec</a> with <a href="http://www.ironruby.net/">IronRuby</a>. Mostly, I was interested in this because I keep hearing really good things about Cucumber, but as a non-ruby person, I have never quite discovered what those good things actually look like.
</p><p>
I was also a bit psyched, because I was pretty sure I'd heard that <a href="http://en.oreilly.com/oscon2009/public/schedule/detail/7965">IronRuby was going 1.0 on my birthday</a>. But alas, it seems that article subtly changed since I last looked at it, from saying "IronRuby is 1.0!" to now saying "IronRuby is <i>almost</i> at 1.0!" A slight let-down, but that's okay. We still had a good session, and I'm the first person to understand that software doesn't always magically appear on a certain date just because we want it to.
</p><p>
To install IronRuby, Cucumber, and RSpec, I mostly used these instructions:</p><ul><li><a href="http://weblogs.asp.net/astopford/archive/2009/04/14/bdd-with-rspec-cucumber-ironruby.aspx">BDD with RSpec\Cucumber\IronRuby</a></li><li><a href="http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net">IronRuby and .NET</a></li></ul>The process for me went something like this:<ol><li><a href="http://rubyforge.org/projects/rubyinstaller/">Install Ruby</a>.<br /><br /></li><li><a href="http://www.ironruby.net/Download">Install IronRuby</a>. (The day I was doing this, 0.6 was being billed as the current release. It looks like things have moved on.)<br /><br /></li><li>From <a href="http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net">IronRuby and .NET</a>, do:</li><ol><li>Installing required gems</li><li>Creating a Cucumber wrapper script for IronRuby</li><li>Running the examples<br /><br /></li></ol><li>Now the examples ran, but there was some weird escape-character output. I didn't find the answer to how to fix this, but another person in the session, <a href="http://www.codegrunt.co.uk/">Lorenzo Stoakes</a> <a href="http://twitter.com/lstoakes"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter"></a>, did. <a href="http://search.twitter.com/search?q=%23ironruby+%23altnetuk">Here's how that looked on Twitter</a>.<br /><br />For convenience, though, I guess I'll compile that into the single sentence: In your file that corresponds to <code>C:/Ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.92/lib/cucumber/formatter/ansicolor.rb</code>, replace <code>Term::AnsiColor.coloring = false if...</code> with <code>Term::AnsiColor.coloring = false</code>.</li></ol><p>At that point, the examples seemed to sort-of run okay for me. I think Lorenzo and <a href="http://blog.robustsoftware.co.uk/">Garry Shutler</a> <a href="http://twitter.com/gshutler"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYKsYow5QwiJjEvOawbJNM4kYbhut-lYhyphenhyphenFJGmKLIrJqIOTWeSe3CcKG5bit_gkCf08rwG0GwJ2MpeP9-sNmK_IzOXPqcThohHWI0Wvcsmavrq-JYkmyhwYWNVvcVRXeViJLoY/s800/twitter_square_blue.gif" class="twitter" alt="Twitter"></a> got past some warnings that were getting output, but I didn't. I'm also pretty sure Garry also got RSpec to work.
</p><p>
What was the whole point? Well, since I didn't get past the examples, I'll sum it up with one of them.
</p><p>
Say you're developing a calculator. Your business person can specify the addition behaviour in text, like this:</p><pre class="brush:text">Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario Outline: Add two numbers
Given I have entered <input_1> into the calculator
And I have entered <input_2> into the calculator
When I press add
Then the result should be <output> on the screen
Examples:
| input_1 | input_2 | output |
| 20 | 30 | 50 |
| 2 | 5 | 7 |
| 0 | 40 | 40 |</pre><p>And you can make that executable by adding some code in a related code file like this, where you're testing a .NET assembly Calculator.dll that contains a Calculator class in the namespace Demo, and the Calculator class has <var>push</var> and <var>Add</var> methods:</p><pre class="brush:ruby">require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
require 'Calculator' # Calculator.dll
Before do
@calc = Demo::Calculator.new # A .NET class in Calculator.dll
end
Given "I have entered $n into the calculator" do |n|
@calc.push n.to_i
end
When /I press add/ do
@result = @calc.Add
end
Then /the result should be (.*) on the screen/ do |result|
@result.should == result.to_i
end</pre><p>That does look pretty sweet.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com1tag:blogger.com,1999:blog-33777038.post-6383548657487712902008-05-14T16:23:00.013+01:002009-12-16T19:35:39.342+00:00JavaScript: The Return [no LineTerminator here] Statement<p>
I was just reading <a href="http://www.amazon.com/dp/0596517742/">JavaScript: The Good Parts</a> by Douglas Crockford, and came across this statement:</p><blockquote>I always use the K&R style, putting the { at the end of a line instead of the front, because it avoids a horrible design blunder in JavaScript's return statement.</blockquote><p>A while back, I was introduced to using closure to help get rid of unnecessary global variables in JavaScript by a friend at work, along with the book <a href="http://www.amazon.com/dp/159059908X/">Pro JavaScript Design Patterns</a>. Instead of something like this:</p><pre class="brush:javascript">var myString = 'hi';
function doStuff() {
alert(myString);
}</pre><p>You write something like this:</p><pre class="brush:javascript">var myNamespace = function() {
var myString = 'hi';
return {
doStuff: function() {
alert(myString);
}
}
}();</pre><p>But, because I like BSD style, I did this, with line breaks before the opening braces:</p><pre class="brush:javascript">var myNamespace = function()
{
var myString = 'hi';
return
{
doStuff: function()
{
alert(myString);
}
}
}();</pre><p>
When I tried to call doStuff, I promptly got the JavaScript error "myNamespace is null or not an object."</p><p>After much head-scratching and debugging, I learned the hard way that <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a> defines the return statement like this:</p><blockquote>return [no <i>LineTerminator</i> here] <i>Expression<sub>opt</sub></i> ;</blockquote><p>Let me put that a slightly different way:</p><blockquote>return [<span style="font-weight: bold; color: red;">!!!NO <i>LINE_TERMINATOR</i> HERE!!!</span>] <i>Expression<sub>opt</sub></i> ;</blockquote><p>And that's the story of how I became a convert to using K&R style when coding JavaScript.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-17198124200953798272009-08-08T19:22:00.020+01:002009-12-16T19:18:29.561+00:00Misadventures In BDD With NBehave<p>
From my previous post, you might have picked up that I like the idea of BDD's given-when-then construct for describing scenarios.
</p><p>
For a while, I've been wanting to use this syntax in unit/integration tests to make them clearer. But I've been hoping to do that without switching languages or unit-testing frameworks. Toward that end, I tried out <a href="http://nbehave.org/">NBehave</a>.
</p><p>
Here's some test code that demonstrates my worst fears about why NBehave might not be right for me:
</p>
<pre class="brush:csharp;">public void Execute()
{
var story = new Story("Search Contacts by Relationship Strength")
.AsA("User")
.IWant("To search on the Strength field")
.SoThat("I can find Contacts who have a given Strength");
Scenario scenario = story
.WithScenario("Find Contacts with Strength of 50");
scenario.Given("The database contains a Contact with a Strength of 50")
.And("a search results view", GivenResultsInfo)
.And("a query for Contacts with Strength of 50",
GivenQueryForContactsWithStrengthOf50)
.When("The search is run", WhenRunSearch)
.Then("The results contain Contacts with Strength of 50",
ThenShouldContainResultsWithStrengthOf50);
}
private void GivenResultsInfo()
{
var resultsView = new ReadOnlyResultsView(
ExtendableEntity.Person, SortType.Ascending,
new[] { Column }, Column);
ResultsInfo = new ResultsInfo(resultsView);
}
private void GivenQueryForContactsWithStrengthOf50()
{
var condition =
new DecimalCondition(Column, ComparisonOperation.EqualTo);
condition.DataField.Value = 5;
_query = TypeHelper.GetAdvancedQuery(_entityType);
_listManager.AddListToAdvancedQuery(_query);
_query.MainConditionGroup.AddCondition(condition);
}
private void WhenRunSearch()
{
ISearchService service = TypeHelper.GetSearchService(_entityType);
ISearchResults results = service.GetResults(_query, ResultsInfo);
_resultsData = results.Results;
}
private void ThenShouldContainResultsWithStrengthOf50()
{
Assert.Greater(_resultsData.Rows.Count, 0);
foreach (DataRow row in _resultsData.Rows)
Assert.AreEqual(5, (decimal)row[Column.Name]);
}</pre>
<p>But for me, creating reports of the text descriptions wasn't the main point. The main point was just to better organize the test. When I started writing the code, I thought maybe I'd just skip the text, but then I thought, "Oh well, I might as well do it."
</p><p>
And that was fine, but when the requirements changed, I had trouble keeping the text synchronized with the code.
</p><p>
After I wrote the initial code, the team decided that instead of having strength on a scale from 0-60, we'd have it on a scale from 0.0-6.0. And when I changed the code, I was in a hurry, since that change hadn't been part of the original estimate, and consequently threatened our timeline.
</p><p>
So I ended up with text that said 50 and code that said 5.
</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com5tag:blogger.com,1999:blog-33777038.post-1158936695904983492006-09-22T15:49:00.001+01:002009-12-16T19:08:57.112+00:00What Is The Best Way To Use Immutable Atomic Value Types With XML Serialization?<p>
Here are two items from <a href="http://www.amazon.com/gp/product/0321245660/">Effective C#: 50 Specific Ways to Improve Your C#</a> by <a href="http://www.srtsolutions.com/public/blog/20574">Bill Wagner</a>:
</p><p>
Item 7: Prefer Immutable Atomic Value Types</p>
<blockquote>Immutable types are simple: After they are created, they are constant. If you validate the parameters used to construct the object, you know that it is in a valid state from that point forward. You cannot change the object's internal state to make it invalid. You save yourself a lot of otherwise necessary error checking by disallowing any state changes after an object has been constructed. Immutable types are inherently thread safe: Multiple readers can access the same contents. If the internal state cannot change, there is no chance for different threads to see inconsistent views of the data. Immutable types can be exported from your objects safely. The caller cannot modify the internal state of your objects. Immutable types work better in hash-based collections. The value returned by Object.GetHashCode() must be an instance invariant (see Item 10); that's always true for immutable types.
</p><p>
Not every type can be immutable. If it were, you would need to clone objects to modify any program state. That's why this recommendation is for both atomic and immutable value types. Decompose your types to the structures that naturally form a single entity. An Address type does. An address is a single thing, composed of multiple related fields. A change in one field likely means changes to other fields. A customer type is not an atomic type. A customer type will likely contain many pieces of information: an address, a name, and one or more phone numbers. Any of these independent pieces of information might change. A customer might change phone numbers without moving. A customer might move, yet still keep the same phone number. A customer might change his or her name without moving or changing phone numbers. A customer object is not atomic; it is built from many different immutable types using composition: an address, a name, or a collection of phone number/type pairs. Atomic types are single entities: You would naturally replace the entire contents of an atomic type. The exception would be to change one of its component fields.</blockquote>
<p>Item 25: Prefer Serializable Types</p>
<blockquote>Prefer adding serialization to your types when practical. It should be practical for all types that do not represent UI widgets, windows, or forms. The extra perceived work is no excuse. .NET Serialization support is so simple that you don't have any reasonable excuse not to support it. In many cases, adding the Serializable attribute is enough</blockquote>
<p>But, are immutable atomic value types serializable to XML?
</p><p>
Here is the immutable atomic address structure, pretty much taken straight from Wagner's book:</p>
<pre><code>[<span style="color: teal;">Serializable</span>]
<span style="color: blue;">public</span> <span style="color: blue;">struct</span> <span style="color: teal;">Address</span>
{
<span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> _street;
<span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> _city;
<span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> _state;
<span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> _zip;
<span style="color: blue;">public</span> Address (<span style="color: blue;">string</span> street, <span style="color: blue;">string</span> city, <span style="color: blue;">string</span> state, <span style="color: blue;">string</span> zip)
{
_street = street;
_city = city;
_state = state;
_zip = zip;
}
<span style="color: blue;">public</span> <span style="color: blue;">string</span> Street { <span style="color: blue;">get</span> { <span style="color: blue;">return</span> _street; } }
<span style="color: blue;">public</span> <span style="color: blue;">string</span> City { <span style="color: blue;">get</span> { <span style="color: blue;">return</span> _city; } }
<span style="color: blue;">public</span> <span style="color: blue;">string</span> State { <span style="color: blue;">get</span> { <span style="color: blue;">return</span> _state; } }
<span style="color: blue;">public</span> <span style="color: blue;">string</span> Zip { <span style="color: blue;">get</span> { <span style="color: blue;">return</span> _zip; } }
}</code></pre>
And here is a class that uses it:
<pre><code>[<span style="color: teal;">Serializable</span>]
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: teal;">Office</span>
{
<span style="color: blue;">private</span> <span style="color: blue;">string</span> _name;
<span style="color: blue;">private</span> <span style="color: teal;">Address</span> _address;
<span style="color: blue;">public</span> Office() { }
<span style="color: blue;">public</span> <span style="color: blue;">string</span> Name
{
<span style="color: blue;">get</span> { <span style="color: blue;">return</span> _name; }
<span style="color: blue;">set</span> { _name = <span style="color: blue;">value</span>; }
}
<span style="color: blue;">public</span> <span style="color: teal;">Address</span> Address
{
<span style="color: blue;">get</span> { <span style="color: blue;">return</span> _address; }
<span style="color: blue;">set</span> { _address = <span style="color: blue;">value</span>; }
}
}</code></pre>
Now, here is some code that creates an Office and serializes it to XML:
<pre><code><span style="color: teal;">Office</span> office = <span style="color: blue;">new</span> <span style="color: teal;">Office</span>();
office.Name = <span style="color: maroon;">"Chicago"</span>;
office.Address = <span style="color: blue;">new</span> <span style="color: teal;">Address</span>(<span style="color: maroon;">"1060 W Addison St"</span>, <span style="color: maroon;">"Chicago"</span>, <span style="color: maroon;">"IL"</span>, <span style="color: maroon;">"60613"</span>);
<span style="color: teal;">XmlSerializer</span> s = <span style="color: blue;">new</span> <span style="color: teal;">XmlSerializer</span>(<span style="color: blue;">typeof</span> (<span style="color: teal;">Office</span>), <span style="color: blue;">new</span> <span style="color: teal;">Type</span>[] {<span style="color: blue;">typeof</span> (<span style="color: teal;">Address</span>)});
s.Serialize(<span style="color: teal;">Console</span>.Out, office);</code></pre>
<p>And here's the output:</p>
<pre><Office>
<Name>Chicago</Name>
<Address />
</Office>
</pre></p>
Where's the address information?
</p><p>
MSDN explains in <a href="http://msdn2.microsoft.com/en-us/library/182eeyhh%28VS.80%29.aspx">XML Serialization Considerations</a>:</p>
<blockquote>Only public properties and fields can be serialized. Properties must have public accessors (get and set methods). If you need to serialize non-public data, use the BinaryFormatter class rather than XML serialization.</blockquote>
<p>My Address properties don't have public set methods, and so aren't in the XML.
</p><p>
Now, I <i>like</i> the immutable type idea. It feels good and clean and right to me for things like Address. And <a href="http://martinfowler.com/">Martin Fowler</a> and Eric Evans agree—they both have descriptions of immutable value objects in their books <a href="http://www.amazon.com/dp/0321127420/">Patterns of Enterprise Application Architecture</a> and <a href="http://www.amazon.com/dp/0321125215/">Domain-Driven Design</a>, respectively. So, I really want to use the immutable value type idea. However, I'm going to start using these types over a web service. That means I want a good way to serialize them, where "good" is defined by James Shore in <a href="http://www.jamesshore.com/Articles/Quality-With-a-Name.html">Quality With a Name</a> as</p>
<blockquote>A good software design minimizes the time required to create, modify, and maintain the software while achieving acceptable run-time performance.</blockquote>
<p>And so, the question is: What is the best way to use immutable atomic value types with XML serialization?</p>
programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com5tag:blogger.com,1999:blog-33777038.post-48501680407104381502007-04-01T23:54:00.001+01:002009-12-16T19:06:10.452+00:00Physical World Hyperlinks<p>
You know the feeling when you read about something, and think, "That's cool. I want to be a part of that."?
</p><p>
I just read the <a href="http://www.nytimes.com/2007/04/01/business/01code.html">New York Times article</a> about <a href="http://en.wikipedia.org/wiki/Physical_world_hyperlinks">physical world hyperlinks</a>.
</p><p>
I want it, now. I want to build it, now.
</p><p>
Ooh, and I just found <a href="http://www.semacode.org">semacode.org</a>.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-56715158608764027612007-12-21T19:26:00.001+00:002009-12-16T19:05:32.393+00:00Customers Do So Care What Your Code Looks Like, They Just Don't Know It<p>
Over at <a href="http://www.codinghorror.com/">Coding Horror</a>, Jeff Atwood claims "<a href="http://www.codinghorror.com/blog/archives/001022.html">Users couldn't care less whether the underlying code is pretty</a>."
</p><p>
Baloney.
</p><p>
The article sparked lots of responses noting that customers do care, because ugly code is often hard to maintain, and code that is hard to maintain often leads to more bugs, as well as to longer implementation times both for bug fixes and for the new features that keep you ahead of your competition.
</p><p>
But yes, in a short-sighted way, Jeff is right. Customers often don't <b>appear</b> to care about quality until something bad happens.</p><ul><li>They don't care about the bad quality of cheap toys from China, until they find out they are hazardous to their children's health because the toys contain too much lead.</li>
<li>They are so enamored with the bling of their SUVs that they don't think about quality until news headlines start shouting about rollovers.</li>
<li>And, they don't care about ugly, unmaintainable code until your product has a showstopper bug and it takes you forever to fix it, because you can't figure out how to. Or, until a competitor has a feature that your customers are dying for, but that it takes you forever to match, because you can't figure out how to integrate it into your ugly codebase.</li></ul><p>Whoops! It turns out that customers care about quality after all.
</p><p>
So yes, customers do care, it's just that they are so dazzled by promises of features and the potential for bargains that sometimes they forget—until something bad happens.
</p><p>
As always—and I think this may really be part of Jeff's point anyway—there has to be balance. Take the time to write maintainable, quality code so you don't end up in the "whoops!" situation. But on the other hand, don't stare at your code editor, re-refactoring for hours on end just to write a masterpiece.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-49699116454937486272007-12-30T20:56:00.001+00:002009-12-16T19:04:49.370+00:00Amazon Kindle Phone Customer Support Sucks<p>
My bf bought a Kindle. My opinion is that it's a very nice e-book reader. There are a lot of reviews out there that think it should be prettier or flashier or do more.
</p><p>
But they are wrong. It's an e-book reader. And it does that job very nicely.
</p><p>
As long as it's working.
</p><p>
Our Kindle seems to be having some issues with the battery—just flat-out really bad battery life, even with the wireless off. Some people have speculated this is because the device is draining too much power when the screensaver is on, and that things work better if you turn it off between reading sessions.
</p><p>
Okay, fine. But rather disappointing from a device you just paid $400 for.
</p><p>
Our Kindle has another issue, though, where if you leave it in the screensaver and not plugged into an outlet, it often won't wake up from the screensaver. Getting it back to life involves various resets, battery-poppings, and <b>always</b> needing to get it plugged back into an outlet.
</p><p>
And it's not that the battery is dead. When it wakes back up, it shows the battery as having plenty power left.
</p><p>
This rendered it unusable for the bf to take on his trans-Atlantic flight to see his family for Christmas.
</p><p>
That's not acceptable from a device you just paid $400 for.
</p><p>
The bf contacted customer service by e-mail. They said that from his description, they couldn't tell if the problem was in the Kindle itself, or just in the battery, and he needed to contact them by phone. Fair enough.
</p><p>
When he got back to the States, we did that.
</p><p>
For Kindle customer support, Amazon has a system where you enter your details into their online support site, and then support calls you at the phone number you provide—you can choose immediately, or in a few minutes. We chose immediately, and indeed were immediately called.
</p><p>
Only to be put on hold until a support representative was available to take our call.
</p><p>
I expected this. I understand this is how customer phone support works. You usually have to wait a while. But you know, if your business has a system sophisticated enough to have support call the customer back like that, they could actually make it so that support only calls when they have someone free to handle the call.
</p><p>
It's just a thought.
</p><p>
The bf and I passed the phone back and forth, waiting for a human. (Our speaker-phone died a terrible death a while back.)
</p><p>
Every few minutes, a pre-recorded voice broke through the music, saying the things those pre-recorded voices usually do, including that someone would take our call within a few minutes.
</p><p>
We passed the phone back-and-forth like this, waiting and waiting.
</p><p>
FOR THREE HOURS.
</p><p>
THEN THE SUPPORT SYSTEM HUNG UP ON US.
</p><p>
Furthermore, we are not the only people this has happened to. In the Kindle discussion forums on Amazon, at least one other customer said something similar had happened to them.
</p><p>
Amazon, I know you're a big enough company that you don't care how one customer feels, or even a few.
</p><p>
BUT RIGHT NOW, I'M REALLY PISSED OFF AT YOU.
</p><p>
The bf and I are still deciding if we will try getting through to the Kindle phone customer support again, or just send the thing back. (We're still within our 30-day return window.)
</p><p>
Right now, we're favoring the latter.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com2tag:blogger.com,1999:blog-33777038.post-50244073018106027832008-04-23T20:41:00.002+01:002009-12-16T19:03:32.364+00:00Avoid Resharper 4.0 Nightly Build 775<p>
If you're trying the Resharper 4 beta nightly builds, I just thought I'd warn that I had trouble with build 775 from 11 Apr 2008, which is currently the newest build marked "Works here". When I installed it, the Resharper items, such as "Find Usages", were disabled in the context menu. I found the issue discussed in the Jetbrains forums, and they said they fixed it in a later build.
</p><p>
Now, I'm using build 780 from 18 Apr 2008, and it's working well for me so far.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com1tag:blogger.com,1999:blog-33777038.post-37940499745327810632009-01-09T10:47:00.004+00:002009-12-16T19:02:47.146+00:00Debugging Deadlocks in SQL Server Sucks Less These Days<p>
I'm debugging deadlocks in SQL Server 2005. I hate debugging deadlocks.
</p><p>
The good news is that debugging deadlocks in SQL Server 2005 sucks a lot less than it did in SQL Server 2000.
</p><p>
<a href="http://blogs.msdn.com/bartd/default.aspx">Bart Duncan</a> expresses the difference well:</p>
<blockquote>Turn on trace flag 1222 with "DBCC TRACEON (1222, -1)" or by adding "-T1222" as a SQL startup parameter. This trace flag is a new trace flag in SQL 2005, a much improved version of the tried-and-true -T1204. If you’re running SQL 2005, you should be using 1222 instead of 1204 unless you have deep-seated masochistic tendencies. Alternatives to 1222:<ul><li>If you are using SQL 2000 or SQL 7.0, you’ll have no choice but to fall back on the older -T1204. </li><li>There’s a "Deadlock graph" Profiler trace event that provides the same info as -T1222. Feel free to use this instead of -T1222 if you’re on SQL 2005. But don’t waste your time with the "Lock:Deadlock" and "Lock:Deadlock Chain" trace events that are in SQL 2000, as they provide an unacceptably incomplete picture of the deadlock.</li></ul></blockquote>
<p>Hooray!
</p><p>
That quote is taken from the first part in an excellent three-part series on debugging deadlocks in SQL Server 2005:</p>
<ul><li><a href="http://blogs.msdn.com/bartd/archive/2006/09/09/747119.aspx">Deadlock Troubleshooting, Part 1</a></li><li><a href="http://blogs.msdn.com/bartd/archive/2006/09/13/751343.aspx">Deadlock Troubleshooting, Part 2</a></li><li><a href="http://blogs.msdn.com/bartd/archive/2006/09/25/770928.aspx">Deadlock Troubleshooting, Part 3</a></li></ul>
<p>
Also, there's <a href="http://www.togsblom.com/2008/12/basic-sql-server-deadlock-debugging.html">Basic SQL Server Deadlock Debugging</a> over on <a href="http://www.togsblom.com/">Tog's Blom</a>.
</p><p>
I also like the Troubleshooting Deadlocking section in <a href="http://www.amazon.com/dp/0735621969/">Inside Microsoft SQL Server 2005: Query Tuning and Optimization</a> by Kalen Delaney.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-65224130060729186052009-02-02T10:24:00.005+00:002009-12-16T19:01:43.181+00:00Jeff and Joel Say Quality Really Doesn't Matter That Much. Uncle Bob Disagrees<p><a href="http://www.joelonsoftware.com/">Joel Spolsky</a> has a <a href="http://www.joelonsoftware.com/items/2009/01/31.html">transcript of part of a podcast</a> with <a href="http://www.codinghorror.com/blog/">Jeff Atwood</a> where they say various odd things about software development, including:</p><ul><li>"And I find, sadly, to be completely honest with everybody listening, quality really doesn't matter that much, in the big scheme of things."</li>
<li>Robert C. Martin's SOLID principles sound like "extremely bureaucratic programming that came from the mind of somebody that has not written a lot of code, frankly."</li>
<li>And, "The longer I think about this, the less I care about code hygiene issues."</li></ul><p>Robert C. "Uncle Bob" Martin gives them a much-deserved ass-reaming in <a href="http://blog.objectmentor.com/articles/2009/01/31/quality-doesnt-matter-that-much-jeff-and-joel">his response</a>.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-6774900456834310412009-03-31T11:14:00.006+01:002009-12-16T18:59:15.343+00:00Looking Forward to Alt.Net London Beers Tonight<p>
I'm looking forward to attending <a href="http://serialseb.blogspot.com/2009/03/altnet-london-beers-7.html">Alt.Net London Beers</a> tonight to see what social gaffe I can commit next. My favorite from last time was when someone asked me if I "was you-switch" and I looked at them blankly, wondering what they could possibly mean. In retrospect, I knew that there were several developers there from <a href="http://www.uswitch.com/">uSwitch</a>, and I was just being asked if I was one of them. But at the time, I completely forgot, and the best my mind could turn the question into was something like... "Do you use switch statements? Because you know, in the OO-world, that's not cool." My secret is that I probably have used switch statements in the past year. But I didn't like it. Really.
</p><p>
Seriously, though. It's a good event. I made it to the last two, where we discussed Robert C. "<a href="http://blog.objectmentor.com/articles/category/uncle-bobs-blatherings">Uncle Bob</a>" Martin's <a href="http://blog.objectmentor.com/articles/2009/02/12/getting-a-solid-start">SOLID Principles</a> and "avoiding the big rewrite," including ideas from Michael Feathers' book <a href="http://www.amazon.co.uk/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/">Working Effectively With Legacy Code</a>.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com1tag:blogger.com,1999:blog-33777038.post-9055820258232476742009-04-12T14:21:00.016+01:002009-12-16T18:58:45.680+00:00Egoless Programming: Admitting When You Should Be Shot<p>
<a href="http://www.markhneedham.com">Mark Needham</a> brought up <a href="http://c2.com/cgi/wiki?EgolessProgramming">Egoless Programming</a> <a href="http://twitter.com/markhneedham/status/1495300147">on Twitter</a> the other day, reminding me of one of my favorite times I got to admit "I did this, including the mistakes."
</p><p>
It looks much funnier as an <a href="http://xkcd.com">xkcd</a>-style cartoon than it did in real life:
</p><p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHdJeTlS4_l6GMuuTYNAkKiyye0Qv5zgjEpPg3YQJLUuhuL-gYTecsBhM_cgq0aAzOBEvsTEIiGooAaFZkma-8KF-uKxeCZoLbcr-6cdyL8RLgbQuomkUbT9a9wUCk6J-_dbl/" />
</p><p>
(Disclaimer: All of the drawing above was copied directly from <a href="http://xkcd.com">xkcd</a>, because I can't draw at all. But the words are mine—well, mine and those of the co-worker who wanted to shoot me.)</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0tag:blogger.com,1999:blog-33777038.post-75018754031583667642009-04-15T18:02:00.001+01:002009-12-16T18:58:17.990+00:00Sometimes It's Easier to Stick With What You Already Use<p>
For the upcoming <a href="http://openspacecode.com/uk/london.en.xhtml">London Open Space Coding Day</a>, we're thinking about <a href="http://groups.google.co.uk/group/openspacecode/msg/d25c6f06c4db5dee?hl=en">working with messaging in enterprise applications</a>.
</p><p>
That reminds me of the lesson I learned the last time I tried using MSMQ: Sometimes, it's easier to stick with what you already use.
</p><p>
The scenario was that we were going to import some record updates from an external system. Once we grabbed them from the external web service, we wanted to queue them up and bring them into our system.
</p><p>
"Aha!" I thought. "We need a queue. This is what MSMQ is for. We'll use that."
</p><p>
Unfortunately, this import is a very, very small piece of an application that otherwise is very, very largely database-driven. Ever since implementing the import, every time someone needs to test it, there's baloney about the MSMQ queues not getting set up right or not having permissions or some other junk. And that's ignoring that when we first coded it, we found out that lots of our developers didn't even have MSMQ installed, and they all had to install it.
</p><p>
On the other hand, if we'd set up the queues to be stored in the database, there would have been no problem. In our application, if you can't access the database, you're not going anywhere. In fact, in the next release, another developer needed a queue. He stored it in the database and never had any of the problems I did.
</p><p>
Now, this isn't a story about how you shouldn't use MSMQ. Instead, it's a story about how if your application is largely based on one technology, and to implement a single feature, you have a choice between using that technology and another one—where both will work pretty much equally well—you might want to seriously think about sticking with the one the rest of the application is based on.
</p><p>
On a related note, a few months ago, when I was at the February meeting of the <a href="http://www.dnug.org.uk">London .NET User Group</a>, <a href="http://gojko.net">Gojko Adzic</a> and David de Floriner gave <a href="http://gojko.net/2008/12/02/asynchronous-net-applications-with-nservicebus">a talk</a> on <a href="http://www.nservicebus.com">NServiceBus</a>. It looked like an interesting way I might have been able to interface the message queuing so that I could have swapped out MSMQ with our SQL Server database without needing to change code.</p>programmergrrlhttp://www.blogger.com/profile/08045944515241515020noreply@blogger.com0