简体   繁体   中英

how to organize interfaces and classes

I know this question has been asked and answered many times, but I am still asking the same question again...

I have started working on a travelling application and for which currently I am working on creating on the creation of the underlying DAO so I am planning to create a generic DAO, its implementation and again an interface for each entity class.

My query is what is the best way to organise all these interfaces as well as their Implementation.

Thanks in advance

If I understand the question correctly your looking for suggestions on organising your packages?

I'd split then between. com.yyy.zzzz.dao.interfaces and com.yyy.zzzz.dao.impl

You're the only one who can take decisions on how your application should be organized. You can, of course, follow some recommandations such as the Java Naming Convention for packages, or even try to split your packages for each tier implied in your application; but in the end, you have to choose for yourself.

@Kevin D's solution is correct, you could use the com.company.project.dao.interfaces (I wouldn't use interfaces as it's a plural and I avoid plural in package names, but again it depends on you) and com.company.project.dao.impl or you could use packages to split different implementations. It's as you want. And no one should tell you how to split your own application (except your team).

The only (but still facultative) rule I would tell you to follow is "Have coherent names".
That means choose your project convention, but stick to it, and of course the names you choose for your packages (but it also applies on classes, variables) must represent their content (but I suppose this is common sense).

On another note, I don't know the context of your work, but you should really read Adam bien's Weblog , you'll see some articles on best practices regarding DAO and "default implementation", maybe it will concern your project.


Resources :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM