-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
return <ActualSyllabusInformation syllabusName={syllabusName} /> | ||
} | ||
|
||
export { SyllabusInformationOrNull as SyllabusInformation } |
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.
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.
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.
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.
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.
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?
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.
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.
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 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.
This PR fixes