In the english computer science world, the principle of locality refers to a dynamic memory access pattern. The german translation is "Lokalitätsprinzip". However, in the german computer science world, the Lokalitätsprinzip also refers to a software engineering principle.

The principle of locality means that all relevant information about a single concept, should be at the same location as context free as possible. The single concept can be an algorithm, a mapping, etc. Location can be interpreted as page, function, module, entity etc.

The intention behind the principle of locality, is that code should be understandable in small bites with little context. This helps with debugging and testing. It also improves reuseability, if functions do not depend on context.

For example, the object-oriented practice of keeping methods small follows from this principle.

© 2013-08-17