I'm carrying out a task for the university in which we have to develop something like an integrated library management system (if you even call if that way).
To put you into perspective I've to develop a fexible search on the elements of this library. I've five child classes (Video, Audio, Book, NewsPaper and Magazine) they all have their own fields and some others inherited from the parent class (Material).
So in order to do a fexible search through console :
1- I've to ask the user what type of material is he looking for ( Ej : Book )
2- Then I've to display a menu containing class Book fields so the user can choose which fields he wants to use to perform this search.
3-I need a switch for each on of the menu options in order to save those fields values.
4-Finally, once I've collected the values I can call my method( no matter how many fields the user has entered ) which will return true or false ( overriding equals and using EqualsBuilder ) .
5- Implement first three steps five times, one for each child class.
I've thought about using Reflection so I get to paint every menu dynamically using getDeclaredFields and superClass fields. Although after reading about it and its performance I think it's even better to write all those code lines. I've even thought about implementing some kind of dynamic switch...
My question is, is there any way of doing this clean and efficient?
I apologize for my English, tried my best and hope you all can understand my problem. Didn't post any code since I think it's more a concept than code issue.
Aucun commentaire:
Enregistrer un commentaire