The main drawback to structured programming is that the data and the methods that operate upon that data are completely separate. This means that any code with access to the data can modify that data. In and of itself that is not a major problem, but it places the onus upon the programmer to ensure that all data is modified in a consistent and highly predictable manner, which may require additional verifications and assurances within the code to ensure that is always the case. For instance, if a variable must have a limited range of 0 to 100, then the programmer may be forced to ensure that is the case before he can use the data, and may need to perform that same check every time the data is used.
Object oriented programming combines the data and the methods that operate upon that data into a single entity, presenting the data to the outside world in a more abstract form, limiting its exposure and protecting its integrity. Mutators that modify the internal data act as gatekeepers, assuring that any and all modifications to the data are consistent. The programmer no longer needs to continually check the state of the data before using the data, as the onus is now upon the object to ensure that data integrity is maintained at all times.
By delegating the workload to the objects themselves, highly-complex data models can be created simply by embedding objects within objects, where each individual object is solely responsible for its own data integrity. The programmer can then manipulate these highly complex structures as a single entity, rather than through a series of separate functions and data that could very easily be corrupted by a single errant statement that would be difficult to trace.
Copyright © 2026 eLLeNow.com All Rights Reserved.