Skip to content

Commit e00b560

Browse files
bkoelmandennisdoomen
authored andcommitted
Added rule for this/base prefixes (#123)
1 parent 58ab5cb commit e00b560

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

Src/Cheatsheet/Cheatsheet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ NOTE: Requires Markdown Extra. See http://michelf.ca/projects/php-markdown/extra
6262
* Don’t pass `null` as the sender parameter when raising an event (AV1235)
6363
* Use generic constraints if applicable (AV1240)
6464
* Evaluate the result of a LINQ expression before returning it (AV1250)
65+
* Do not use `this` and `base` prefixes unless it is required (AV1251)
6566

6667
<br/>
6768
**Maintainability**

Src/Guidelines/1200_MiscellaneousDesignGuidelines.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ Consider the following code snippet
9696
}
9797

9898
Since LINQ queries use deferred execution, returning `query` will actually return the expression tree representing the above query. Each time the caller evaluates this result using a `foreach` cycle or similar, the entire query is re-executed resulting in new instances of `GoldMember` every time. Consequently, you cannot use the `==` operator to compare multiple `GoldMember` instances. Instead, always explicitly evaluate the result of a LINQ query using `ToList()`, `ToArray()` or similar methods.
99+
100+
### <a name="av1251"></a> Do not use `this` and `base` prefixes unless it is required (AV1251) ![](images/1.png)
101+
102+
In a class hierarchy, it is not necessary to know at which level a member is declared to use it. Refactoring derived classes is harder if that level is fixed in the code.

0 commit comments

Comments
 (0)