Tutor profile: Marc S.
Subject: Java Programming
What is a good example of using <? super T>?
<? super RandomClass> refers to a class of type RandomClass or any of RandomClass' super classes. For example if some code is trying to sort a list of vehicles by manufacturer year then the comparison could use the model year field which will be present in all vehicles. So Cars in a list of type List<Car> could be compared with a list of List<Vehicles> if the the comparator took in type <? super Car>.
Subject: Software Engineering
Why is taking time to name variables, functions, and classes so important?
Well named variables and functions make for much more readable code. This improves the software by: - Decreasing the need for comments - Increasing ease of comprehension when code is read - Forcing the developer to think about the design - Avoiding common naming pitfalls that are worse than poorly chosen names Code will be read 10 or 100 times for every one time it is edited, as Clean Code expert Bob Martin pointed out. So hard to read code requires explanation in comments, quickly reduces efficiency and creates more bugs. Plus thinking if the name is too long or doesn't fit with how the rest of the code base is named it clear that some part of what is being named should be refactored.
Subject: Computer Science (General)
How is space complexity different from time complexity? Give an example of when space complexity is more important than time complexity.
Space and time complexity are both analyzed in similar ways, and using similar notations. They are also both analyzed relative to the input for an algorithm or piece of code. But time complexity refers to the number of operations done during the course of an algorithm while space complexity refers to the amount of space taken up in memory during the course of the algorithm. For example an algorithm running on a small embedded system might sort a very large array of 8 bit integers which take roughly 700KB of the systems 1024KB of memory. A sorting algorithm like bubble sort with a space complexity of O(1) must be chosen or there might not be enough memory to continue running the system.
needs and Marc will reply soon.