Skip to content
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

Add Faculty class #68

Merged
merged 15 commits into from
Mar 15, 2024
Merged

Conversation

JerryWang0000
Copy link
Collaborator

@JerryWang0000 JerryWang0000 commented Mar 13, 2024

Add Faculty and its test class.

closes #45

JerryWang0000 and others added 8 commits March 7, 2024 03:08
* 'master' of https://github.com/JerryWang0000/tp:
  Update file names to follow format
  Update aboutus page with my details and photo
  Update typos
  Change use case for filter and typo in sort
  aboutus update file name
  changed names to match github names
  update aboutus info to name match lowercase requirements
  Updated use cases
  Update AboutUs for Jerry Wang
* 'master' of https://github.com/JerryWang0000/tp:
  Update files with traces of the package name "seedu.address" to "staffconnect"
  Update remaining files with traces of seedu.address in test
  Refactor package seedu.address to staffconnect in test
  Refactor package seedu.address to staffconnect in main
  Update header in _base.scss
  Fix typos and added clarity
  Update UserGuide description
  Update website main index
  Add pluiexo.md page
  Amend Readme
  Update github info
  Update Readme to fit StaffConnect
  Update DeveloperGuide.md
  Update AboutUs: Replace placeholder images
  Update UserGuide.md
Add Faculty and its test class.
@JerryWang0000 JerryWang0000 added type.Task Something that needs to be done, but not a story, bug, or an epic. priority.High Must do labels Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 77.81%. Comparing base (2a635ab) to head (e1b7be0).
Report is 68 commits behind head on master.

Files Patch % Lines
...c/main/java/staffconnect/model/person/Faculty.java 90.47% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #68      +/-   ##
============================================
+ Coverage     75.36%   77.81%   +2.44%     
- Complexity      424      495      +71     
============================================
  Files            72       80       +8     
  Lines          1352     1537     +185     
  Branches        127      148      +21     
============================================
+ Hits           1019     1196     +177     
- Misses          303      310       +7     
- Partials         30       31       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JerryWang0000 JerryWang0000 added this to the v1.2 milestone Mar 13, 2024
@JerryWang0000 JerryWang0000 linked an issue Mar 13, 2024 that may be closed by this pull request
Copy link
Collaborator

@tsulim tsulim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me! However, I have a couple of suggestions written in the review.
Keep up the good work, and let me know if you have any questions or need further clarification on the suggestions! 👍

src/main/java/staffconnect/model/person/Faculty.java Outdated Show resolved Hide resolved
src/main/java/staffconnect/model/person/Faculty.java Outdated Show resolved Hide resolved
Copy link
Collaborator

@iynixil iynixil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Could do with a few improvements (the equals() method, regex pattern).
Left a suggestion for the values that Faculty can take.

src/main/java/staffconnect/model/person/Faculty.java Outdated Show resolved Hide resolved
Restrict the valid input values to currently existing NUS faculties. Change the test class.
@JerryWang0000
Copy link
Collaborator Author

Now I store the faculty value as an enum. Do I need to change it to String?

Change the type of value to String.
public Faculty(String faculty) {
requireNonNull(faculty);
checkArgument(isValidFaculty(faculty), MESSAGE_CONSTRAINTS);
value = fromString(faculty).getFacultyName(); // can be extended
Copy link

@Pluiexo Pluiexo Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good, though the logic is abit off currenly it is: string -> enum->string, it makes having the enum class a bit redundant. May I suggest storing the enum instead and returning the enum. This gives an additional layer of abstraction for those who use faculty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider that, but I wish to keep conformity as other attributes which are also strings. The fromString() function can be extended so that maybe syncronyms can be allowed. don't have to type in the full name of the faculty. Adding enum can simplify the process.

Comment on lines 91 to 92
public String toString() {
return value;
Copy link

@Pluiexo Pluiexo Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When storing value as a enum, you may choose call a toString in the enum class to return the value inside the enums instead

* For this version, a valid faculty value should match exactly the full name of the facult,
* or the value is invalid
*/
public enum FacultyEnum {
Copy link

@Pluiexo Pluiexo Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For conciseness Enums don't contain the term enums in them, rather they are nouns by themselves to represent the type of items they contain. Eg: Faculties

Copy link

@Pluiexo Pluiexo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good! Though several logical nits to bring up

@JerryWang0000 JerryWang0000 changed the title Add Faculty class Add Faculty class Mar 15, 2024
* @return True if the input matches any faculty name.
*/
public static boolean isValidFaculty(String test) {
requireNonNull(test, "faculty cannot be null");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some may consider this magic string, but you don't have to fix it in this commit

Copy link

@Pluiexo Pluiexo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好嘞

@Pluiexo Pluiexo merged commit 712b8fa into AY2324S2-CS2103-F08-3:master Mar 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.High Must do type.Task Something that needs to be done, but not a story, bug, or an epic.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Faculty class
5 participants