• Latest
Writing Beautiful, Optimized, and Better .NET Code

Writing Beautiful, Optimized, and Better .NET Code

June 23, 2022
Realme sells 2 million GT Master edition smartphones

Realme sells 2 million GT Master edition smartphones

July 1, 2022

Major Updates for What the Golf?, Clap Hanz Golf, Spire Blast, SP!NG, and More – TouchArcade

July 1, 2022
Skull & Bones seasonal events aim to raise overfishing awareness

Skull & Bones seasonal events aim to raise overfishing awareness

July 1, 2022
TikTok versus Reels battle set to intensify

TikTok versus Reels battle set to intensify

July 1, 2022
Fireworks photos made easy: Getting the most bang out of your images

Fireworks photos made easy: Getting the most bang out of your images

July 1, 2022
Nintendo Launches Subscription Service For Switch Repairs In Japan

Nintendo Launches Subscription Service For Switch Repairs In Japan

July 1, 2022
Kao the Kangaroo roadmap promises achievement fixes

Kao the Kangaroo roadmap promises achievement fixes

July 1, 2022
OnePlus 7 and 7T are finally getting Android 12

OnePlus 7 and 7T are finally getting Android 12

July 1, 2022
Xbox Cloud Gaming launches on Samsung smart TVs

Xbox Cloud Gaming launches on Samsung smart TVs

July 1, 2022
FIST: Forged In Shadow Torch Gets Physical Edition In September

FIST: Forged In Shadow Torch Gets Physical Edition In September

July 1, 2022
Google settles lawsuit with US app developers for $90 million

Google settles lawsuit with US app developers for $90 million

July 1, 2022
OnePlus Nord 2T debuts in India, sales begin July 5

OnePlus Nord 2T debuts in India, sales begin July 5

July 1, 2022
Advertise with us
Friday, July 1, 2022
Bookmarks
  • Login
  • Register
GetUpdated
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About
No Result
View All Result
GetUpdated
No Result
View All Result
GetUpdated
No Result
View All Result
ADVERTISEMENT

Writing Beautiful, Optimized, and Better .NET Code

June 23, 2022
in Software Development
Reading Time:7 mins read
0 0
0
Share on FacebookShare on WhatsAppShare on Twitter


Over the years, I’ve been in various discussions regarding the benefits of clean architecture, best practices, techniques such as code reviews, unit tests, etc., and I think to some degree, most of us are aligned on the reasons behind it. Having a clean architecture or code-base not only makes your development team happier, but it has a far-reaching impact on the business itself.

In this post, we will learn about NDepend, which is described on their website as the following:

“The ‘Swiss Army Knife’ for .NET Developers, Architects, and Teams”

Here, we will take the first steps to see how to install and set up NDepend in the Visual Studio project and get started with improving code almost immediately.

Setting the Scene

You can setup NDepend on your machine easily by following these steps:

  • Download the zip file.
  • Run NDepend Visual Studio extension installer.
  • Use NDepend.

The following is a 3-minute video from NDepend to show these steps:


I followed the steps as shown in the video and got NDepend set up in minutes.

Analyze .NET Code Base With NDepend

Let’s look at the code base that I will be using for testing purposes. I have a very simple .NET project with the following structure:

demoApp.Web

As you can see, it is a typical .NET Core Web API project (demoApp.Web) and it references two standard library projects for the domain model (demoApp.Core) and database repository (demoApp.Data).

You can download the source code from this repository or use your own codebase and the principles will be the same. I am using this very simple codebase to keep the focus on NDepend in this introductory post and at the same time, I am very well aware of this application code structure and component dependencies.

But as you may be already thinking, what about the complex code bases? and what if the developer is new to the project? This is where NDepend shines. Once you start using NDepend, it will make it much easier for you to navigate the code base, visualize dependency graphs, and, of course, help you find code issues, code smell, and other architectural concerns in an easy and rapid manner.

You can visit the official website for more information.

Now, getting back to the next installation step, once NDepend is installed, you will find the options as shown below:

Options once NDepend is installed

Click Attach New NDepend project to Current VS Solution. With this one click, the VS solution will be configured with NDepend. On the next screen, you can start the analysis with the click of a button as shown below:

Start the analysis

Analysis Results

Once NDepend runs through the code assemblies, it will generate an HTML report and also provide you with some options for the next steps:

Next step options

You can see the possible actions and corresponding descriptions. The following picture shows a display of the NDepend Dashboard:

NDepend Dashboard

You can see this view gives us a good overview of code analysis. We can now drill deeper for issues/concerns, see more details, and take necessary action to improve the code base.

The information and options from NDepend may seem overwhelming, but that is ok: take your time to check each option. There are short videos for each feature from NDepend on their website. You can gradually learn these options and apply them to your codebase as you progress.

Context Is the King

Context is the king in the land of architecture. While NDepend can help you with analyzing your codebase, provide easy navigation to different concerns, and assist you to improve your code base, it is up to you as a developer to evaluate whether or not to accept those recommendations.

Project Rules

NDepend has many built-in code quality checks and rules which look for common issues and suggest best practices. You can also introduce new rules as per your project requirements to configure NDepend to meet your specific needs and evolve your application architecture while following your internal best practices and policies.

Here is an example from an analysis where NDepend identified 2 issues in the dashboard with high severity in the code base:

Example from an analysis where NDepend identified 2 issues in the dashboard with high severity in the code base

We can drill down to the issues and see which rules are violated:
Which rules are violated

As you can see, along with the rule description, NDepend is providing suggestions to fix the issue and with a simple click, it will take us to the corresponding code area to fix it.

Here is the code which is not following the rules:
Code not following rules

Now, the developer can review the code and fix the issue following the suggestions suggested by NDepend.

Dependency Graphs

Dependency Graphs are another useful feature from NDepend which help you visualize the solution. It becomes extremely useful with complex code bases, architectural discussions, and also helps onboard new developers to understand the solution structure and dependencies.

Here is the dependency graph for our sample source code:

Dependency graph for our sample source code

You can check this resource on the official website for more details. There is also a nice video on the official website, which will walk you through this great feature in a simplified manner:


Other NDepend Features

Some of the notable features of NDepend are as follows:

  • Easily manage large projects
  • Continuous code quality
  • Monitor the health of your application
  • Reduce friction between your developer teams
  • Working with legacy code easily

There are a lot of other useful features with NDepend that I will cover more in upcoming posts. Please check the official website for more details and examples.

Summary

In this post, we saw that NDepend is a very useful tool and it promotes code quality in your projects. Installation is simple and you can quickly get started with it. It has built-in rules to help you write better code and is highly configurable to allow you to add/remove rules as per your project’s requirements.

I suggest you give it a try by downloading the trial version and see its ease of use and benefits to your projects and teams.

Let me know if you have some comments or questions. Until next time: Happy coding.



Source link

ShareSendTweet
Previous Post

Taiko no Tatsujin: Rhythm Festival Arrives On Nintendo Switch This September

Next Post

Aspyr Suggests Using Warp Cheat To Overcome Star Wars: KOTOR II’s Game-Breaking Switch Bug

Related Posts

MongoDB vs DynamoDB Head-to-Head – DZone Database

July 1, 2022
0
0
MongoDB vs DynamoDB Head-to-Head – DZone Database
Software Development

Databases are a key architectural component of many applications and services. Traditionally, organizations have chosen relational databases like SQL Server,...

Read more

Understanding Kubernetes Resource Types – DZone Cloud

July 1, 2022
0
0
Understanding Kubernetes Resource Types – DZone Cloud
Software Development

Note: This is the first of a five-part series covering Kubernetes resource management and optimization. We start by describing Kubernetes...

Read more
Next Post
Aspyr Says It’s Aware Of Star Wars: KOTOR II Switch Crash Preventing Players From Completing The Game

Aspyr Suggests Using Warp Cheat To Overcome Star Wars: KOTOR II's Game-Breaking Switch Bug

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 GetUpdated – MW.

  • About
  • Advertise
  • Privacy & Policy
  • Terms & Conditions
  • Contact

No Result
View All Result
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?