Many people have explored the concept of code reviews at length. They continue to be an integral part of the developer experience, for reasons I will discuss below. But, like most things that challenge us to improve, they can easily become awkward and a host for a variety of toxic behaviors. A number of articles have been written about proper code reviews, and they usually center around the idea of “being nice.” But I’m going to hone in on a few slightly different signs of toxicity in your code reviews. And with each sign, I’ll help you understand how you can change your team’s behavior to create a healthier environment.
Time for another C#-related post. We’ve already covered a fair amount of the language’s keywords, types, and concepts in previous posts. Today’s post covers C# comments, a topic that you might think is trivial.
My mission in this post is to convince you otherwise. True, comments are far from being the most exciting programming topic you could think of, I admit. And sure, comments have gotten a negative reputation over the years. But there’s more to comments than you might think.
In this post, you’ll learn about the definition of C# comments, followed by common justifications for their usage. Then we’ll proceed to show you the different possible types of C# comments and how to use them in practice. Let’s get started.
For many developers, their first experience handling time in C# is by using DateTime.Now.
When needing to retrieve the current date and time, they’d search for it, reaching a StackOverflow question or some documentation page by Microsoft. They’d quickly find that the way you get the current instant is by using the “DateTime.Now.” They’d go back to their code, use the property, and be done with it.
Also, for many developers, the scenario described above is the extent of their education about DateTime.Now. This isn’t good. Why?
Well, time is one of the trickiest topics in programming. Not knowing about its intricacies can get you into trouble. We’re here to help avoid that, by taking a look at the dos and don’ts of DateTime.Now.
We’re going to cover what DateTime.Now is the basics of its use. Then we’ll go a bit deeper, showing some more advanced usage scenarios (i.e. output formatting), covering the best practices you should employ and also the pitfalls you must be aware of when working with this property.
Let’s get started.
Software documentation is all about bringing clarity into a code baseline. It provides clues to clarify the meaning of certain code structures. For this purpose, we use best programming practices and tools to clarify our software.?When documenting software, we aim to minimize time spent hunting for meaning. We want anyone using or reading our code to know exactly what we meant when we wrote it. In addition, they should also know how to use our code without having to look for extra clues. Whether it’s an API, a suite of REST services, or simply a method in your code, it should all be clear.? When things are not clear, you have to dig up the meaning from other parts of the code, and this is a waste of time.
In this article, we’ll explore what information to document and how to do it. Lastly, we will talk about presenting our software documentation.
Welcome back to the CodeIt.Right Rules Explained series. For those of you who haven’t seen an installment in this series, let’s explain what it’s all about.?CodeIt.Right?is a tool that performs automated code review for .NET. It checks your code against a set of rules, giving you valuable feedback on its quality. Throughout the series, we’ve been explaining these rules, always three at a time.
In every post in this series, we start with the following two rules of thumb:
- Never implement a suggested fix without knowing what makes it a fix.
- Never ignore a suggested fix without understanding what makes it a fix.
Trust me?we don’t phrase it this way to sound funny or anything. It’d be the same thing to say ?figure out why the tool is suggesting this.? But we don’t. And here’s why.
Each time CodeIt.Right shows you a warning, you must decide to either address it or ignore it.?Make that choice for the right reasons. Ignore the warning when you’re truly convinced it doesn’t apply to your situation or doesn’t provide enough benefits. Don’t ignore it because you don’t understand it very well and don’t feel like handling it.
Now that you understand what this post is all about, let’s get to today’s three rules.
A minor feature update build v2018.2.19030 is now available
Changes in v2018.2
- GhostDoc now uses Async integration with Visual Studio with background load enabled. This minimizes the GhostDoc load on Visual Studio startup.
- Added new setting?Options -> Solution Options -> General -> “Use <inheritdoc /> tag for inherited comments”. When checked, GhostDoc will insert the
<inheritdoc />tag instead of copying the base member documentation.?Note: When using the
<inheritdoc />, remember it is a custom tag and you must use GhostDoc to generate help documentation and VS Intellisense files.
- Modified Properties, Methods, Indexer, Event and Constructor T4 templates to insert the
<inheritdoc />tag instead of copying the base member documentation – when UseInheritdocTag setting is True.
- Encryptions within GhostDoc are now FIPS compliant.
- Abbreviations dictionary now allows abbreviations with an empty value. This enables skipping abbreviations and word parts like prefix, suffix etc.
- Now a new XML Comment template is generated when Visual Editor opens using Ctrl-Shift-D for the member that does not have XML Comment.
- Numerous fixes and improvements
For the complete list of changes, see What?s New in GhostDoc v2018
One of the most anticipated acts at a circus is the juggler?a performer who can move five or six or more balls in the air at the same time. The really complicated juggling acts, however, add something extra to wow the crowd. The juggler?first climbs some stairs, high up but still close enough for everyone to see. He’s on a platform. The overhead lights are dim while one bright spotlight is on the juggler as he starts to juggle?one, two, three, four, five, and six balls moving effortlessly through the air, all in balance. He’s good!
But now, a new spotlight illuminates everything to his right … and everyone is amazed. It’s a tightrope that runs across the entire stage to another platform. The juggler then turns and faces the tightrope while juggling the six balls, and he starts walking slowly across. Step by step, balancing and juggling, he gets to the other side. He then turns to face the crowd, catches each ball, and bows. The crowd roars in delight! He’s done!
In many ways, a software developer is a juggler who is keeping many balls in the air while simultaneously walking on a tightrope. If you drop any balls or you walk in the wrong direction, you will fail. If, on the other hand, you get to the right destination with all the balls in the air, you get to stop, take a bow, maybe get some applause, and be done with your software.
The C# interface isn’t exactly intuitive.
Interfaces, in general, are common. We use them all the time. You’re using at least one interface right now as you read this article.
Keyboards, mice, and screens are interfaces to your operating system. It’s the same concept with C# interfaces.
In this article, I’ll start with these familiar device?interfaces as a metaphor for explaining the C# interface. I’ll use examples and alert you to some of the pitfalls. You’ll also learn about industry best-practices when using C# interfaces.
By the end, you should have a clear picture of the C# interface.
Imagine you’re a software developer working on a financial application. One day you’re assigned (or, if you’re agile, you pick yourself) to implement changes to the overtime computation logic so your company can sell the application in France. In France, the official work week has 35 hours (lucky them) instead of the 40 hours in the US. Being new to the team, you’re not sure where to begin, so you start searching the codebase for the keyword “overtime.”
Let’s see the search results. No, no, no, maybe, no, no, maybe. Hmmm. OK, looks like it’s in this file, and then in this other file as well. Let’s take a look inside.
I see final static int HOURS = 8. What’s that? Looks like eight hours per day…maybe? Then final static int WEEK_HOURS = 40. Looks like 40 hours per week…maybe? Or maybe it’s in this method called getOvertime? I’m not sure where to find the logic I’m looking for.
This is a typical scenario when the meaning of the code is unclear. And it’s a time suck.
What would help you as a developer when modifying and fixing existing code? It’s easy to complain about code written by someone else, but what about the code you write yourself? What do you include so you can help the maintenance programmers who’ll come after you?
The simple answer is that you have to document your code?so your logic is clear, easy to understand, and easy to change.
This article will explain how to do that. We’ll explore what software maintenance is. Then we’ll talk about how to document our code so we can help the other developers who’ll be fixing and modifying the code we write. And since we often get to fix and modify our own code, this will be an article about how we can help ourselves, too.
Rent, employment, house buying: you name it. If you’re an adult, chances are that you’ve signed several contracts in your life (and will probably sign many more). A contract is an agreement that defines the rights and obligations of two or more parties in order to accomplish something.
Having a proper contract in place is a powerful tool to clear doubts about what you’re allowed or not allowed to do to the apartment you live at, for instance. A contract also defines penalties for the parties that fail to fulfill their part of the agreement. If you don’t put down your house payments when they’re due, you’re pretty much guaranteed to suffer some consequences.
Contracts are everywhere in the real world. But what would it look like if we could use something similar to contracts in our code? For instance, what if we could specify “clauses” that defined the conditions required at the start and end of a function? Or maybe that specified and enforced the invariants of our objects? In this case, I’d say our programs would definitely improve in readability, safeness,?and self-documentation.
And now, what if I told you something like this already exists?