Skip to content

Explicitly test that the empty string is not treated specially in twofer#1802

Merged
jmrunkle merged 1 commit into
masterfrom
unknown repository
Apr 15, 2020
Merged

Explicitly test that the empty string is not treated specially in twofer#1802
jmrunkle merged 1 commit into
masterfrom
unknown repository

Conversation

@jmrunkle
Copy link
Copy Markdown
Contributor

We decided in issue #1783 (and previously) that the empty string should not be treated as a special case like null. As such, I think we should have a test for it.


Reviewer Resources:

Track Policies

Copy link
Copy Markdown
Contributor

@sshine sshine left a comment

Choose a reason for hiding this comment

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

the empty string should not be treated as a special case like null

I will point out that not treating "" as null can be done either by explicitly treating "" as something else, or as not treating "" at all. The advantage of the test is clarity: The student knows exactly what to expect. The advantage of the absence of the test is flexibility: The student and the mentor don't have to bother with the edge case.

I don't think one of these didactics are ultimately better than the other. I've used both.

In #1783, @Smarticles101 interestingly pointed out that this exact test was added in #733 (and discussed in #728). So the question arises, why was it then removed? The PR that removes it, #1246, doesn't reference the commit that added it, and it doesn't argue either. So I think it would be safe to say that most voices have endorsed the test.

I'm writing all of this to clarify, when someone comes along and wants to remove it again, this serves as a kind of summary of points previously made. And I'm noting to myself that nulls are bad, but that even Haskell has undefined; having the flexibility to choose whether to denote that a function is provably total is something we still only see in languages like Idris and F*.

Comment thread exercises/two-fer/src/test/java/TwoferTest.java
@jmrunkle
Copy link
Copy Markdown
Contributor Author

The advantage of the test is clarity.

This is precisely the point. We are trying to teach and giving students (especially in these early exercises) an ambiguous problem is not helpful.

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.

2 participants