Skip to content

Gendarme.Rules.Smells.AvoidMessageChainsRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

AvoidMessageChainsRule

Assembly: Gendarme.Rules.Smells
Version: 2.10

Description

This rule checks for the Message Chain smell. This can cause problems because it means that your code is heavily coupled to the navigation structure.

Examples

Bad example:

public void Method (Person person)
{
    person.GetPhone ().GetAreaCode ().GetCountry ().Language.ToFrench ("Hello world");
}

Good example:

public void Method (Language language)
{
    language.ToFrench ("Hello world");
}
Clone this wiki locally