callat-qcd / lattedb

Lattice QCD database interface using EspressoDB as the content manager.
https://ithems.lbl.gov/lattedb
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Model class names in singular #9

Closed ckoerber closed 5 years ago

ckoerber commented 5 years ago

It is best practice in Django to write model classes in singular. E.g.,

class Propagator

instead of

class Propagators

We should change all models to the first structure for consistency.

ckoerber commented 5 years ago

@cchang5 I guess we should fix that rather sooner than later.

ckoerber commented 5 years ago

The new naming convention for models / classes:

  1. CamelCase singular like, e.g., GaugeConfiguration
  2. Do not keep inheritance in name like HisqGaugeConfiguration -> Hisq. This is not problematic since tables will be named {appname}_{modelname} so we have, e.g., propagator_hisq and gaugeconfiguration_hisq. Also imports are using the app name from propagator.models import Hisq and from gaugeconfiguration.models import Hisq.
  3. To make this consistent, every model which inherits from base.{parent} must be placed in the app parent. E.g., base.models has the model GaugeConfiguration(Base) and gaugeconfiguration.models has the model Hisq(GaugeConfiguration).

Question @cchang5 : To make it fully consistent, should app names have underscores or not? It seems to me that no underscores are more consistent with table names.

ckoerber commented 5 years ago

This was adjusted by 7ff6175f15b7e7688b0412d2d0c632a950b26719 and previous commits. The guideline is now in the wiki.