I have a simple MVC project. My current packages:
- gui
- controller
- db
- domain
I want to put extra classes which I will use, e.g. md5 hashing, email validator (methods which I will use in more than one class). Where do I put them? I will probably not use them in only one package, but in two or three (not in model for sure). Do I create an extra package, or do I put them in domain as they’re “static” (unchangable)?
What you are looking for is a “utility” package. This may include classes with static utility methods used all over the application. Common utility classes are String operations, Date/Time, etc.
Your validators could be a subclass of the utility package, but personally I would put them in the domain in a higher “common” directory.
Refer to this answer for more details: How should I organize my source tree?
0