<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.lostechies.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ray Houston - All Comments</title><link>http://www.lostechies.com/blogs/rhouston/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>NotImplementedException and the Interface Segregation Principle</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/03/14/ptom-the-interface-segregation-principle.aspx#5385</link><pubDate>Sun, 12 Oct 2008 19:51:02 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5385</guid><dc:creator>Jimmy Bogard</dc:creator><description>&lt;p&gt;This week, Derrick Bailey will be in town (Austin) to talk about the SOLID principles .&amp;amp;#160; One of&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5385" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5292</link><pubDate>Mon, 06 Oct 2008 21:54:45 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5292</guid><dc:creator>Gabriele Lana</dc:creator><description>&lt;p&gt;I agree with you, but in the example above IMHO the SRP should be applied&lt;/p&gt;
&lt;p&gt;We can split the method in three distinct sections with three distinct purposes&lt;/p&gt;
&lt;p&gt;public bool Login(string username, string password) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;// find the user object&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;var user = userRepo.GetUserByUsername(username);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if(user == null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return false;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;// validate the user login&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (loginValidator.IsValid(user, password))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;// apply the login failures's business logic&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;user.FailedLoginAttempts++;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (user.FailedLoginAttempts &amp;gt;= 3)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;user.LockedOut = true;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return false;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;The user object can be passed as an argument (so that the Login method can be more easely tested without mock/stub), the caller can retrieve the user object from the repo, and the repo can return a NotFoundUser (null object pattern) which should fail all the login validation &lt;/p&gt;
&lt;p&gt;The last section smells like &amp;quot;Feature Envy&amp;quot;, maybe the 'user' should deal with the login failures's business logic&lt;/p&gt;
&lt;p&gt;public bool Login(User user, string password) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (loginValidator.IsValid(user, password)) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;user.FailedLogin();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return false;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Last steps:&lt;/p&gt;
&lt;p&gt;- We can/should inline loginValidator.isValid or move it to this class&lt;/p&gt;
&lt;p&gt;- 'Login' seems to me more a 'do' method then a 'query' method&lt;/p&gt;
&lt;p&gt;In the end, something like this&lt;/p&gt;
&lt;p&gt;public void Login(User user, string password) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (IsNotTheUserPassword(user, password)) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;user.FailedLogin();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throw new LoginFailedException(user, password);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Sorry for my bad english&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5292" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5289</link><pubDate>Mon, 06 Oct 2008 19:35:47 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5289</guid><dc:creator>Jan Van Ryswyck</dc:creator><description>&lt;p&gt;I'd thought I's take this for a spin:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://elegantcode.com/2008/10/06/refactoring-exercise-the-single-responsibility-principle-vs-needless-complexity/"&gt;elegantcode.com/.../refactoring-exercise-the-single-responsibility-principle-vs-needless-complexity&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let me know what you guys think.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5289" width="1" height="1"&gt;</description></item><item><title>Elegant Code &amp;raquo; Refactoring Exercise: The Single Responsibility Principle vs Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5288</link><pubDate>Mon, 06 Oct 2008 19:33:31 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5288</guid><dc:creator>Elegant Code » Refactoring Exercise: The Single Responsibility Principle vs Needless Complexity</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Elegant Code &amp;amp;raquo; Refactoring Exercise: The Single Responsibility Principle vs Needless Complexity&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5288" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5278</link><pubDate>Mon, 06 Oct 2008 12:42:44 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5278</guid><dc:creator>Ryan</dc:creator><description>&lt;p&gt;Funny, I was having a very similar conversation with a co-worker late last week. &amp;nbsp;Mike is an extremely smart developer and adheres to SOLID practices without having to think about it. &amp;nbsp;He was very proud of a solution to a particularly nasty problem we've had recently, but when he presented his solution to the more junior developers on the team, it was met with a deafening silence. &amp;nbsp;While his solution was EXTREMELY flexible, the junior guys just didn't get it due to it's complexity. &amp;nbsp;There were simply too many relationships for the young guys to follow and they quickly became frustrated. &amp;nbsp;What we had was a deer in the headlights scenario.&lt;/p&gt;
&lt;p&gt;Now, we're working on bringing everyone's knowledge of good OO design up a notch or two, but it's going to take time. &amp;nbsp;For now, we know for certain that some parts of our application are going to change, so Mike and I worked for a while to come up with a good solution that just applied to those parts of the app. &amp;nbsp;We cut the object diagram down by about 80% and STILL had a flexible solution that solved all the problems that we knew (or suspected) would change. &amp;nbsp;When we went back to the developers, they were MUCH more receptive.&lt;/p&gt;
&lt;p&gt;What gets me is that Mike knows better. &amp;nbsp;We've been doing a great job with agile practices for about six months now, and Mike knows (or should know) not to design his application for some far off, grandiose idea of what could be a year or two down the road. &amp;nbsp;Chances are that 95% of the flexibility provided by the initial design would never be needed.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5278" width="1" height="1"&gt;</description></item><item><title>Dew Drop - October 6, 2008 | Alvin Ashcraft's Morning Dew</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5276</link><pubDate>Mon, 06 Oct 2008 12:31:49 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5276</guid><dc:creator>Dew Drop - October 6, 2008 | Alvin Ashcraft's Morning Dew</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Dew Drop - October 6, 2008 | Alvin Ashcraft's Morning Dew&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5276" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5273</link><pubDate>Mon, 06 Oct 2008 07:11:44 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5273</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Yeah - what sean said&lt;/p&gt;
&lt;p&gt;There is a quote along the lines of &amp;quot;being made a fool of the first time is OK&amp;quot; subsequent time not so&lt;/p&gt;
&lt;p&gt;i.e. wait until a scenario occurs that suggests you need to add in some extra flexibility rather than assume it needs it upfront&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5273" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5270</link><pubDate>Mon, 06 Oct 2008 03:55:17 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5270</guid><dc:creator>Sean Scally</dc:creator><description>&lt;p&gt;Good points made there.&lt;/p&gt;
&lt;p&gt;Actually, Uncle Bob's PPP book discusses this very topic in greater detail in the Agile Design / OCP chapters, i believe, under the topic of &amp;quot;taking the first bullet&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://anydiem.com/2008/10/05/needless-complexity-and-taking-the-first-bullet/"&gt;anydiem.com/.../needless-complexity-and-taking-the-first-bullet&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5270" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5267</link><pubDate>Mon, 06 Oct 2008 01:25:28 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5267</guid><dc:creator>Ray Houston</dc:creator><description>&lt;p&gt;@chad - yeah, I agree. The point I'm trying to make here is not to abstract just to be abstract. If you do, you'll have a lot of complexity that just ends up being waste. I've been down that road a time or two.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5267" width="1" height="1"&gt;</description></item><item><title>re: Single-Responsibility Versus Needless Complexity</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/10/05/single-responsibility-versus-needless-complexity.aspx#5266</link><pubDate>Mon, 06 Oct 2008 00:14:33 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5266</guid><dc:creator>chadmyers</dc:creator><description>&lt;p&gt;Whomever asked about SRP had good instincts, though. That code does stick out like a sore thumb.&lt;/p&gt;
&lt;p&gt;I'd say the second any change came up that involved any more complexity in how failed login attempts are calculated or reset, refactor that into a separate class somehow.&lt;/p&gt;
&lt;p&gt;Also, the hard-coded '3' might need to become configurable -- also an excuse to refactor this part.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5266" width="1" height="1"&gt;</description></item><item><title>re: How Mr. Buford got me started in software development</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/09/20/how-mr-buford-got-me-started-in-software-development.aspx#5150</link><pubDate>Wed, 24 Sep 2008 20:55:26 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5150</guid><dc:creator>Kevin Miller</dc:creator><description>&lt;p&gt;Great story Ray thanks for sharing this and thank you to all the Mr. Bufords of the world that work hard, get paid little and inspire the little Ray Houstons of the world.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5150" width="1" height="1"&gt;</description></item><item><title>Arjan`s World    &amp;raquo; LINKBLOG for September 24, 2008</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/09/23/learning-tdd.aspx#5149</link><pubDate>Wed, 24 Sep 2008 20:18:59 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5149</guid><dc:creator>Arjan`s World    » LINKBLOG for September 24, 2008</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Arjan`s World &amp;nbsp; &amp;nbsp;&amp;amp;raquo; LINKBLOG for September 24, 2008&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5149" width="1" height="1"&gt;</description></item><item><title>re: Learning TDD</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/09/23/learning-tdd.aspx#5148</link><pubDate>Wed, 24 Sep 2008 17:37:07 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5148</guid><dc:creator>Ray Houston</dc:creator><description>&lt;p&gt;@Robb - thanks for the kind praise. When you say &amp;quot;your blog&amp;quot; I'm sure you mean the whole LosTechies blog and not just mine. Either that or you have me confused with somebody else. ;)&lt;/p&gt;
&lt;p&gt;@Duncan &amp;amp; @Robb - I know that several of us are going to attempt to record &amp;quot;something&amp;quot;. I can't make any promises to what we'll get and the quality, but we're going to make an effort. I'll have to check out Ustream.tv too.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5148" width="1" height="1"&gt;</description></item><item><title>re: Learning TDD</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/09/23/learning-tdd.aspx#5147</link><pubDate>Wed, 24 Sep 2008 17:25:57 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5147</guid><dc:creator>Ray Houston</dc:creator><description>&lt;p&gt;@c - We have other types of tests that verify the application from end to end (integration tests) which do hit the database, but for our unit tests, they do not hit the DB.&lt;/p&gt;
&lt;p&gt;When I mentioned state based testing, what that means is that I'm verifying that the properties of my object under test are what they're expected to be after a specified operation. Interaction based testing means that I'm verifying that my object under test is calling methods and properties on its dependencies correctly. The interaction based testing makes it tough when I want to refactor the way I implemented something without changing its functionality.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5147" width="1" height="1"&gt;</description></item><item><title>re: Learning TDD</title><link>http://www.lostechies.com/blogs/rhouston/archive/2008/09/23/learning-tdd.aspx#5146</link><pubDate>Wed, 24 Sep 2008 16:49:46 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:5146</guid><dc:creator>Robb Schiefer</dc:creator><description>&lt;p&gt;I would love to come too, but work and family aren't flexible enough for me to take a road trip from Birmingham, AL. &amp;nbsp;Granted I'm in the same country (sorry Duncan), but I might as well be across the world.&lt;/p&gt;
&lt;p&gt;I really enjoy your blog and know the event would be hugely helpful to me as well. &amp;nbsp;If you have decided not to video the event yourself, how about Ustream.tv? &amp;nbsp;They will broadcast your event live and I believe archive it to watch later. &amp;nbsp;All for free. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Most new laptops come with webcams and mics in them. &amp;nbsp;All you would have to do is setup one of these laptops in each of the presentation rooms. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;lt;GuiltTrip&amp;gt;Your blog has become an international information souce for developers. &amp;nbsp;We can't all live in the greater Austin area. &amp;nbsp;You owe it to your readers to make this attempt.&amp;lt;/GuildTrip&amp;gt;&lt;/p&gt;
&lt;p&gt;Regardless, thanks for all your content.&lt;/p&gt;
&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=5146" width="1" height="1"&gt;</description></item></channel></rss>