Another C moment: Is there any point to the principle of least privileged?

VIAN

Diamond Member
Aug 22, 2003
6,575
1
0
The principle of least privilege:

for ex. defining a function prototype inside another function so that other functions wont be able to use it.

Is there really a point to that at all?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Well it's alright if you want to use some semantic information hiding scheme. But semantics is all it is because there is nothing to stop the other functions from defining the same prototype locally. So I guess it makes life easier if everyone always plays by the rules but if they don't then it's pointless.

If you use something like Java then you don't have that problem. It's much harder to break the rules then.
 

VIAN

Diamond Member
Aug 22, 2003
6,575
1
0
But I'm saying, if you are the programmer and you know what your doing, why would you need to make such rules if you could just program the program not to do what you don't want it to.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: VIAN
But I'm saying, if you are the programmer and you know what your doing, why would you need to make such rules if you could just program the program not to do what you don't want it to.

Namespace pollution?
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Depends on the function. If the function is one that should not be called outside of the scope of your code, then you certainly don't want to expose it. The oldest excuse in the book is, "well I'm the only one writing this program, so it's ok." That excuse only works in very limited scenarios. Certainly never in the real world when working for a company.