All documentations I've read about starred/non starred versions of commands recommend more or less the following way of doing (following for instance the List of TeX FAQ):
\newcommand{\mycommand}{\@ifstar\mycommandStar\mycommandNoStar}\newcommand{\mycommandStar}{%<few lines of code only for starred mycommand><many lines of code common to starred/non starred mycommand>}\newcommand{\mycommandNoStar}{%<few lines of code only for non starred mycommand><many lines of code common to starred/non starred mycommand>}
For environments, the scheme is similar (following for instance this answer):
\newenvironment{myenvironment}{%<few lines of code only for non starred myenvironment><many lines of code common to starred/non starred myenvironment>}{%<few lines of code only for non starred myenvironment><many lines of code common to starred/non starred myenvironment>}\newenvironment{myenvironment*}{%<few lines of code only for starred myenvironment><many lines of code common to starred/non starred myenvironment>}{%<few lines of code only for starred myenvironment><many lines of code common to starred/non starred myenvironment>}
But, most of the case, there are only slight differences between starred and non starred versions and this way of doing requires to copy all changes in the common code between the two versions, which is a pain of maintenance (particularly if the common code is long).
Is there a more efficient way of doing?