From 210f9cc8e1e28c435e41704d6d9f53f2e7149f9c Mon Sep 17 00:00:00 2001 From: Greg Hays Date: Tue, 23 Jul 2024 11:15:37 -0700 Subject: [PATCH 1/2] DOCUMENTATION: Proccessings Proofing Closes: #286 --- 2. Services/2.2 Processings/2.2 Processings.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/2. Services/2.2 Processings/2.2 Processings.md b/2. Services/2.2 Processings/2.2 Processings.md index cd78d1a..8d644c5 100644 --- a/2. Services/2.2 Processings/2.2 Processings.md +++ b/2. Services/2.2 Processings/2.2 Processings.md @@ -12,7 +12,7 @@ Here's an example of what a Processing service function would look like: public ValueTask UpsertStudentAsync(Student student) => TryCatch(async () => { - ValidateStudent(student); + ValidateStudentOnUpert(student); IQueryable allStudents = this.studentService.RetrieveAllStudents(); @@ -21,7 +21,7 @@ TryCatch(async () => retrievedStudent.Id == student.Id); return studentExists switch { - false => await this.studentService.RegisterStudentAsync(student), + false => await this.studentService.AddStudentAsync(student), _ => await this.studentService.ModifyStudentAsync(student.Id) }; }); @@ -106,7 +106,7 @@ Processing services delegate full validations to the layer of services that are public ValueTask UpsertStudentAsync(Student student) => TryCatch(async () => { - ValidateStudent(student); + ValidateStudentOnUpsert(student); IQueryable allStudents = this.studentService.RetrieveAllStudents(); @@ -115,13 +115,13 @@ TryCatch(async () => retrievedStudent.Id == student.Id); return isStudentExists switch { - false => await this.studentService.RegisterStudentAsync(student), + false => await this.studentService.AddStudentAsync(student), _ => await this.studentService.ModifyStudentAsync(student.Id) }; }); ``` -Processing services are also not very concerned about outgoing validations except for what they will use within the same routine. For instance, if a Processing service is retrieving a model and will use this model to be passed to another primitive-level function on the Foundation layer, the Processing service will be required to validate that the retrieved model is valid, depending on which attributes of the model it uses. +Processing services are also not very concerned about outgoing validations except for what they will use within the same routine. Some exceptions may be neccesary as discussed in later sections. For instance, if a Processing service is retrieving a model and will use this model to be passed to another primitive-level function on the Foundation layer, the Processing service will be required to validate that the retrieved model is valid, depending on which attributes of the model it uses. However, processing services will delegate the outgoing validation to the foundation layer for Pass-through scenarios. ## 2.2.3 Responsibilities @@ -141,6 +141,8 @@ For instance, in a shifter pattern, we want to verify whether a student exists. public ValueTask VerifyStudentExists(Guid studentId) => TryCatch(async () => { + ValidateStudentId(studentId); + IQueryable allStudents = this.studentService.RetrieveAllStudents(); From dfd6956bbb77ec437f84905f0ea8b10de7edc83b Mon Sep 17 00:00:00 2001 From: Greg Hays Date: Tue, 23 Jul 2024 13:30:46 -0700 Subject: [PATCH 2/2] CODE RUB: Resolve Review Comments --- 2. Services/2.2 Processings/2.2 Processings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2. Services/2.2 Processings/2.2 Processings.md b/2. Services/2.2 Processings/2.2 Processings.md index 8d644c5..e0bcd58 100644 --- a/2. Services/2.2 Processings/2.2 Processings.md +++ b/2. Services/2.2 Processings/2.2 Processings.md @@ -12,7 +12,7 @@ Here's an example of what a Processing service function would look like: public ValueTask UpsertStudentAsync(Student student) => TryCatch(async () => { - ValidateStudentOnUpert(student); + ValidateStudentOnUpsert(student); IQueryable allStudents = this.studentService.RetrieveAllStudents(); @@ -21,7 +21,7 @@ TryCatch(async () => retrievedStudent.Id == student.Id); return studentExists switch { - false => await this.studentService.AddStudentAsync(student), + false => await this.studentService.RegisterStudentAsync(student), _ => await this.studentService.ModifyStudentAsync(student.Id) }; });