nus-cs2103-AY2324S2 / forum

16 stars 0 forks source link

Regarding Equivalence Partitions #1043

Closed itstrueitstrueitsrealitsreal closed 6 months ago

itstrueitstrueitsrealitsreal commented 6 months ago

Hi, wanted to clarify the following:

Let's take an example of a method, foo(int i). Examples of equivalence partitions, depending on the context of the method, would be [MIN_INT, -1], [0], [1, MAX_INT].

Would null be part of another EP? And would inputs from other types form other EPs as well? Or would they be part of the same EP?

dillontkh commented 6 months ago

I think it might make sense in other weakly typed languages. However since Java is strongly typed, if you try to pass a null into a function expecting an int it won't even compile. So I don't think it's something we need to be concerned about in this case.

wilsonwid commented 6 months ago

I think it might make sense in other weakly typed languages. However since Java is strongly typed, if you try to pass a null into a function expecting an int it won't even compile. So I don't think it's something we need to be concerned about in this case.

To add on, this is because int is a primitive type. If we use Integer instead, then yes I think null should be an equivalence partition.

itstrueitstrueitsrealitsreal commented 6 months ago

Thanks for the input guys! Closing this issue.