-
Notifications
You must be signed in to change notification settings - Fork 0
Exceptions
Consider each of these 4 different code snippets. What do you reckon that they provide as a guarantee? You have to be specific and relate to the different functionalities that actually are in use. This means that some functionalities may provide one type of guarantee whereas others may provide another. When designing code you should also strive to ensure that although your code insides do as promised, interfaces should promote proper use as well - consider if any of the interfaces fail - e.g. cannot uphold guarantees. Also note any mistakes you may find in your quest. Use reasoning to substantiate your answer! Do note that small subtle tricks may have been employed. Do not let yourselves be fooled! :-D.
In listing 1.1 We find that the index operator should have some kind of validation that i is contained in the array. Otherwise it should throw an exception. In listing 1.2 We find that the myVector class, should have a destructor that deletes the allocated data_ In listing 1.3 We find that it would be better to use the copy constructor when overloading the equals operator
Made by: Frederik Both Rokkjær, Frederik Kronvang Gade and Christian Olsen