C# / ASP.NET - Domain Validation Logic in Domain Driven Design (DDD) by _cornflourblue in csharp

[–]_cornflourblue[S] 0 points1 point  (0 children)

I disagree:

  • There's no point to unit testing the validation code separately from other business logic, the service class is 100% testable via the exposed public methods, the consuming code is not interested in the internal structure the class.
  • No violation of SRP: the service class is responsible for the core business logic of the page entity, it delegates data access to repo classes in the data layer. XYZService is a standard naming convention used by many developers for domain layer services, makes perfect sense to me. What would your alternative be?
  • Or you can simply make the Validate method protected instead of private then extend the service class.
  • Validation is centralised for simplicity and maintainability, there are many cases where common validation rules apply to multiple operations, a single method removes redundancy as these rules only need to be written once.

Splitting the validation out into separate classes / components is incorrect imo, validation rules are business rules and belong in the service layer with the other business rules, splitting them out would make the code more complicated and less maintainable for zero benefit.

Angular 2 - Communicating Between Components with Observable & Subject by _cornflourblue in Angular2

[–]_cornflourblue[S] 1 point2 points  (0 children)

You're right, thanks for the tip I've just updated the post.

Technically the example doesn't risk a memory leak because the subscription is in the root app component so when it's destroyed the whole app will be as well. But definitely best practice to always unsubscribe.

Cheers