- Always use types explicitly wherever possible.
- Write inline documentation for all public members and complex logic.
- Follow Microsoft's C# Coding Conventions: https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions
- Use PascalCase for class names, method names, and public members.
- Use camelCase for local variables and method parameters.
- Prefix private fields with an underscore (_).
- Use meaningful and descriptive names for all identifiers.
- Organize code into logical regions within classes.
- Keep methods short and focused on a single task.
- Use dependency injection for better testability and loose coupling.
- Use exception handling (try-catch blocks) for exceptional cases.
- Avoid using exceptions for normal flow control.
- Always include meaningful error messages in exceptions.
- Use meaningful names for XAML elements, especially those referenced in code-behind.
- Organize XAML code with proper indentation and grouping.
- Use data binding wherever possible to separate UI from logic.
- Use XML comments for all public members.
- Include
, , and tags in XML comments. - Write clear and concise comments for complex logic within methods.
Example:
/// <summary>
/// Generates a QR code from the given text.
/// </summary>
/// <param name="text">The text to encode in the QR code.</param>
/// <returns>A bitmap image of the generated QR code.</returns>
public System.Drawing.Bitmap GenerateQRCode(string text)
{
// Method implementation
}- Write clear and descriptive commit messages.
- Make small, focused commits that address a single concern.
- Use feature branches for new features or significant changes.
Remember, these conventions are guidelines to ensure consistency and readability across the project. They may be adjusted as needed for specific project requirements.