14.5: Subdividing a Problem - Encapsulation
- Page ID
One of the advantages of the object oriented approach is that it can hide complexity. For example, while we need to know how to use the
urllib and BeautifulSoup code, we do not need to know how those libraries work internally. It allows us to focus on the part of the problem we need to solve and ignore the other parts of the program.
Ignoring Detail When Using an Object
This ability to focus on a part of a program that we care about and ignore the rest of the program is also helpful to the developers of the objects. For example the programmers developing BeautifulSoup do not need to know or care about how we retrieve our HTML page, what parts we want to read or what we plan to do with the data we extract from the web page.
Ignoring Detail When Building an Object
Another word we use to capture this idea that we ignore the internal detail of objects we use is "encapsulation". This means that we can know how to use an object without knowing how it internally accomplishes what we need done.