문제

Does the data tier verify any of the user's input? or does it just store data?

Example - User adds email to his profile.

Is this right?

Presentation Tier - Verify Email format is valid (client side)

Logic tier

  • Verify Email format is valid (again?)
  • Set Email type (ie is Primary email?)
  • Check record limit allowed to store email

Data:

  • Store the email record

Logic:

  • Send Notification to presentation tier
  • Send Notification via Email
도움이 되었습니까?

해결책

Note :

Data layer task is to connect with the database and to perform CRUD operation if you want to apply extra validation logic than you must do it in the logical layer

You architecture changes

Presentation Tier -

  • Verify Email format is valid (client side)

Logic tier

  • Verify Email format is valid (again?) - No need to do it again
  • Set Email type (ie is Primary email?)
  • Check record limit allowed to store email

Data Layer:

  • allow to connect with the database
  • perform CRUD operation

Data Store i.e DataBase

  • Store the email record

Return

DataLyer

  • Informs logic layer data inserted propertly

Logic Layer:

  • Send Notification to presentation tier either data inserted/updated properly
  • Send Notification via Email if Data Inserted/Updated properly else log error

다른 팁

Every layer has its own set of contracts with outside world.

You shouldn't do or not do something based on assumption that it may have been done on earlier layer (like validation)

However DataLayer doesn't verify email address formats. Its not part of its responsibilities. It shouldn't even understand what an email looks like except for a fact that it is string of some specific length.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top