Refactoring - Inline Method

Motivation: A method's body is just as clear as its name.

public float GetMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes)
{
    return CalculateMovieRanking(rating, totalVotes, minVotesRequired, meanVotes);
}

private static float CalculateMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes)
{
    float movieRanking = (rating * totalVotes + minVotesRequired * meanVotes) / (totalVotes + minVotesRequired);
    return movieRanking;
}

Refactor as:
public float GetMovieRanking(float rating, int totalVotes, int minVotesRequired, float meanVotes)
{
    float movieRanking = (rating * totalVotes + minVotesRequired * meanVotes) / (totalVotes + minVotesRequired);
    return movieRanking;
}

Comments

Popular posts from this blog

Performance Test Run Report Template

Understanding Blockchain

Bugs Management in Agile Project