-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 393 Notification Pattern #1912
Conversation
…ster for a course. This a working version of the app.
categories: Behavioural | ||
language: en | ||
tags: | ||
- Notification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tags, I would put Decoupling
and Presentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the tag Notification
notification/pom.xml
Outdated
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are needed. We use Java 11 language level for the whole project.
/** | ||
* With the DAO pattern, we can use various method calls to | ||
* retrieve/add/delete/update data without directly interacting | ||
* with the data source. The below example demonstrates basic CRUD | ||
* operations: select, add, update, and delete. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text seems to be copied from another pattern. Please update it to introduce the notification pattern briefly and describe how the example code implements it.
/** | ||
* This is not called. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, please describe the class
final String courseId = "CSE427"; | ||
final String semester = "Fall21"; | ||
final String department = "Engineering"; | ||
final FormRegisterCourse form = new FormRegisterCourse(courseId, semester, department); | ||
form.submit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to use local variable type inference (keyword var
) here. Additionally, it would be nice to have some comments that describe what happens. This is an example code for others to read, after all.
/** | ||
* Get a Notification object. | ||
* | ||
* @return Notification object. | ||
*/ | ||
public Notification getNotification() { | ||
return notification; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Lombok to get rid of boilerplate code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check this throughout the code
@@ -0,0 +1,23 @@ | |||
package com.iluwatar.notification; | |||
|
|||
public class Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good practice to provide Javadoc for each class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error
as a name can be a little bit too generic. Please consider alternatives.
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class FormRegisterCourse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name a little strange. Wouldn't RegisterCourseForm
sound better?
@Test | ||
void testCourseServiceTest() { | ||
RegisterCourseDto registerDTO = new RegisterCourseDto(); | ||
registerDTO.setDepartment("English"); | ||
registerDTO.setCourseId("CS444"); | ||
registerDTO.setSemester("Fall21"); | ||
CourseService course = new CourseService(); | ||
Boolean isRegistered = course.registerCourse(registerDTO); | ||
assertTrue(isRegistered); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably tests that the happy scenario for registering for a course succeeds. The naming of the test could be better. Additionally, there should be more tests that check the negative cases (course registration does not succeed).
@iluwatar thanks for the comments. I have made some changes and committed the change |
Kudos, SonarCloud Quality Gate passed! |
@@ -210,7 +210,7 @@ Example use cases | |||
|
|||
## Consequences | |||
|
|||
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time. | |||
* Dependency injection in java hides the service class dependencies that can lead to runtime notificationErrors that would have been caught at compile time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that some text has been accidentally replaced in many other patterns. Please revert the changes.
categories: Behavioural | ||
language: en | ||
tags: | ||
- Notification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the tag Notification
|
||
## Intent | ||
|
||
A Notification is an object that collects information about notificationErrors during validation of data. When an notificationError appears the Notification is sent back to the view to display further information about the notificationErrors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Notification is an object that collects information about notificationErrors during validation of data. When an notificationError appears the Notification is sent back to the view to display further information about the notificationErrors. | |
Notification is an object that collects information about notification errors during the validation of data. When a notification error appears, the notification is sent back to the view to display further information about the notification errors. |
> There's a form to register for a course. We need to validate the inputs to make sure | ||
> the inputs are valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use passive voice (see https://www.grammarly.com/blog/passive-voice/)
|
||
In plain words | ||
|
||
> An object that collects together information about notificationErrors and other information and communicates it to the presentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> An object that collects together information about notificationErrors and other information and communicates it to the presentation. | |
> Notification is an object that collects together information about notification errors and communicates it to the presentation layer. |
Add Notification pattern (issue pattern #393)
A Notification is an object that collects information about errors during validation of data. When an error appears the Notification is sent back to the view to display further information about the errors.
Pull request description