mattstibbs / nhspy

Python helper package for NHS-related functions
ISC License
1 stars 1 forks source link

Need a naming convention for classes, methods etc. #1

Open TonyFlury opened 8 years ago

TonyFlury commented 8 years ago

Contributions ideally should have a consistent naming convention and module/class hierarchy.

TonyFlury commented 8 years ago

Proposal - to be written up in a wiki page.

Package name : nhspy (clearly) Module : CUI (for instance) Classes : NHSNumber, Date, Patient Name etc.

Suggest that the class constructor should be able to take a value as stored - so Date will take a datetime.datetime, or a time stamp. Constructor will raise a ValueError Exception if the value is invalid in some way.

Each class will have a : 1) is_valid class method - so that strings (or other values can be tested for validity without trying to create an instance. 2) __format__ special method - which will format the data as per the CUI spec - this will allow using code to simply use "%v".format( value) to format the data according to the CUI data.: using __format__ will allow use of things like field width - padding characters etc etc etc - without repeating data type formatting (we could use something other than %v if needs be).

Other magic methods can be added as required.

Suggest that these classes inherit as appropriate from builtin classes - so that we get comparisons etc for free.