This essay does not describe an existing computer program, just one that should exist. This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. I have no source, object, specifications, file layouts or anything else useful to implementing this project.
This project outline is not like the artificial, tidy little problems you are spoon-fed in school, when all the facts you need are included, nothing extraneous is mentioned, the answer is fully specified, along with hints to nudge you toward a single expected canonical solution. This project is much more like the real world of messy problems where it is up to you to fully the define the end point, or a series of ever more difficult versions of this project, and research the information yourself to solve them.
Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; or give you any additional materials. I have too many other projects of my own.
Though I am a programmer, I don’t do people’s homework for them. That just robs them of an education.
You have my full permission to implement this project in any way you please and to keep all the profits from your endeavour.
Please do not email me about this project without reading the disclaimer above.This is one of the amanuensis projects. When you want to sort an array or Vector you need to write a collating routine that sorts by major key, then if there is a tie, it looks at the next key etc. It is quite a bit of error-prone work to write a set of comparator routines, about three lines of code per field. We need a way to generate them on the fly, just from a list of field names and an ascending/descending boolean for each field.
See SORT for some sample Java Comparator code that you might like to generate. Ideally, you would generate byte codes, which could then be interpreted or JITed. Sorts spend a considerable amount of time in the compare routines. This technique would be much faster than any general purpose compare routine that determines the major and minor keys every time it compares.
You feed in the field names, their types, and whether you want ascending or descending on each field and it stomps out the Java source for the corresponding Comparator or Comparable This source then has to be compiled before use.
Ideally you should generate the byte codes directly, then the file would not need compilation. You could crank the Comparators out dynamically while the program was running based on any fields in any combination you desired.
To do that you need reflection to discover the types and field names. Unfortunately private field names are not accesesible to the inner class you might generate. You would have to limit sort fields to non-private fields or accessor methods.
I have already implemented a simple version this project without reflection. You can see the Applet and the source code for ComparatorCutter.
available on the web at:
optional Replicator mirror
Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : . If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I can’t very well fix erroneous or ambiguous text if I can’t find it.
Your face IP:[18.104.22.168]
|Feedback||You are visitor number 5,920.|