muffin
muffin

Reputation: 1486

How to name my packages

I worked with object oriented programming for a while now and I also used packages a few times.

But I really wonder if there is an easy way to choose the package names? I know the MVC-Pattern, which is fine, but doesn't really apply on all my classes. For example, I have a custom JButton Class, which is a model and a view at the same time... Where should I put such classes?

Are there "golden rules" for package names or are there other patterns? How do you usually name your packages?

Upvotes: 0

Views: 940

Answers (2)

davioooh
davioooh

Reputation: 24706

I suggest you to follow this article for general guidelines about packages naming conventions.

In you specific case, if you're using MVC pattern you should organize your classes among the different roles of the pattern. So, for example:

com.yourproject.views
com.yourproject.controller
com.yourproject.model

NOTE If you have a class that is "model and a view at the same time", I suppose you have some design issue. Try to analyze the problem more carefully.

Upvotes: 3

podongfeng
podongfeng

Reputation: 46

First of all, name your package by classification of your class. In addition, you can follow the famous open source project, such as apache.

Upvotes: 1

Related Questions