Skip to content

Issue #20: Indecent Exposure #20

@shadyashraf174

Description

@shadyashraf174

Issue #20: Indecent Exposure

Type: Encapsulation Violation
Files: BlogPost.cs, BlogComment.cs

Problematic Examples:

  1. Public setters in domain models:
public string Title { get; set; } // Should be private set
  1. 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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions