In this paper we study a special subclass of real solvable Lie algebras having small dimensional or small codimensional derived ideal. It is well-known that the derived ideal of any Heisenberg Lie algebra is 1-dimensional and the derived ideal of the 4-dimensional real Diamond algebra is 1-codimensional. Moreover, all the coadjoint orbits of any Heisenberg Lie group as well as 4-dimensional real Diamond group are orbits of dimension zero or maximal dimension. In general, a (finite dimensional) real solvable Lie group is called an $MD$-group if its coadjoint orbits are zero-dimensional or maximal dimensional. The Lie algebra of an $MD$-group is called an $MD$-algebra and the class of all $MD$-algebras is called $MD$-class. Simulating the mentioned above characteristic of Heisenberg Lie algebras and 4-dimensional real Diamond algebra, we give a complete classification of $MD$-algebras having 1-dimensional or 1-codimensional derived ideals.