For my Week 7 reflection, I will be writing a short summary of what I've learned about abstract data types. In CSC108, all of our assignments were given to us with explicit instructions on what certain functions should return. Because of this, I had become accustomed to seeing a problem and instantly trying to formulate code to resolve it. That may have worked for individual functions, but when presented with classes of various methods and multiple functions that all have to work together to create something like a gaming interface, it's very difficult to start writing function bodies without having a good sense of the big picture.
ADTs are useful in providing a glimpse of the bigger picture, because they describe the data stored in an object and the operations that can be performed on it, but they don't include the actual implementation. When a class' attributes and methods describing what it should be able to do are provided, it is much easier to understand the purpose of each method and see how they are interconnected and summate to the class as a whole. ADTs are also handy when they are made public for clients to use through a specified interface, because the user only has to deal with higher-level details such as passing arguments into a function call, and not with the nitty-gritty details in the function body.
One example of an ADT is a stack, which stores data and has operations push, pop, and is_empty. As a user, one wouldn't have to worry or be confused about how push, pop, and is_empty are implemented to understand how to use a stack, because the information on a stack's data and operations is all they need to effectively use it. All in all, I especially appreciated this aspect of ADTs, because they provide a framework that helps us focus on how we can use certain algorithms to solve problems, without leaving us caught up in the lower-level details like implementation.
No comments:
Post a Comment