Federer
Federer

Reputation: 34715

Naming Conventions for Methods / Classes / Packages

What naming conventions do you use for everyday code? I'm pondering this because I currently have a project in Python that contains 3 packages, each with a unique purpose. Now, I've been putting general-purpose, 'utility' methods into the first package I created for the project, however I'm contemplating moving these methods to a separate package. The question is what would I call it? Utility, Collection, Assorted?

Is there any standard naming conventions you swear by, and if so can you please provide links? I'm aware each language has it's own naming conventions, however is there any particular one that you find the most useful, that you'd recommend I'd start using?

Upvotes: 1

Views: 291

Answers (2)

Cory Petosky
Cory Petosky

Reputation: 12646

In general, you should follow the naming convention of the language you're using. It doesn't matter if you like or prefer the standards of another language. Consistency within the context of the language helps make your code more readable, maintainable, and usable by others. In Python, that means you use PEP 8.

Using a personal example:

In Python, I'd call the package "utils" -- or if I intended on redistribution, "coryutils" or something similar to avoid namespace collisions.

In Java or ActionScript, I'd call the package "net.petosky.utils", regardless of whether I intended on redistribution or not.

Upvotes: 1

Jonathan Feinberg
Jonathan Feinberg

Reputation: 45324

Unless you have some good reason not to, you should follow the guidelines presented in PEP 8. See, in particular, "Prescriptive: Naming Conventions".

Upvotes: 0

Related Questions