The "killer instinct" of excellent coders

The "killer instinct" of excellent coders

What makes an outstanding developer?

You may be the worst developer on the planet at the moment...

But there is one quality, if you can develop it, that will move you steadily in the direction of excellence.

That quality is:

A deep, visceral disgust of repetitive code.

If you can get your brain to adopt this - to be honestly intolerant of repetitive code - then it doesn't matter how mediocre you see yourself right now.

So long as you keep writing code... Keep developing software...

And keep surrenduring to this deep aversion to repetitive code...

You'll be COMPELLED to excellence.

Leaps and bounds better than 99% of all developers on this lumpy rock we call Earth.

I'm not going to shelter you with toy code here. Imagine you see code like this:

  1. # Listing 1
  2. import pandas as pd
  3. class BankAccountReader:
  4. def __init__(self, df: pd.DataFrame):
  5. self.df = df
  6. @classmethod
  7. def from_csv(cls, path):
  8. return cls(pd.read_csv(path, skiprows=6))
  9. class CreditCardReader:
  10. column_names = ['Date', 'Description', 'Category', ...]
  11. def __init__(self, df):
  12. self.df = df
  13. @classmethod
  14. def from_csv(cls, path):
  15. return cls(pd.read_csv(path, names=cls.column_names))

What MUST happen, is that you become someone who is COMPELLED to change it to code like this:

  1. # Listing 2
  2. import pandas as pd
  3. class CSVDataReader:
  4. def __init__(self, df: pd.DataFrame):
  5. self.df = df
  6. @classmethod
  7. def from_csv(cls, path: str, **read_csv_opts):
  8. return cls(pd.read_csv(path, **read_csv_opts))
  9. class BankAccountReader(CSVDataReader):
  10. @classmethod
  11. def from_csv(cls, path: str):
  12. return super().from_csv(path, skiprows=6)
  13. class CreditCardReader(CSVDataReader):
  14. column_names = ['Date', 'Description', 'Category', ...]
  15. @classmethod
  16. def from_csv(cls, path: str):
  17. return super().from_csv(path, names=cls.column_names)

Do you not understand some of the code in listing 2? Are some of the Python features unfamiliar?

Then you have to learn them. You'll be FORCED to master Python well enough that you can write this kind of code, so you can make your code un-repetitive.

Why this matters:

Can you see how much more expressive listing 2 is? How much more POWERFUL it is? And how it makes it easier to create new, even more powerful classes and code?

By "compelled", I mean that - in your mind - you effectively have no choice. Tolerating Listing 1 is NOT AN OPTION for you...

I becomes almost physically painful for you to look at.

I'll go so far as to say that no one can become an outstanding developer - of Python, or any language - unless they have this quality...

This "program" running in your mind.

And if you don't have it yet... start cultivating it now.

You can do that, by choosing to keep that intention in your mind, every day.

If you do this, you'll go through a period where you're rewriting your own code a lot...

Endure it. What's on the other side is worth it.