The coding system had its origins in a reorganisation of locomotive operation and maintenance on the LMS in the 1933-35 period. It grouped all sheds into districts with a main shed, given the district number followed by the letter A as its code, and subsidiary sheds with the same number followed by B, C, or D etc. Many sheds were also responsible for sub-sheds where day-to-day servicing could be carried out but which lacked the facilities for intermediate or heavy overhauls. The extension of the system to all regions was brought into use in 1950, each region being given a block of district numbers:
Many codes changed as districts were re-organised and as regional boundaries changed over the years. For example, the former LMS shed at Goole was initially 25C as part of the Wakefield District. In September 1956 the district was transferred to the North Eastern Region and split between districts 53, 55 and 56; Goole became 53E in the Hull District. This district was itself merged with the York District in January 1960 and so Goole was re-coded again to become 50D. The changes accelerated with the contraction of the railway network and modernisation, both of which reduced the number of locomotives in use. For example, the Inverness district had five sheds and seven sub-sheds in 1950 but these had been reduced to a single shed by 1967. On 6 May 1973 all the remaining depot codes were replaced by new two-letter codes. These no longer included any kind of district hierarchy, but were more suitable for use with the TOPSoperating management computers.
Locomotive allocations
Each steam locomotive was allocated to a particular shed and an oval, cast metal plate with the depot code was bolted to the smokebox on the front of the locomotive. When a locomotive was reallocated to a different shed the plate was taken off and replaced with one from the new shed. Locomotives moved between a parent depot and its sub-sheds did not need this change as they shared the same code. With the introduction of diesel and electric motive power the system of allocation became changed. Main line locomotives were capable of operating greater distances between servicing and, very often, depots only held the equipment and spare parts for servicing a limited range of locomotive classes. This resulted in them being allocated to a smaller number of depots and reallocations became less common. For instance, the 74 Western Region Class 52 diesel-hydraulics were only ever allocated to six depots and were eventually all based to just one rather than spread around more than 60 depots on the region, although they could often be found at many of these others. This meant that many depots only had allocations of shunting locomotives, and some locomotives did not carry allocation plates. Those that did had them in a variety of positions: Class 42s on the underframe below the cab but near-identical Class 43s on the front next to the left buffer; after 1967 the code was generally painted on the bodywork near the cab door. On the London Midland Region, from June 1968 until 1973 main line diesel locomotives were given a divisional allocation in which locomotives were allocated to a nominal district, although in practice the locomotives received major attention at the principal depot in the Division. For example, locomotives in the D01 London Division were effectively based at principal depot Willesden. Other divisions were D02 Birmingham Division, D05 Stoke-on-Trent Division, D08 Liverpool Division, D09 Manchester Division, D10 Preston Division, D14 London Division, D16 Nottingham Division.