Principle of Locality
The Principle of Locality is the idea that programs usually access only a relatively small part of their address space at any instant of time.
Two kinds of Locality
- Temporal Locality (locality in time): The locality principle stating that if a data location is referenced then it will tend to be referenced again soon.
- “If you recently brought a book to your desk to look at, you will probably need to look at it again soon”
- Spatial Locality (locality in space): The locality principle stating that if a data location is referenced, data locations with nearby addresses will tend to be referenced soon.
- “Libraries put books on the same topic together on the same shelves to increase spatial locality.”
Locality of Behavior (Programming)
I first heard this term from Primagean. It goes against Abstraction / Single Responsibility Principle. But basically, grouping together something that does
You should abstract away when