I was reading about the history of Microsoft and Webforms. How people strayed away from Webforms because it mixes business logic with display/presentation logic. So when reading Angular 8, and seeing they are mixing web html with Business validation logic, doesn't this break SOLID principles and separation of concerns? Why is Angular 8 allowing this, and is there another alternative in Angular? 'name.invalid, name.dirty, untouched, etc"

 <input class="form-control"
 pattern="^[A-Za-z ]+$" />
 <ul class="text-danger list-unstyled" *ngIf="name.dirty && name.invalid">
 <li *ngFor="let error of getValidationMessages(name)">
 <button class="btn btn-primary" type="submit">
  • Input validation and business logic are not the same thing. On the frontend, validation is more about UX, and involves UI-specific considerations. On the backend, you have to validate again, because there's a possibility that the input has been tampered with in a malicious way, but it's slightly different because you don't have a UI, and have to think about things like responses. Then there's business logic behind all that. The problem with webforms, though, was more that the web controls were conceptualized as stateful, but it was all very clunky and downright hackish. – Filip Milovanović Oct 27 '19 at 4:27
  • hi @FilipMilovanović thanks ! feel free to write as answer, and I can send points ! – user349637 Oct 27 '19 at 6:05
  • @Filip Some types of input validation are presentation logic, and some business logic are. Checking that the input for a year is an integer - presentation logic. If the presentation for the year changes, this rule may change or disappear. Checking that the age should be less than 75 years - business logic. Presentation validation rules are checked before the business validation rules. – Nick Alexeev Oct 27 '19 at 14:40
  • @NickAlexeev: it's all driven by business rules on some level, but my point was more about code organization, and the idea that these are different concerns (validation of external input vs the behavior of the domain model), or at least, different aspects of a cross-cutting concern, so that, while there is overlap, it's not necessarily a good idea to reuse everything, as there are things there that are going to evolve independently (as you've pointed out), so one has to be a bit more careful and deliberate about designing these. – Filip Milovanović Oct 28 '19 at 6:37
  • @JeremySmith85 - I'll see if I have time; I feel the comment I left should be expanded a bit in order for it to be a good answer. – Filip Milovanović Oct 28 '19 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy