Maintaining consistent coding standards ensures code quality, readability, and maintainability across all Intent Architect modules. These guidelines apply to all C# code, module specifications, and related artifacts.
// Use 4 spaces for indentation (not tabs)public class Example{ private readonly string _value; // Single blank line between members public Example(string value) { _value = value; } public void ProcessValue() { if (string.IsNullOrWhiteSpace(_value)) { return; } // Process value }}
// Always use braces, even for single-line statementsif (condition){ DoSomething();}// Opening brace on new line (Allman style)public void Method(){ // Implementation}// For lambda expressions, use appropriate formattingvar result = items .Where(x => x.IsActive) .Select(x => x.Name) .ToList();
// Use comments to explain WHY, not WHAT// Good: Explain reasoning// We cache this value because the calculation is expensive// and the value doesn't change during executionvar cachedResult = CalculateExpensiveOperation();// Bad: Stating the obvious// Set x to 10var x = 10;
<?xml version="1.0" encoding="utf-8"?><package> <id>Intent.ModuleName</id> <version>1.0.0</version> <authors>Your Name or Organization</authors> <summary>Brief description of the module</summary> <description>Detailed description of what the module does</description> <iconUrl>data:image/svg+xml;base64,...</iconUrl> <tags>tag1 tag2 tag3</tags> <releaseNotes>release-notes.md</releaseNotes> <dependencies> <dependency id="Intent.Common" version="4.0.0" /> </dependencies></package>
// Be specific with exception typestry{ ProcessTemplate(template);}catch (ArgumentNullException ex){ _logger.LogError(ex, "Template was null"); throw;}catch (TemplateException ex){ _logger.LogError(ex, "Template processing failed"); // Handle or rethrow}
// Use 'using' statements for IDisposableusing var stream = File.OpenRead(filePath);using var reader = new StreamReader(stream);var content = reader.ReadToEnd();// Or traditional using blocksusing (var connection = CreateConnection()){ // Use connection}