11. Clean Packages
Rules of Thumb
1
Hide Internal Logic
package classifier
// ClassifyImage classifies images as "hotdog" or "not hotdog"
func ClassifyImage(image []byte) (imageType string) {
if hasHotdogColors(image) && hasHotdogShape(image) {
return "hotdog"
} else {
return "not hotdog"
}
}
func hasHotdogShape(image []byte) bool {
// internal logic that the application doesn't need to know about
return true
}
func hasHotdogColors(image []byte) bool {
// internal logic that the application doesn't need to know about
return true
}