3

I recently ordered a new credit card. I used the price comparison websites to find the best one that met my requirements.

I notice that these websites have a lot of validation on the client side. For example please see here: https://www.moneysupermarket.com/credit-cards/search/?goal=CC_ALLCARDS&purpose=AllCards&from=SSComponent. If you enter an invalid date of birth (under 18 years old), then there is client side validation that immediately says: "Unfortunately we can only provide product information to users aged between 18 and 99 years of age.". I would expect this logic to be in the domain layer rather than the presentation layer.

The reason I ask is because I read an article recently that said the website in question are champions of DDD? Is there a pattern/approach I am missing here. Is the presentation layer calling the domain layer through AJAX?

w0051977
  • 7,139

1 Answers1

1

Not all code that executes in the client is presentation layer. Increasingly with the advent of JavaScript frameworks like Angular and React, it's more common that logic is implemented client-side. The client-side applications have their own layers just like the server-side applications do. In the example you've linked to they have validation logic in the client's domain layer regardless of whether it's duplicated validation logic in the client or the client delegates to server for validation.

Samuel
  • 9,237