DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Code Smell 96 - My Objects
Maxi Contieri ⭐⭐⭐
Maxi Contieri ⭐⭐⭐

Posted on • Originally published at maximilianocontieri.com

Code Smell 96 - My Objects

You don't own objects.

TL;DR: don't use my as a name prefix.

Problems

  • Lack of context

  • Bijection Fault

Solutions

  1. Remove my prefix.

  2. Change to a role suggesting name.

Context

Several old tutorials use the word 'my' as a lazy name.
This is vague and lead to context mistakes.

Sample Code

Wrong

MainWindow myWindow = Application.Current.MainWindow as MainWindow;
Enter fullscreen mode Exit fullscreen mode

Right

MainWindow salesWindow = Application.Current.MainWindow as