General direction

Diez B. Roggisch deets at nospam.web.de
Thu Jan 15 04:08:37 EST 2009


MLT schrieb:
> Hello all: I'm a beginner to Python (and programming altogether), and
> am now looking to create a program of my own.  What I've got in mind
> is a very basic pest control program that would keep track of 1) trap
> findings and 2) pesticides.  My thought is to make each of these
> classes.  Looking at the general outline written below, can anyone
> give general impression about whether I'm somewhat going in the right
> direction or if I need to approach it entirely differently?  Thanks
> for any suggestions or help!

Familiarize yourself with PEP8 for naming and coding-conventions first.


> Class Insect_Trapping attributes:
>  - Unique Name
>  - Location
>  - Type

Depending on what the Type is, you might consider using subclassing here 
instead.

>  - Frequency of Checks?
>  - Next Check Date
> 
> Within Insect_Trapping there are Trap_Count objects
> 
> Trap_Count objects have the following attributes:
>  - Date
>  - Time
>  - Insect A Finds
>  - Insect B Finds
>  - Insect C Finds
>  - Insect A Number
>  - Insect B Number
>  - Insect C Number

Instead of manually coding attributes for all kinds of insects, better 
use a mapping of insect-name to attributes. There are plenty of options 
for that - you could a mapping of name to tuple:

{ "cockroach" : (100, 200),
   "wasp" : (2000, 3000)
}

Or introduce a InsectInfo-class that has finds and numbers as fields:

{ "bee" : InsectInfo(finds=100, number=200) }


> Class Pesticides attributes:
>  - Unique Name
>  - Usage Instructions
> 
> Within Pesticide there are Pesticide_Usage objects
> 
> Pesticide_Usage objects have the following attributes:
>  - Date
>  - Time
>  - Location
>  - Reason for Use
>  - Amt Used


HTH,

Diez



More information about the Python-list mailing list