Scalar user defined functions are the logical implementation unit for repeated code. However unlike most languages the use of scalar user defined functions in SQL Server can cripple performance.
This is especially true in case of reporting style queries that process many rows. The time taken for processing the function is proportional to the number fo rows, unlike most other SQL functions where the are optimisations for doing large bulk processing.
Whats more the user of UDFs blocks the use of parallel plans which also hurts reporting style applications.
There needs to be a way for these to be compiled and not to have such a detrimental impact on performance.