First, to define what I'm talking about, the "length" of a source is how many characters it has. Having more characters allows improving readability by using more descriptive function and variable names, as well as indentation.
In compiled languages, the length of the source's text does not matter, but in interpreted languages (which AFAIK SQL is) it can. Does that also extend to stored procedures/functions?
In other words, do I need to try to minimize something like this:
CREATE FUNCTION dbo.Add_Highest_Subjects
(@studentScoreInMath INT,
@studentScoreInBiology INT,
@studentScoreInLiterature INT)
RETURNS INT
AS
BEGIN
DECLARE @bestOfTwo INT
SET @bestOfTwo =
CASE
WHEN @studentScoreInMath > @studentScoreInBiology
AND @studentScoreInBiology > @studentScoreInLiterature
THEN @studentScoreInMath + @studentScoreInBiology
WHEN @studentScoreInMath > @studentScoreInBiology
AND @studentScoreInBiology < @studentScoreInLiterature
THEN @studentScoreInMath + @studentScoreInLiterature
ELSE @studentScoreInBiology + @studentScoreInLiterature
END
RETURN @bestOfTwo
END
into that:
CREATE FUNCTION dbo.ahs(@m INT, @b INT, @l INT)
RETURNS INT
AS
BEGIN
DECLARE @r INT
SET @r = CASE
WHEN @m > @b AND @b > @l THEN @m + @b
WHEN @m > @b AND @b < @l THEN @m + @l
ELSE @b + @l
END
RETURN @r
END
Or is there no need?
PS: this is quite hard to search for, as I keep finding explanations of how the LEN function works, instead of the answer to my question.
PPS: I can't believe I have to say this: the function above is an example stripped down to essentials (variable names and indentations). I don't need advice on how to add two integers efficiently, but thank you.
RETURN. The second one though is almost impossible to maintain