![]() |
.. (לתיקייה המכילה) | |
How should we deal with empty arrays (Arrays with length of 0)?
| Consider them as illegal arguments. |
Should we handle exceptions inside the scan function?
|
No. All exception handling should be in the 'main' function. If you want to avoid many try&catch blocks you can use loops for similar types objects. Example: // SumIntegers example Integer[] a = {1,2,3,4,5,6,7,8,9,10}; Integer[] b = {23,45,36,78,32}; Integer[] c = {-54,39,6,7,2}; Integer[][] arrays = {a, b, c}; for (Integer[] arr : arrays) { try { s.scan(arr, 0, new SumIntegers()); } catch (IllegalArgumentException e) { System.out.println("Error with..."); } } |
Should we use casting (like c-style casting) and/or type checking?
| No need to use them. Since it's a statically typed languages the types can be deduced automatically when calling a generic function. |
What kind of errors should we check?
|
For each example think of bad inputs that can occur and handle them. Exmaple - The most common error - null objects. |

