I am currently trying to figure out how to develop a small application. An application is a service in which there are some files as input (excel files or pdf files representing reports from third-party companies), and its output should consist in creating an invoice from various reports. These invoices are then sent by hand to the issuing company. I know how to make an application do what I want, but currently all classes are in the same package, the default package. I would like to change that. So I started to rename classes so that they all fit into the metaphor: "office." These are my current classes and interfaces:
- OfficeDesk (hub like everything)
- Translator (opens pdf and excel files, parses them into String)
- Report (an object representing the contents of a pdf or Excel report file)
- ReportBook (list of all reports)
- BookKeeper (converts the Rows report to reports, adds reports to ReportBook, implements ReadSkill)
ReadSkill (interface, makes BookKeeper convert the string to a report object)
TypeSetter (some common String utilities)
- Typist (converts ReportBook to pdf, uses TypeSetter, implements InvoiceTypingSkill)
- InvoiceTypingSkill (forces Typist to implement methods such as TypeReportTable (), TypeDueDate (), etc.).
- JobAgency (a service that briefly looks at a PDF file to decide which source (reporting company) the pdf file is from, and then provides a specialized BookKeeper (a subclass of the BookKeeper class, fe WeylandCorporationBookKeeper for an accountant who knows how to read reports from Weyland Corporation) or Typist for job)
With this, I have many classes that need to use ReportBook and Report, which I planned to put in the "filingcabinet" package. So now BookKeeper imports filingcabinet. Typical too, etc .... How can I pack this so that the packages are not needed by each other? Or is it really good practice that they use each other? FE
- BookKeeper.writeRecordToBook (ReportRecord Record, BookBook Book)
against
- BookKeeper.writeRecordToBook (String [Object] Record, Vector Book)
I think (1.) is more readable, but makes BookKeeper have a dependency. On the other hand, there is no dependency on (2.), just common java types, but less readable. What is better here? Also, what would you name packages (or should there be only one, with so few classes)
My current packages
- office (classes: OfficeDesk)
- filingcabinet (classes: ReportBook, Report)
- services (classes: JobAgency, Translator, TypeSetter)
- services.bookkeeping (classes: BookKeeper, ReadingSkill, all subclasses of BookKeeper)
- services.typist (classes: Typist, InvoiceTypingSkill, all subclasses of Typist)
I understand that this could have been written with a more concise example, but thanks for reading and for any input / opinion!
java design packages
Karly
source share