• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Which Design Pattern to use for this requirement  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Requirements -
* Sort/segregate students on the basis of various criterias.
* Right now, we will be sorting on the basis of students age but in future different kind of sorting requirements may come.
* Future requirements can be any like sort students on the basis of their father’s age, segregate students on the basis of grades they got etc.
* For all the sorting/segregation types, list of students objects will be provided.
* Create a reusable framework which can be used for age based sorting & future sorting requirements which may come.
 
Marshal
Posts: 61766
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

We don't supply complete solutions, but you doubtless know about sorting with Comparators. You can use the decorator pattern to create comparators using multiple criteria, and you might use a strategy pattern to decide which Comparator to use just now. I presume you are familiar with the theory of sorting; I like this part of the Java™ Tutorials.
 
Tony Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell for your kind help. I have done some research on both the suggested patterns & looks like Decorator pattern will fit in my requirements.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!