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

issues/KUI-1176 syllabus bugfix #345

Merged
merged 2 commits into from
May 28, 2024
Merged

Conversation

belanglos
Copy link
Contributor

This PR fixes

  • bug in creation of syllabusName (including refactoring and removal of duplicate code).
  • that no activeSyllabus was selected if there is no selectedSemester.

@belanglos belanglos requested review from a user and removed request for a user May 28, 2024 04:06
return <ActualSyllabusInformation syllabusName={syllabusName} />
}

export { SyllabusInformationOrNull as SyllabusInformation }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Curious what you think about this solution
I thought that calling the component SyllabusInformationOrNull for SyllabusInformation would be misleading. Rather the component ActualSyllabusInformation should be called SyllabusInformation, but then we would have a mismatch in file name <-> exported component.

Note also the change to named export.

Copy link

Choose a reason for hiding this comment

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

First: I like the change to named export. What are the real advantages of using default export? Or why don't we always use named exports?

I'm not sure I think calling SyllabusInformationOrNull for SyllabusInformation would be misleading actually. For the "user" SyllabusInformation is what the component actually is. The null check with an extra component is just an internal behaviour the "user" doesn't need to know about ("user"=the other component using this component).

And with that said, the only like important thing is the name of the actual exported component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious about the approach here.

Why can’t the functional component ActualSyllabusInformation just be called SyllabusInformation and either just return the html
if syllabusName exists or 
return (null) if syllabusName does not exist? Is it not possible to get rid of SyllabusInformationOrNull altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good question!
This is certainly possible. This is a rather philosophical discussion about readability and the notion that "one function should do one thing", which - I think - is mentioned in Clean Code in the chapter about functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I completely agree with Karl and think the approach that you have used is indeed the cleanest approach that could be used here.
right now there is nothing that mislead other developers. I also really liked the aliasing approach for exporting the component.
I used to handle this functionality (checking to show the component if is not null) inline in the other components and now I think this approach can help me to have cleaner code.
I'll also check the mentioned part inside the clean code book which is valuable to read.

@belanglos belanglos marked this pull request as ready for review May 28, 2024 06:47
@belanglos belanglos merged commit b2e2fba into master May 28, 2024
3 checks passed
@belanglos belanglos deleted the issues/KUI-1176-syllabus-bugfix branch June 12, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants