Issue #20: Indecent Exposure
Type: Encapsulation Violation
Files: BlogPost.cs, BlogComment.cs
Problematic Examples:
- Public setters in domain models:
public string Title { get; set; } // Should be private set
- Exposed collection:
public IList<BlogComment> Comments { get; set; } // Modifiable from outside
Solution:
private readonly List<BlogComment> _comments = new();
public string Title { get; private set; }
public IReadOnlyList<BlogComment> Comments => _comments.AsReadOnly();
Issue #20: Indecent Exposure
Type: Encapsulation Violation
Files: BlogPost.cs, BlogComment.cs
Problematic Examples:
Solution: