Quote:
Originally Posted by Mageofdancingdr
Real engineers use encapsulation because it is more secure against malicious programmers and their programs.
|
No, definitely not. You *could* make a statement that it makes things easier to debug, and thus more secure, but even then that is not strictly true.
Quote:
This is also why proper memory allocation is important as well. Keeping code secure from outside influence is important so that
A) the code doesn't interfere with other processes on the same machine
B) outside programmers can't access it
|
While proper memory allocation is a good thing, these are totally different issues. This is a *type* of encapsulation, but it certainly isn't the encapsulation one talks about when talking about programming languages (and really, (B) isn't even true in many situations that we won't go into here... ).
As someone above has pointed out, WPILib is a great example of why encapsulation is a good thing. Clearly it does not contribute to the security of the program.
For example, just because you declare something in a class as 'private' does not mean someone cannot access it (in absolute terms). Generally, accessing private members in a class will not compile correctly -- however if you had a raw pointer to the member then you could easily change the item, despite it being private. Additionally, there are a few ways one could make something that accesses a private member compile if you wanted to be truly nasty: see
http://www.gotw.ca/gotw/076.htm if you're interested.
Quote:
|
C) it allows for a more modular type of code where simple function calls change not entire blocks of code.
|
This is the correct answer (though its more generic than just simple function calls).