I wouldn't use \providecommand, to begin with: if you load a package that happens to define \inlinecode, chaos might happen.
The definition is good, although I would say
\newcommand{\inlinecode}{\texttt}
that avoids reading the argument twice, but this is a minor issue. Using a self-defined command is the right way, as you can freely redefine it in (almost) any way you like.
The main problem is, of course, that long words in typewriter type are a potential source for overfull lines. There's no automatic cure, apart from enclosing the paragraph in a sloppypar environment that sets the tolerance (a measure of how much you are accepting large spaces between words) to a very high value. You can also use the \sloppy declaration that sets those parameters "forever" (but respecting groups, of course).
What to do depends on the nature of the document: an informal report might be set with \sloppy, a formal book not.
My usual suggestion is to worry about bad line breaks only when the text is in its almost final form. Only at that time you can check the bad breaks one by one: it's often easy to find a way to rephrase the paragraph and avoid the bad break. When this fails, you can put \emergencypar at the end of the paragraph, where you have defined
\makeatletter
\newcommand{\emergencypar}[1][3em]{%
\begingroup\emergencystretch=#1\relax
\@@par\aftergroup\par\endgroup}
\makeatother
and try. You can also change the parameter by saying \emergencypar[4em] or other values. This will enlarge the interword spaces, but in a more uniform way than with \sloppy.
The command sets the \emergencystretch parameter inside a group, in which the primitive command \par (that LaTeX calls \@@par) is executed. We need to execute also \par with its present meaning, but outside the group, since this command is used by LaTeX for some internal workings.
Example (\lipsum* doesn't add \par at the end)
\documentclass{article}
\usepackage{lipsum}
\textwidth=5cm
\makeatletter
\newcommand{\emergencypar}[1][3em]{%
\begingroup\emergencystretch=#1\relax
\@@par\aftergroup\par\endgroup}
\makeatother
\begin{document}
\lipsum*[2]
\lipsum*[2]\emergencypar[2em]
\end{document}
Some Underfull \hbox messages are unavoidable, one might insert \hbadness=4000\relax after setting the \emergencystretch in the definition above to limit their appearance only to very bad lines.
\newcommand{\inlinecode}{\texttt}without passing the argument around. Even more efficient would be\let\inlinecode\texttt. – Martin Scharrer May 25 '11 at 09:43