The authors attack the problem of optimally extending the dimension of a linear binary block code by increasing its length but retaining its minimum Hamming distance. After defining some decisive characteristics of a code affecting its extension capabilities and proving some preliminary results, the authors give a necessary and sufficient condition for a code to be optimally extended. This result can be readily used to decide the existence of a code from the existence of another shorter code of which the first can be an extension, and this can be also done in a recursive manner, ending up with the need to examine the properties of much shorter codes.