Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12760
| From | Novice <novice@example..com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Designing Interfaces |
| Date | 2012-03-08 00:27 +0000 |
| Organization | Your Company |
| Message-ID | <XnsA00FC7119110Ajpnasty@94.75.214.39> (permalink) |
This is actually a discussion that Lew and I started in the "Aspect Qustions" thread but it is so unwieldy know that I'm pushing it into a new thread. Here's the context so that everyone knows what the subject of discussion is. While this started as sort of a side conversation between Lew and I, as far as I'm concerned, anyone who has something to contribute is more than welcome to jump in on this. Even if you say the same thing as someone else, your wording might be more effective in making me see the point than the way the other person said it. Anyway, here's where we were in the other thread. >>>>> Summary: >>>>> Interface: what to do >>>>> Class: how to do it > ... >>> Give me an example of some unit of functionality you'd like to >>> design, in broad terms, and I'll do just that. >> I think that would be an interesting exercise. Let's do one that I've >> already done myself and that you (probably) haven't. I'm sure I'll >> learn some things by seeing how you approach it. >> I have a project (that regularly undergoes polishing) to produce >> resumes. More specifically, it creates various formats of my own >> resume (and only my own resume.) Each of the resumes I generate >> contains the exact same information obtained from a single file but I >> generate it in several formats: an HTML version, a Java applet, an >> ASCII text version, a PDF version (using iText), and a Word version. >> I also generate supporting files, including a CSS file for the HTML >> version of the resume, and a short PDF containing contact information >> for references. > What are the overall modules? For example: "Obtain resume from single > file", "Export to format X", "Generate references document", ... At the moment, I have a main program that simply generates each document in turn. It's called ResumeFileGenerator. Its constructor gets the resource bundle that drives the creation of the resumes. Each resume format is generated by a separate class and is passed an object that represents the data needed in the resume and the path and file name to be generated by that class. Then, the supporting documents are each generated by their own separate classes. They too are told the path and file name that should be generated but are not passed the resume object since they don't need it. >> The program that generates the resumes and supporting files is >> written in Java. The data file that is parsed to create each format >> of the resume is a Java ResourceBundle of the "list" type. NOw, I'm >> only producing the resumes > Sorry, "list" type? Sorry, that was sloppy shorthanding on my part. I meant the ResourceBundles that are based on ListResourceBundles, as shown at http://docs.oracle.com/javase/tutorial/i18n/resbundle/list.html, versus the "text" and "message" types which are basically properties files. Some of my data consists of arrays like the list of editors I've used and the list of word processing programs I'm familiar with so the simpler property file type resource bundles don't work well for that. >> in English so I should mention that I am open to the possibility of >> creating the resume in additional languages - I have a working >> knowledge of two other (human) languages - so I chose to use a >> Resource Bundle so that I could easily generate resumes in additional >> languages. Otherwise, I'd have probably just used a standard text >> file or more likely a properties file. >> Given the fact that several resumes containing the same data are >> being generated there would seem to be obvious opportunities for >> refactoring and probably at least one interface. This code has gone >> through various permutations but I've used a single interface with a >> single method in my existing code. The code works but I'm not at all >> sure it is designed well. > What interface? What method? It's an interface I created as opposed to one that is in the API. It is called ResumeFileWriter and has one empty method in it called writeResume. It has two parameters, a String that identifies the path and name of the file to be written and a Resume object that refers to the data contained in the Resource Bundle. Each of the classes that writes an actual resume (as opposed to a supporting file) implements it. It's entirely likely that this interface should do a lot more than it currently does. That's why I'm very curious to get your take on this. I've also got an abstract class called ResumeFileCreator. It has four concrete methods: deleteFile, openOutputFile, closeOutputFile and getGeneratedBy (which simply generates a string containing the name of a class and the current date and time which I use to create comments in each of the files that are written). Each of the classes that writes a resume or supporting file subclasses ResumeFileCreator. >> I'd be very curious to get your take on it. I expect that the design >> has major flaws and I'd like to clean those up once I find out what >> they are. >> Does that sound reasonable to you? I'm basically asking you to talk >> me through the way you would design it knowing what I've told you. >> Naturally, you're free to ask as many questions as you like to >> understand what I'm trying to do. > We'll go step by step. Works for me :-) -- Novice
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Designing Interfaces Novice <novice@example..com> - 2012-03-08 00:27 +0000
Re: Designing Interfaces Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-08 08:28 -0400
Re: Designing Interfaces Jeff Higgins <jeff@invalid.invalid> - 2012-03-08 09:11 -0500
Re: Designing Interfaces Jeff Higgins <jeff@invalid.invalid> - 2012-03-08 09:35 -0500
Re: Designing Interfaces Jeff Higgins <jeff@invalid.invalid> - 2012-03-08 19:24 -0500
Re: Designing Interfaces Jeff Higgins <jeff@invalid.invalid> - 2012-03-08 19:36 -0500
Re: Designing Interfaces Novice <novice@example..com> - 2012-03-11 23:29 +0000
csiph-web