Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
When I started my very first career in software development many years ago, I remembered that I really like to learn and achieve a lot of skills in software development via read notably books by gurus in this fields as well as read blogs of them. Some of the very famous books that I have read are Code Complete: A Practical Handbook of Software Construction, The Clean Coder: A Code of Conduct for Professional Programmers, Design Patterns: Elements of Reusable Object-Oriented Software, Refactoring: Improving the Design of Existing Code, and so on. And I strongly believed that all developers just like me also stepped into the software development industry in this way.
By the time, I wondered how to share what I have learned to the software development communities out there so that it will help them save their efforts for the first stage of their career. Just the last year, I saw there are couples of projects about Clean Code in JavaScript and PHP languages, and now is Ruby language. Then I thought that it would be great if I started the list just like them but customized sections for .NET/.NET Core, and that pushed me to start immediately in that night to create the very first Clean Code for .NET developers list at https://github.com/thangchung/clean-code-dotnet
To make it easy to readers, .NET developers in specially, I start with the different way by other lists (JavaScript, PHP, or Ruby language). I grouped them to the big group with collapsible sub-items which help readers couldnât be scary when they walk through the big list with huge items accordingly. In case they want to investigate or read in details, they can click on the title of the sub-item to read more. Tonyâââmy colleagueâââis also eager to join this project so that I told him to help me and heâs a person who proposed this IDEAS as well, and actually it makes the list became short and succinct. Talking a lot of the history of this list, let now go into details to see what inside those group.
Naming
- Avoiding using a bad name
- Avoid disinformation name
- Use pronounceable names
- Use camel-case notation
- Use domain name.
Variables
- Use meaningful and pronounceable variable names
- Use the same vocabulary for the same type of variable
- Use searchable names
- Use explanatory variables
- Avoid nesting too deeply and return early
- Avoid Mental Mapping
- Donât add unneeded context
- Use default arguments instead of short circuiting or conditionals
- Avoid magic string
Functions
- Function arguments (2 or fewer ideally)
- Functions should do one thing
- Function names should say what they do
- Functions should only be one level of abstraction
- Donât use flags as function parameters
- Avoid Side Effects
- Donât write to global functions
- Donât use a Singleton pattern
- Encapsulate conditionals
- Avoid negative conditionals
- Avoid conditionals
- Avoid type-checking
- Remove dead code
Objects and Data Structures
- Use getters and setters
- Make objects have private/protected members
Classes
- Use method chaining
- Prefer composition over inheritance
SOLID
- Single Responsibility Principle (SRP)
- Open/Closed Principle (OCP)
- Liskov Substitution Principle (LSP)
- Interface Segregation Principle (ISP)
- Dependency Inversion Principle (DIP)
- Donât repeat yourself (DRY)
Testing
- Single concept per test
Concurrency
- Use Async Await
Error Handling
- Donât ignore caught errors
- Use consistent capitalization
- Function callers and callees should be close
Formatting
- Uses .editorconfig file
Comments
- Only comment things that have business logic complexity
- Donât leave commented out code in your codebase
- Donât have journal comments
- Avoid positional markers
Recap
Weâre still working on this list, and I believe that it will be longer and accuracy. Our team looks forward to having all of you to involve, contribute and help to make this list more useful for .NET/.NET Core Community.
Again, the clean code list for .NET/.NET Core can be found at https://github.com/thangchung/clean-code-dotnet
Thanks for reading! If you enjoyed this article, be sure to click đ symbol below so others will see it.
Clean Code for .NET Coding Craftsman was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.