.NET Standards
At Defra, we use .NET as a secondary technology stack, with Node.js being our primary stack.
.NET does not align with our recruitment or training strategies and has a significantly smaller talent pool within Defra compared to Node.js.
The use of .NET must be justified with an evidence-based decision. This document outlines the standards for using .NET within Defra, ensuring alignment with modern practices and Microsoft's best practices.
Key Principles
- Primary Stack Preference:
- Node.js is the preferred stack for all new projects.
-
The decision to use .NET must be supported by clear evidence, such as:
- Integration with commodity products or libraries that are best suited to .NET.
- Specific backend service requirements that are better suited to .NET.
- Ecosystem is already heavily invested in .NET, making it more efficient to continue using it.
- Matches team profile and expertise.
- .NET is more prone to state mutation through multi-threading which can lead to hard to debug issues.
-
Backend Services Only:
- .NET is only used for backend services and integration with commodity products.
-
Frontend applications must not be developed using .NET.
-
C# Language:
- All .NET development must use the C# language.
-
Refer to the C# Standards for language-specific guidelines.
-
Long-Term Support (LTS):
- Always strive to use the latest LTS version of .NET.
- .NET Framework should only be used for maintaining legacy applications.
When to use .NET over Node.js
While Node.js is the preferred stack, there are scenarios where .NET may be better suited:
- Integration with Microsoft Ecosystem:
-
Some parts of the Microsoft ecosystem are easier to integrate with when using .NET. For example:
- Dynamics 365, which has strong support for .NET libraries and SDKs.
-
High-Performance Backend Services:
- .NET is generally better suited for CPU-intensive operations, such as:
- Complex mathematical computations.
- Image or video processing.
- Real-time data analysis.
-
The Just-In-Time (JIT) compilation and runtime optimizations in .NET can outperform Node.js in these scenarios.
-
Large-Scale Multi-Layer Monolith:
- For large-scale, multi-layered monolithic applications that require:
- Clear separation of concerns (e.g., presentation, business logic, and data access layers).
- Advanced tooling for debugging and profiling.
-
.NET provides a robust framework and ecosystem to support such architectures effectively.
-
Cross-Platform Desktop Applications:
- If backend services need to complement cross-platform desktop applications built with .NET technologies like:
- WPF (Windows Presentation Foundation).
- WinForms.
- MAUI (Multi-platform App UI).
- .NET ensures seamless integration between the desktop and backend.
Best practices
To ensure consistency and maintainability, follow Microsoft's official guidelines for .NET development: