<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/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>Hadi Hariri : Architecture</title><link>http://devlicio.us/blogs/hadi_hariri/archive/tags/Architecture/default.aspx</link><description>Tags: Architecture</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>That dreaded M in ASP.NET MVC</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2011/01/02/that-dreaded-m-in-asp-net-mvc.aspx</link><pubDate>Sun, 02 Jan 2011 16:50:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:64347</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=64347</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2011/01/02/that-dreaded-m-in-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;When it comes to working with Models in MVC, I&amp;rsquo;ve tried many approaches, some good, others not so much. I&amp;rsquo;ve ended up settling on ViewModels, whereby the Model I submit is dictated by the View I&amp;rsquo;m working with. This allows me the flexibility of displaying or gathering only the information I need. It also allows me to provide additional information on the view that isn&amp;rsquo;t necessarily required by my domain. &lt;/p&gt;
&lt;p&gt;It works, but it also adds a lot of friction. Be it mapping, be it validation, it&amp;rsquo;s continuously repeating same processes over and over again. Even automating some of this still requires constant set up. Every time I work with ASP.NET MVC, I dread having to deal with all this. Way too much friction. &lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve often wondered whether I&amp;rsquo;m overly complicating myself by trying to add so much flexibility. I mean if the Rails guys can work with ActiveRecord, why can&amp;rsquo;t I? Granted that maybe much of the drawbacks of ActiveRecord can be remedied in some way in Rails because of Ruby being a dynamic language and allowing for things such as Mixins, but still, what about the other stuff? The mapping to an actual domain model. What happens when they need a list of countries? What happens when they have to update only 2 out of 7 fields of their domain model? &lt;/p&gt;
&lt;p&gt;I decided to ask &lt;a href="http://twitter.com/ironshay"&gt;Shay&lt;/a&gt; how he works. As a guy who works with both ASP.NET MVC and Rails, and has written a book on &lt;a href="http://www.amazon.com/IronRuby-Unleashed-Shay-Friedman/dp/0672330784"&gt;IronRuby&lt;/a&gt;, I thought he&amp;rsquo;d be a good candidate. Plus, he&amp;rsquo;s a nice guy. &lt;/p&gt;
&lt;p&gt;I have to say I wasn&amp;rsquo;t really surprised by his answer. He binds directly to his Domain Model in ASP.NET MVC. I asked how he dealt with additional info: Html Helpers. I asked how he solved partial updates: In the controller. Although, not surprising, it was interesting. As a guy that&amp;rsquo;s worked heavily in Rails, he seems to cope fine with this approach in C#. &lt;/p&gt;
&lt;p&gt;So again I wonder, am I focusing on too much flexibility? I decided to ask others by running a quick survey on Twitter asking how people worked with M in MVC. &lt;/p&gt;
&lt;p&gt;1. First the disqualifying question. Are you using Strongly-Typed views?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_194D66C3.png"&gt;&lt;img height="265" width="474" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_77818E31.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;98% voted they are. I&amp;rsquo;m guessing more than 2 people were not, but since the Survey was focused on strongly-typed views, they probably didn&amp;rsquo;t take part.&lt;/p&gt;
&lt;p&gt;2. Now the question to see if I am the odd one out using ViewModels&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_5C68BF23.png"&gt;&lt;img height="265" width="490" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_688A394A.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Apparently not. 78% of people use ViewModels. &lt;/p&gt;
&lt;p&gt;3. The next question was how one deals with only partially updating some fields of a Domain Model if binding directly to them.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_50371F2F.png"&gt;&lt;img height="265" width="354" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_274C0A26.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;4. What about that damn list of countries? &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_33015158.png"&gt;&lt;img height="265" width="384" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_7EECB204.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;(I&amp;rsquo;ve actually found another way to solve this problem, partially based on conventions, and we might even build it in to &lt;a href="http://github.com/hhariri/AutoReST"&gt;AutoReST&lt;/a&gt;. But that&amp;rsquo;s for another post).&lt;/p&gt;
&lt;p&gt;5. Key question the following. Mappings (read friction). If you use ViewModels, do you manually map information or use something like AutoMapper? &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_2E5B20D1.png"&gt;&lt;img height="380" width="367" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_5CF129B3.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Surprised by the number of people doing manual mapping. You would think that if AutoMapper&amp;rsquo;s only responsibility is to do mapping for you, why not use it? Could it be again the same issue? Too much friction to setup? NuGet to the rescue? Too much ceremony? &lt;/p&gt;
&lt;p&gt;6. Here&amp;rsquo;s another one. Validation.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTMLaa90b6d_5F00_4ED23AB6.png"&gt;&lt;img height="527" width="360" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTMLaa90b6d_5F00_thumb_5F00_75046E41.png" alt="SNAGHTMLaa90b6d" border="0" title="SNAGHTMLaa90b6d" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So pretty much everyone (79%), some way or other has to deal with decorating their models with attributes. &lt;/p&gt;
&lt;p&gt;7. Finally, I was curious how people felt in general with the development process. Did they also encounter friction?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_1804B9E5.png"&gt;&lt;img height="265" width="368" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_43D50DD4.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Not surprisingly, 70% find some level of friction in doing web development. &lt;/p&gt;
&lt;h3&gt;Conclusions&lt;/h3&gt;
&lt;p&gt;First off, this is not a stab at ASP.NET MVC. If you take it like that, you&amp;rsquo;re barking up the wrong tree. I&amp;rsquo;m sure in one way or another, any platform or language has a certain level of friction when it comes to developing applications. No, this is more of a self-stabbing. &lt;/p&gt;
&lt;p&gt;I also agree that on the whole, there&amp;rsquo;s too much friction. However, I&amp;rsquo;m not sure how much of that friction is caused by the platform vs the mentality of us developers to think big and try to build in so much unneeded flexibility. Are we really applying YAGNI? Are we really applying KISS? Maybe adding so much flexibility in terms of ViewModels because, and I quote, &amp;ldquo;&lt;em&gt;when dealing with complex scenarios, simple approaches fall apart&amp;rdquo; &lt;/em&gt;only actually solve a 5% edge case that could be remedied in a different way. &lt;/p&gt;
&lt;p&gt;Maybe we should stop being afraid of trying to be too strict and not flexible enough. Maybe we should take the concept of conventions more seriously than just what folders our Views, Controllers and Models reside in. Maybe we should push conventions to the limit and see if we actually reduce this friction. &lt;/p&gt;
&lt;p&gt;And that&amp;rsquo;s the next journey I&amp;rsquo;m going to embark on. It might be time to drop the ViewModel, it might not be. What I do know is that writing good software shouldn&amp;rsquo;t be so complex. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=64347" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Design/default.aspx">Design</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Architecture/default.aspx">Architecture</category></item><item><title>SRP, as easy as 123…</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2010/12/18/srp-as-easy-as-123.aspx</link><pubDate>Sat, 18 Dec 2010 15:55:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:64020</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=64020</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2010/12/18/srp-as-easy-as-123.aspx#comments</comments><description>&lt;p&gt;&amp;hellip;of course, you&amp;rsquo;d need to have the &lt;a href="http://www.youtube.com/watch?v=i9hQIrsHaS4&amp;amp;feature=related"&gt;song ABC from the Jackson Five&lt;/a&gt; in your head for that title to be remotely amusing. &lt;/p&gt;
&lt;p&gt;Single Responsibility Principle is such a simple principle. It states that a class should only have one responsibility. One responsibility. Not two, not three, one. Such a concise and simple definition is hard to get wrong, right? Right? RIGHT??? Hmm&amp;hellip; &lt;/p&gt;
&lt;p&gt;&lt;a&gt;&lt;img height="264" width="460" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/clip_5F00_image001_5F00_4DFA63F8.png" alt="clip_image001" border="0" title="clip_image001" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;A conversation between two friends&lt;/h3&gt;
&lt;p&gt;I&amp;rsquo;m looking at this Customer class, it does a bit too much no? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Huh? What do you mean? It&amp;rsquo;s a Customer Class. It deals with Customers. That&amp;rsquo;s all it does. Not Employees. Customers. I can fetch a customer. I can fetch a lot of customers. I can store a customer. I can calculate their age. I can check if they are VIP customers. Everything there is to do with customers. That&amp;rsquo;s all it does. Isn&amp;rsquo;t that what this Single Responsibility Principle states? To only have one responsibility? &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Well, yes, but I think you&amp;rsquo;ve kind of missed the point on what this whole responsibility thing is . &lt;/p&gt;
&lt;p&gt;&lt;i&gt;How so? It just deals with Customers right? In fact, isn&amp;rsquo;t what I&amp;rsquo;ve just described pretty much the ActiveRecord Pattern? &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Indeed it is. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;So then WTF is the problem?&lt;/i&gt; &lt;i&gt;I don&amp;rsquo;t get it. &lt;/i&gt;&lt;/p&gt;
&lt;h3&gt;Digging deeper&amp;hellip;&lt;/h3&gt;
&lt;p&gt;Hmm, let&amp;rsquo;s look at this class. It reads/writes a customer(s) from/to the database. Therefore it has some code that has to do with reading from a database. It calculates age and verifies if a customer is a VIP. So it must have some business logic code in there. &lt;/p&gt;
&lt;p&gt;What happens when you need to change the persistence logic? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Well I&amp;rsquo;ll change the code. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Which code? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;The Customer class of course. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Right. What happens when you need to change the business logic of how a customer is considered a VIP? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;I&amp;rsquo;ll change it again&amp;hellip;..Sorry. What&amp;rsquo;s your point?&lt;/i&gt; &lt;/p&gt;
&lt;p&gt;So again, you&amp;rsquo;ll touch that class. What happens when Customers need some validation? You&amp;rsquo;ll again have to touch the same class. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;And? &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;What happens when you touch code? You usually end up breaking things. And it&amp;rsquo;s not necessarily &lt;i&gt;that &lt;/i&gt;particular thing you touch. You break other things that at that point you had no clue were somehow related. The more complicated the code, the more chances you have of breaking something. Of course, if on top of everything,&amp;nbsp; you don&amp;rsquo;t even have regression tests&amp;hellip;well I&amp;rsquo;m sure you&amp;rsquo;ve suffered the consequences. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;I kind of think of myself a competent developer. I&amp;rsquo;m sure I can work with enough care to not break things. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Right&amp;hellip;. Now while you go and convince yourself of that, let me explain another problem. You see, writing code is easy. Understanding it is hard. The more code in a class, the harder it will be to decipher. The less code, the easier it will be to comprehend. If a class does many things, it will most likely have what? More code. The less it does, you got it! Less code. Forget logic for a moment. It even has psychological impacts. Open a large class and a small one. Which one will depress you more? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;I have no problem understanding my own code.&amp;nbsp; &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Sure. You&amp;rsquo;re very smart and you&amp;rsquo;ve worked on this code base and you know it well. What about other team members? Hell. Forget others. Why don&amp;rsquo;t you look at code you wrote yourself eight months ago. Do you know what it does? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Well mostly yes. But I guess that&amp;rsquo;s kind of why comments are useful&lt;/i&gt; &lt;/p&gt;
&lt;p&gt;Why do you need comments if your code is clear enough to understand? And you know why your code is hard to understand? Because you&amp;rsquo;re trying to solve too many problems at the same time. Think about it. You&amp;rsquo;re doing Customer listings, storing, reading and some business logic. It might be the case that for this particular example it&amp;rsquo;s not too hard to understand, but that&amp;rsquo;s because both of us have beaten Customer management to death (along with Authentication) so we&amp;rsquo;re experts in it. But imagine being thrown into some code that you have little knowledge of the domain. Is it easier to understand a class if it does one thing or five?&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;i&gt;So what are you proposing? &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s actually very simple. Divide and Conquer. Remember that? Back from our College days? Divide up a problem into smaller problems and solve the smaller issues. Dealing with mini-problems is easier than dealing with mega ones. &lt;/p&gt;
&lt;p&gt;When we take a class and divide it up into smaller classes, it will be easier to deal with it. And dealing can mean both understanding it and modifying it. But if your customer class is doing all that, it&amp;rsquo;s bound to be harder to understand and maintain. That&amp;rsquo;s why it&amp;rsquo;s important to get these responsibilities right. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;I see. But where have I gone wrong then? I kind of thought I understood the Single Responsibility Principle. Going back to my Customer class, how do I define what the responsibility is if it&amp;rsquo;s not &amp;ldquo;dealing with customers&amp;rdquo;?&lt;/i&gt; &lt;/p&gt;
&lt;h3&gt;Getting a grip on responsibilities &lt;/h3&gt;
&lt;p&gt;The main problem in complying with SRP is defining the responsibilities. Where do we draw the line? A few things that have helped me along the way have been&amp;hellip; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Change &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Have you ever heard people say: &lt;/p&gt;
&lt;p align="center"&gt;&lt;i&gt;&amp;ldquo;A class should only have one reason to change&amp;rdquo;&lt;/i&gt; &lt;/p&gt;
&lt;p&gt;when talking about Single Responsibility? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Yes, actually I have.&amp;nbsp; &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Well think about it. If a class changes for more than one reason, it must be because it&amp;rsquo;s doing more than one thing. Going back to your customer class, think how many reasons there is for it to change. If we have to touch the same class for changing different things, the risk of breaking something is higher, which leads to higher costs in maintainability. &lt;/p&gt;
&lt;p&gt;One way therefore of trying to figure out the responsibilities of a class is by asking the question of how many reasons are there for it to change. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Naming &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Naming is a good way to discover the responsibilities of a class. What does your class do? Give it a name describing what it does. Does it use &lt;i&gt;And&lt;/i&gt; or &lt;i&gt;Or&lt;/i&gt;? Is it hard to explain what it does? Do you need to use suffixes like &lt;i&gt;Manager&lt;/i&gt;, &lt;i&gt;Processor &lt;/i&gt;or &lt;i&gt;Admin &lt;/i&gt;because you can&amp;rsquo;t pinpoint the exact word describing what it does? Maybe it&amp;rsquo;s because it does two things that one word can&amp;rsquo;t describe. These are all clues that your class is doing more than one thing. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cohesion&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Take your class. Look at your methods. Do they have parameters or are they using instance fields? If they are using parameters, remove them. Make them instance fields. Do you end up with methods that only use one of the five instances? That most likely is a warning of the low cohesion that exists between that method and your class. Cohesion is a indication of how well related lines of code are, how well related methods are to a class.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;And you use &lt;a href="http://www.jetbrains.com/resharper"&gt;ReSharper&lt;/a&gt; right. Next time ReSharper prompts you if you want to make a method static, it&amp;rsquo;s telling you it does not use instance fields. That&amp;rsquo;s where you need to decide if that method actually belongs in that class. Sometimes it might, many times it might not. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;OK, that&amp;rsquo;s kind of making sense. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Wait though. Many look at Single Responsibility Principle as something that applies only to classes. Wrong. It applies to methods too. The more things your method does, the more lines of code. The more lines of code. The harder to understand. The harder to debug. &lt;/p&gt;
&lt;p&gt;Use the same process to identify responsibilities in methods. How many reasons do I have to change the method? What do I name it? If I can&amp;rsquo;t name it on a single line, bad! If I can&amp;rsquo;t name it without using &lt;i&gt;And/Or &lt;/i&gt;, bad! &lt;/p&gt;
&lt;p&gt;Refactor your methods to smaller ones. Give each smaller method a good name. Make it descriptive. Don&amp;rsquo;t waste time trying to comment your methods and the 20 parameters it takes. If it&amp;rsquo;s well named and has one or two parameters at most, it should be self-describing. Remember, parameters are used to operate on values, not decide what path to take in the method. For that, you create two methods. &lt;/p&gt;
&lt;p&gt;(Beer enters the scene&amp;hellip;) &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Hahahhaha&amp;hellip;&lt;/i&gt; &lt;/p&gt;
&lt;p&gt;What? &lt;/p&gt;
&lt;p&gt;&lt;i&gt;I remember back when I first started using non-locking source control, I was concerned about running into conflicts when merging. I was right. I did run into issues. I bitched at the SCM.&lt;/i&gt; &lt;i&gt;But now that I think of it, the problem wasn&amp;rsquo;t the SCM. It was the way I was working. It was having too much code in the same class. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Yep, and that would lead to contention since many people would need to touch the same code. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Yep. I was fighting the wrong problem. Damn, it seems such a simple principle, but hard to get right then&amp;hellip;.&lt;/i&gt; &lt;/p&gt;
&lt;p&gt;Yes. It&amp;rsquo;s about asking the right questions. Single Responsibility Principle is about making code maintainable and understandable. That&amp;rsquo;s all there is to it really. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Right. Well dude, I guess it&amp;rsquo;s time for me to Refactor out that Class. &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Yep. Oh and do yourself a favor. If you&amp;rsquo;ve not read the book &lt;a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882"&gt;Clean Code&lt;/a&gt; by Robert C. Martin (@unclebobmartin), get it. It teaches you much of what we&amp;rsquo;ve been talking about. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Cool! &lt;/i&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=64020" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Design/default.aspx">Design</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Architecture/default.aspx">Architecture</category></item><item><title>Technological shortcomings driving business needs</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2010/02/15/technological-shortcomings-driving-business-needs.aspx</link><pubDate>Mon, 15 Feb 2010 13:41:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:55405</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=55405</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2010/02/15/technological-shortcomings-driving-business-needs.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Recent conversation I had with someone the other day:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Jack&lt;/b&gt;: Yes, but we can&amp;rsquo;t do it like that. The business does not work that way.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Me&lt;/b&gt;: Why does it not work that way? &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Jack&lt;/b&gt;: It&amp;rsquo;s a fundamental aspect of the business. We can&amp;rsquo;t change that.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Me&lt;/b&gt;: And I accept that, but have you thought about why it is like that? &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Jack&lt;/b&gt;: Well because it&amp;rsquo;s not viable. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Me&lt;/b&gt;: Why is it not viable ?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Jack&lt;/b&gt;: It would cause too much havoc. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Me&lt;/b&gt;: Why would it cause too much havoc?&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Jack&lt;/b&gt;: Well because the software doesn&amp;rsquo;t allow it. &lt;/p&gt;
&lt;p&gt;Reading this script, one would think that it is quite absurd, yet this situation is quite common. &lt;/p&gt;
&lt;h3&gt;Updating a legacy system&lt;/h3&gt;
&lt;p&gt;Jack in this case was a developer, that is working on re-designing an existing system. But Jack could be anyone. In fact, many times, Jack is a user of the system. &lt;/p&gt;
&lt;p&gt;Users are many times accustomed to having software impose the way they do their job. They have to accommodate their process to that of the way the software they are using functions. What then happens is that they become used to this way of working to the point that they actually change their process, to work with the system, many times attempting to make their own life easier. &lt;/p&gt;
&lt;p&gt;The problem is of course that these changes have an impact on the business. At times this influences productivity, at other times revenue, or even how dealing with customers is handled, ultimately jeopardizing the business or its potential.&lt;/p&gt;
&lt;p&gt;When the time comes to develop a new system, what was considered an impediment has now become a fundamental pillar of how the business should work. As such, the user no longer thinks of how he/she would ideally want to do his/her job and have the software adapt to that, but lets his/her requirements be driven by technology. &lt;/p&gt;
&lt;p&gt;Of course, all this become even more vicious when new users join the scene. They are not aware of the real reasons behind certain workings and assume that that is how it is meant to be, no questions asked. &lt;/p&gt;
&lt;h3&gt;Focus on the customer, not the software&lt;/h3&gt;
&lt;p&gt;It is very important for us to analyze the true needs of our users, to make them look beyond existing systems and offer them the possibility of describing how &lt;i&gt;they&lt;/i&gt; would want to work if they had a blank sheet of paper and could start from scratch. If we have the opportunity to re-design an existing system, let&amp;rsquo;s make sure we base it on the users needs, not the existing software. &lt;/p&gt;
&lt;p&gt;Upgrading existing systems is not about making them use the latest, greatest and most shiny technology. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55405" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Design/default.aspx">Design</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Architecture/default.aspx">Architecture</category></item></channel></rss>