Tabs or Spaces, the age old debate that will likely never be settled! Fortunately, at the end of the day consistent formatting is more valuable than the rules we follow because consistency significantly improves readability and maintainability.
It's difficult in software development to shift the focus to problems and goals instead of features, features, features. As I've written about before, it's ideal to focus on the value first, and match the features to the value.
Sometimes we encounter feature requests that seem reasonable enough that we don't feel the need to back track to discover the value. This happens for many reasons:
However, I've been surprised how many times:
Just this week I encountered a request that upon further inspection was prompted by a subset of the problems in a past project. Subconciously, I almost implemented the feature with the full set of problems in mind from the past. By inquiring about situations that prompted the request, we were able to create a solution that was a subset of the past solution! This reduced the time and money necessary to deliver value to the customer.
TLDR: Even if a feature seems reasonable, ask about the situations that prompted it. I've often been pleasantly surprised :)
Next week I'm going to pair with Sean Massa to talk about Code Reviews in Node. In lieu of this I thought maybe I should write down some of the things I look for in a code review. My perspective on this topic is definitely not unique, but after years of doing these I think I have some ideas about what works and especially what doesn't! My first inclination was to dive in and organize anything that comes to mind into tips or patterns. Before I do that though, first I wanted to ask myself: "Why do code reviews?"
Certainly there are derivative reasons, but I find myself coming back to these two:
I'm sure there are other possible reasons, but this should be enough to get started. To avoid duplication, I found these fantastic posts that justify why these are important:
Misunderstandings and miscommunication are a leading cause of problems in software development. Especially with the prevalence of the mediating involvement anti-pattern. Writing code is a translation of the original idea and as with any translation, runs the risk of "lost in translation."
If you're a part of the team, revisit the topic to make sure you validate your assumptions. If you're not part of the team, invest some time in understanding the purpose before doing too much code review.
Once you know the requirements, watch for discrepancies.
Once we know what it should do, we can investigate how the author verified it.
Does our testing give everyone on the team, non technical people included, confidence that we are done? If not, how could it? Where would this be most beneficial?
The tests should be reviewed like any other code!
If the code is difficult to understand now, imagine how difficult it will be in a few months when anyone, the author included, is re-visiting it.
Here are some simple refactorings that can be done:
Complexity happens naturally, simplicity takes work and creativity. A second opinion can easily identify simpler alternatives.
There's only so much time in the day. What little time you have for code reviews, make sure it's well spent. This requires prioritizing what you review. As I've said before, ask "Does it really matter?". Focus on complexity, the business domain, challenging problems etc. Don't worry about administrative CRUD interfaces. Focus on areas you routinely have problems. Focus on what keeps you up at night!
Keep track of common problems, instead of relying on the review to fix them, focus instead on using reviews to identify them. Then, work as a team to address the problems. Some examples:
Using code reviews to catch repetitive issues is going to be a problem when the code review misses it or fails to happen.
One overlooked area of feedback is the commit log. Look for problems like
This normally happens as a consequence of doing code reviews. However, if we are cognizant of it we can maximize the benefits and actually avoid doing things that can inhibit learning.
Do the code review with the author involved, there's no faster way to learn than having both people sit down together. Obviously this can't always happen, but for significant functionality it's probably a wise idea.
There's a trade off between wasted time reviewing and not enough, there's no guarantee every piece of code will be reviewed. Instead of relying on a review to catch mistakes, try to minimize the mistakes that you think are likely so the review instead focuses on highly valuable topics like simplicity, readability, verification and other areas where you can learn from others. Do the very best work you are capable of so you can learn new ideas from the reviews.
Code reviews should be a process of feedback and discussion. Obviously there are times when you're refactoring and you just have to do it yourself. If you are intentionally doing a code review, try to involve the author in the changes.
In my experience, when I make the changes myself and ask the person to review them, I see more repeat behavior of the same problems, not a reduction. As a reviewer, be very cognizant of this risk.
The longer you wait, the more likely things that are important to discuss will be forgotten and the more likely the code will be in production causing problems anyways. Quick feedback is always beneficial. The longer you wait, the less beneficial a code review will be.
Pair programming is like the best form of code review, it happens instantaneously. Of course, make sure you use this judiciously. For example, there's probably no reason to use it on an administrative CRUD interface.
When people repeatedly make negligent changes and just don't care about the quality of the code, the code review won't help. I've made the mistake of trying to cleanup after this behavior and it never helps.
There's no way code reviews will solve this problem, they can only identify when it may be happening. Don't try to be the hero that always reviews this person's code, you will be very unhappy. Perhaps do some pair programming with the person to see if it's negligent or accidental, and then deal with it outside the code review process.
Unless you are dealing with someone who doesn't give a ..., assume the person does until proven otherwise. This will lead to a much more productive learning experience.
Sometimes you see something you don't understand, instead of inferring it's not necessary or was a "bad decision." Ask why it's there.
We all take pride in what we do, keep it constructive. Likewise, if someone is coming across offensively, point it out politely. It's tempting when you get repeat behavior or rudimentary problems to become frustrated, but remember these can be a sign of a problem in the process, it's often a sign that people are rushed. Sometimes code reviews cannot fix the underlying problem.
At the end of the day, a code review is an opportunity for feedback. We do them to improve quality and to learn. The specific techniques will be subjective but keep the end goal in mind. Leverage techniques of testing, refactoring, automation, design and every other aspect of software development in the process.
It's very common to hear from customers, "What will it cost to build X?" Naturally, I want to understand what X will accomplish. I consider this process understanding the value Y, the desired outcomes. Sometimes customers just demand a cost, but for those that are patient in analyzing the value these are the benefits they will reap:
My expertise is custom software development. If I don't know about Y I can't leverage my expertise to propose and build optimal solutions to achieve Y. I also don't have the opportunity to point out deficiencies in X. Imagine someone telling their doctor what medication to prescribe.
If you ask for results, you will likely get them. If you ask for features, there's no guarantee of results.
If I don't understand Y, when X doesn't accomplish it we'll have to try something else. You would be surprised, but when this happens I usually get requests for changes and new features, again with no guarantee of achieving Y. This has happened on every project I've worked on when Y wasn't discussed. Not only does this waste my time, it wastes yours. We are both stuck with the conundrum of who should pay for this wasted time.
Software development is an involved process, it's not just my time. Success requires your involvement in planning, implementation, user feedback, stakeholder feedback, testing, training and many other aspects. It's easy to overlook/underestimate this time commitment. Either way we both lose if we build failed solutions.
If we reduce wasted time, you will get results faster.
Less wasted time means less cost. Identifying and steering clear of low value projects means more of your money can go to high value projects.
Complexity in software happens naturally, simplicity takes expertise. Simplicity brings a whole host of benefits. If the focus is on features, features (complexity) will be maximized.
If the focus is on value, then value will be maximized! Low value features will take a back seat to higher value features.
In my experience, maintenance cost is exponentially proportional to features. Minimal features means minimal maintenance.
If your business needs to make deliveries you could buy a Lamborghini. However, the cost to maintain it will be much higher than many other equally viable choices.
The more features the more difficult it will be to introduce and/or change features in the future. For every feature we must be careful not to "break" it with any updates. Naturally, if we don't minimize features, over time it will become very difficult to introduce change. Ironically, I find the features most likely to get in the way are the ones that aren't even used!
Do you want to pay to maintain features you don't use?
If I know Y, when your business changes I can make recommendations about which Xs can be removed. If not, in my experience, they never get removed.
Here's a great post on why less code is better.
The more features, the harder it is for users to learn to use your software. Keeping things simple for users means less training. Training cost is proportional, probably exponentially so, to features.
If we both know the desired outcomes we can devise simple methods to monitor the effectiveness of the resulting features at achieving the outcomes. When features prove ineffective we can alter/remove them and try other strategies.
If we discuss value we can compare it to cost and make sure we're both making a wise investment decision. Without this analysis it's very easy to propose features that can lead to a marginal or negative ROI. In business it takes extreme discipline to make an investment decision. All too often I see everyone wrapped up in features and value takes a back seat. If we make this our focus, it's less likely to happen and you are more likely to see a significant ROI.
This analysis will naturally take longer the first few times it's done. Over time everyone will become more effective and efficient and the time will be significantly reduced. The capacity to make wise investment decisions in software will be magnified!
There's ample opportunity for any company to invest in high value projects. Low value work competes for limited resources to develop high value projects. Low value work is unlikely to make you happy, at least not compared to high value work. If you demonstrate an interest in maximizing value, it means we're much more likely to have a successful business relationship and we're both much more likely to prosper. Because of this I provide this analysis process for free. When we're done you will still make the decision if we move forward. That means before I charge a penny you will already be guaranteed to get something of value!
When discussing value we're likely to stumble upon roles that usually aren't involved until much later, if at all. These roles often provide perspectives that can avoid sub optimal solutions before we even start. One of these roles is the buyer, the person who sets the final expectations of outcomes. Imagine how difficult it is to achieve an expectation for someone you've never met! Also, users of the resulting software are often left out. For example, if we're trying to save time or expand capacity, doesn't it seem like a good idea to involve the person that does the work now?
It's very easy to identify missing roles when we discuss value and run into questions that can't be answered.
All of these benefits can be had by simply investing in an analysis of value. Once you get good at this it's often only a few hours investment per project. Is it worth the risk to skip this step?
I stumbled upon this article this morning: Why your users hate Agile development (and what you can do about it).
The article is a great starting point for at least a dozen conversations. Here are some of my ideas to mitigate the risks the article introduced:
This is pretty common in a software development project:
We want BizTalk, .net, ruby, Nodejs, SQL Server, Sharepoint, Oracle...
This is pretty common too:
We want a table of customers. We want an export of invoices. We want a list of orders. We want the ability to apply discounts. We want a report of inventory.
This is very rare:
We want to provide more value to our customers. We want more customers and to do that we may need to increase the frequency of doing X. We want to increase customer satisfaction. We want happier employees. We want to expand Y and to do that we may need to automate Z.
When I hear this, I know I can make a difference.
This is my opinion:
Deliverables (ie: features, technologies, software) should be a means to an end.
If you want to maximize business value, the end should be a business objective. If you want to maximize features, technologies and software then let those be your ends.
I'd prefer to minimize features, technologies and software. They aren't cheap to maintain!
In February I decided to set aside full time development to take an academic journey with some new ideas in software development. It's been a few months and I've consumed some amazing content. Learning is only half of the equation, now I'm thirsty for some feedback! I've decided to pursue two new ventures: value based consulting and developer coaching.
I'm very interested in what happens when value is more central to the development process. In the past I've worked with very talented people to create highly valuable solutions. But the value was often dependent on the customer asking for the right features. At times we would build amazing support for a requested feature only to find lack luster usage. See my article on why I think this happens: Why objectives and value are important in software development.
I believe the conversation has to shift to diagnosing value first, then prescribing solutions. The first step I will make is to incorporate the ideas of value based pricing. To hold myself accountable to delivering value, not just software. That of course is easier said than done. It will require time to learn and re-engineer the processes I use as a developer. I'm very excited about the possibilities!
In addition to my passion for innovating in software development, I have a desire to share what I do with others. I want to transform my experiences developing, speaking and training into coaching opportunities. Coaching encompasses a more objective approach to helping a team achieve results. It will be tailored to the goals of each development team and the software they are building.
To start this process I've partnered with JetBrains to offer my experience with several of their products, especially ReSharper. I look forward to partnering with other companies and offering coaching for a variety of topics.
I've started Full City Tech Co. to bring these ideas to life. Everyone knows I'm a coffee aficionado. Full City is a stage in the roasting process when the beans enter the medium to dark range, in my opinion when the coffee starts to taste good! Likewise, the practices I'm investing in are really rounding out my expertise as a consultant.
I want to thank everyone I've worked with at Phoenix Web Group, School District 145, friends and family who have helped me grow and supported me in everything I've done. I look forward to what I can learn and what I can share in return!
In my last article “Why objectives and value are important in software development” I gave examples to show that it's important to diagnose before prescribing technical solutions. But what does this entail?
Diagnosis can be as simple as asking "why". When someone presents what, ask why. Sometimes the response is more of a what, in which case you may have to dig deeper, keep asking why! This can be like peeling the layers of an onion. At some point you find the center, the core objective.
Businesses exist to create value. Objectives are guiding principles to create value. For example, most businesses value profit. One objective to create profit may be to expand the customer base. Value is often intangible, for example employee morale. An objective to increase employee morale may be to pursue equitable workload distribution. Objectives are a means to the value (end). Value and objectives are numerous, focusing on them will hone the skills necessary to identify and create value, another reason to ask why.
Eventually after peeling back enough layers, you will arrive at a rather fundamental objective.
Let's say someone asks, "Can we generate a PDF of X every night and email it to Y?" Follow up with "Absolutely, but first can we talk about what this will accomplish?" If other people are affected by or invested in the request, involve them too. Make sure to involve the person that will write the check. A typical response might be "Right now John creates this by hand and it consumes a significant amount of time." So we've identified a possible objective, saving time. Again, objectives are a means to an end, in this case it's probably about money.
Objectives often create more than one type of value. Now that you have an understanding of the objective, use it to ask further questions to assess related value. Go grab John and include him too! These are some things you may consider:
Involve everyone in this exploration and expand upon what value is desired, quantifying and qualifying it as you go.
With a shared understanding of value, everyone can brainstorm investments in software or otherwise. These options can be analyzed to quantify the level of value they may create and the potential cost. Neither the value nor the cost can be quantified exactly in advance, that's the nature of making investments and taking risk. However, an estimate of a solution without determining if it will create value puts everyone in a much riskier situation. Assessing the value reduces risk.
With enough practice, this approach will hone your ability to make successful investments. Who wouldn't want that?
Also, I'd recommend throwing out any notion of the original request and working from the value to identify solutions. Sadly, the original request is going to bias your thinking, just try not to let it narrow your vision. There are many ways to accomplish an objective and to create value. Keep an open mind to maximize the value.
With clearly identified value, the team can find ways to measure how much value is created. In the example above, find a way to measure how much time is saved, count historical mistakes, ask John how we can measure the time or if he already measures it. Measure historically if possible, starting now and going forward. Monitor how things improve (or not). Keep these metrics simple and estimate what it will cost to measure them. Make sure it's worth the investment to measure. A few good measures can help the team improve future value analysis: maybe the value was less than expected, maybe it was more, maybe there was unidentified value.
If you don't do this analysis, how can you compare one business investment to another? Some investments are more lucrative than others. Who wouldn't want to tackle the most lucrative of investments first? If you have several pending investments and you've done a value analysis of all of them, you can easily prioritize based on the value!
Since we have a more accurate measure of value and cost, we can prioritize based on ROI. Think about this: if the people who will make the investment have determined that the value they think is possible is low relative to the cost or potentially a negative ROI, why would you make that investment? Likewise, if they have identified a high ROI investment, why wouldn't that be at the top of the list of priorities?
Though asking why can help you start this process, it's best to start with objectives first. Goals and problems are plentiful, encourage people to track them and bring them to the team as objectives and not as requests. This will eliminate the bias in a particular solution and will eliminate the need to backtrack to the objective.
When doing business, we should assess objectives first, thoroughly ask why, and determine what value we hope to create. Identifying technical solutions should come after, along with an assessment of their value and cost. Successful software development is about creating value, not software.
Developers get these requests all the time:
All of these request have a common form, a want/need for a specific technical solution.
Developers will typically reply absolutely, I'll get started right away! The developer will expend considerable time to fulfill the request. Upon completion, or perhaps earlier if a developer practices iterative releases, the customer realizes what they asked for won't meet their objective. It won't solve their problem or achieve their goal.
Naturally, the customer makes subsequent requests to tweak or replace the original request. Eventually they may arrive at a solution that meets their objective. They may also run out of time and/or money. If they are paying by the hour, the cost keeps rising. If they have a fixed bid, the developer is suffering and/or disputing the changes. Either way someone isn't happy, and that's no fun!
The above scenario would be akin to being sick and choosing your own medication before going to see your doctor. Then, going to the doctor and saying "I need an antibiotic, can you give me that?" The doctor would administer the drug. Several days later you're still sick, so you go back and ask for a different medication. This repeats until you get better, but maybe you end up dead!
Or, say your hot water stops working in your bathtub. You call a plumber and inquire "I need my water heater replaced, can you do that?" They replace it and that night you still have no hot water. You call them out again and have them replace the faucet in the bathtub. That night, still no hot water!
Maybe these things happen at times, but it's not the norm.
Patients rarely will ask a doctor for a particular prescription to their ailment, and even if they do, the doctor will step back and discuss symptoms first. Same thing with a good plumber, they'll ask you why you need your water heater replaced. Either way, the professional is diagnosing the problem before prescribing a solution.
If diagnosis comes first in software development the developer can bring a variety of viable solutions to the table. Discussing objectives first can save a lot of time and money.
There are plenty of reasons, chief of which is we all like to be problem solvers. Most of us will try to diagnose our medical and plumbing problems too, we just defer to the doctor/plumber to make the final call.
I think developers encourage this too, we're avid problem solvers and we love a new challenge. Instead of listening first, we prescribe.
Sometimes solutions are repetitive, so naturally customers see patterns and offer suggestions.
Sometimes in the middle of a development effort, a suggested feature seems simple, and it may be, so why not add it?
It also happens when customers are charged by the hour. Instead of paying the developer to diagnose the problem, they can do it themselves and "save money."
No matter what the cause, it's clearly beneficial for developers to practice listening to the customer's objectives first. Developers should thoroughly understand the objectives before prescribing solutions. Customers need to participate by describing their objectives until everyone understands. Once the diagnosis is complete, then everyone can feel free to suggest ideas, but I would recommend deferring to the developer, they are supposed to be the expert after all.
ReSharper is an absolutely fantastic complement to the Visual Studio development experience that provides immense value. It's a requisite in my day to day work with Visual Studio. In many ways ReSharper features form the basis for the criteria I use when evaluating a development environment for any platform.
Many bugs can be avoided with good automated testing up front. Testing also helps prevent recurrence of bugs. One barrier to testing is the wide variety of tools and the lack of integration with development environments. This barrier decreases the dividends testing can provide and justifiably in some cases costs more than it is worth, or at least mentally seems to.
If I have a bug in existing code, features like Stack Trace Explorer make it easy to track down and identify the issue.
Lowering the barrier to testing makes automated testing more economical versus manual verification. At the end of the day I can work faster and the resulting product is more reliable. In my opinion, this testing integration alone covers the cost of the license. I save at least 2 hours a week using automated testing with ReSharper over F5 debugging. It also leads to at least one less production bug a month and gives me immense confidence in what I do allowing me to work even faster.
Poorly maintained code is difficult to change, difficult to understand and in some cases difficult to read! This is often referred to as spaghetti code. These design problems lead to stagnant progress evolving a software product to the ever changing demands of business. Writing, understanding, maintaining and evolving software is hard work and is often tedious.
ReSharper reduces repetitive and tedious tasks evolving code by providing a plethora of automated refactorings. It's challenging enough to decide WHAT refactoring to apply, let alone to carry it out. Most beneficial refactorings can be automated and ReSharper does just that with integration and shortcut keys! Having these tools available at a keystroke means I don't wait to change code that is troublesome. ReSharper allows me to avoid the need for a "re-write" by continuously evolving the code to meet the needs of business. Paired with easy automated testing and I have confidence that my refactorings aren't introducing bugs!
Maintainable code means I don't have to worry about re-writes, ReSharper can even help tackle the worst of spaghetti code and evolve it to something more maintainable over time. The costs and risks in a "re-write" are phenomenal. Day to day refactorings save me at least an hour every week manually refactoring my code and it expands my ability to do so. Continuous refactoring also reduces the likelihood of a delay from code that is difficult to change.
Style preferences aside, most developers agree consistency is a good idea. Each project often has a particular style that is an artifact of the time it was created in. Often there's no reason to change the style, but it can be extremely difficult to enforce it when I adopt new styles.
ReSharper allows me to setup shared settings for multiple machines or when I work on teams. They are applied hierarchically so I can have whatever level of consistency I desire. These settings allow decisions in the past to be enforced via simple Code Cleanup commands and don't require me to spend time worrying if I am following consistent rules for any particular project. Instead, I can focus on the content and get consistency for free!
I save at least 30 minutes each day, I know this because I use the silent cleanup
ctrl+e,f immediately followed by
ctrl+s and find myself doing it in applications that don't support it :) If I stumble on code that is inconsistent, I setup rules and apply cleanup as needed to get a better idea of what it does.
As systems grow, so does the code behind them. This can become difficult to organize and even more important to navigate. Folders and projects only go so far and the Solution Explorer is a very crude way to get where you need to go, it's not very keyboard friendly! I spend a significant amount of my time reading code, so having a barrier to navigation is extremely unproductive.
ReSharper provides a bevy of features to ease navigation. A single
Navigate To shortcut with contextual support can get me where I am going quickly. The
Go to Type,
Go to File and other
Go to features make searching and jumping to any place in code lightning fast. ReSharper even supports integrated decompilation and navigation with dotPeek. Paired with refactoring and testing, superb navigation further allows me to evolve and comprehend code.
ReSharper also makes identifying unused code with solution analysis a simple task and helps remove it with
Safe Delete. Unused code just leads to confusion and begets more unused code!
Every day I navigate to different places in my code 100s of times, ReSharper provides features that shave multiple seconds off each navigation, the amount of time is incomprehensible, at least 30 minutes every day, and that's only estimating about 4 seconds saved per navigation, it takes longer than that to do anything with the solution explorer and a mouse.
Even the best of languages can be verbose, C# is not immune and wow is all I can say about Visual Basic. Why should I spend time typing syntax when I could be focused on content?
ReSharper provides many completions to make writing code less burdensome. It also supports several levels of templating and generation to reuse common patterns. These templates are customizable and can be shared with other team members with ease. One of my favorite templates is a test method snippet. When I want to add a test I don't have to type the scaffolding, I can focus on the content. I write more fine grained tests because of this which increases maintainability of my tests! I also thoroughly enjoy code generation of method declarations so I can focus on what the method does!
Less typing saves me even more time every day, at least an hour a day versus manually typing everything out, the biggest savings is in avoiding compilation and other mistakes that shift my focus from content.
Of the above, which are by no means comprehensive of the value I get out of ReSharper, I've enumerated a savings of at least 13 hours per week. That's time I re-invest in content instead of tedium. This is likely a conservative estimate as I feel my productivity is more than doubled with ReSharper.
If you are a developer, what would these savings mean to you? If you fund development teams in your company, what would these savings mean for your company?