21 Techniques to Write Better Code

Bruce H. Cottman, Ph.D.
The Startup
Published in
10 min readApr 9, 2020

--

I have pulled together these techniques from 35 years of programming in multiple languages on multiple projects. There is before and after Python code examples that apply each technique. I also show how to personalize Pycharm for these techniques for your projects.

PyCharm Local file History feature, Animation by Rachel Cottman

What is Photonai?

Photonai incorporates Scikit-Learn and other machine learning (ML) or deep learning (DL) frameworks with one unifying paradigm. Photonai adopts Scikit-Learn’s Estimator, and Transformer class method architecture.

Photonai adds code that reduces manual coding and error by transforming pre- and post-learner algorithms into elements with their argument signature. Examples of elements are several choices of data cleaners, scalers, imputers, class balancers, cross-validators, hyper-parameter tuners, and ensembles.

By applying these twenty-one techniques, we start the adding of clustering to the Photonai package. I give a before and after Python code example to show the transformation of Photonai using the technique.

Create New Version and Document Major Changes

Technique #1:

  • Create a new version a+1.0.0, if there is a major amount of architecture change, a major amount of code changed and, a major amount of new…

--

--

Bruce H. Cottman, Ph.D.
The Startup

I write my blog utilizing decades of experience in investment, programming, and data science.