Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Why not just read the values from the text file at run time? Commented Aug 18, 2014 at 4:19
  • @WinstonEwert While I'd have to actually run some time checks, I'm assuming the overhead from the IO every time would be more than having some extra classes. It is an option though. Commented Aug 18, 2014 at 4:40
  • You'd only need to read the data file in once at the beginning of the program and store the data somewhere. IO of reading a class of files and reading your text file should be pretty similar. Commented Aug 18, 2014 at 4:42
  • 1
    What you have just described are instances of a class. Not different classes. Should I create separate subclasses for each employee that has a different name. e.g. EmployeeBob, EmployeeTom, EmployeeAlice...etc? Commented Aug 18, 2014 at 18:50
  • 1
    @Danno:I know. That is exactly what my example showed. I only changed the domain in order to make it readily apparent how absurd the subclass idea is. Choice 1: employee1 = new Employee("Bob", "Smith"); Choice 2: employee2 = new EmployeeBobSmith(); employee3 = new EmployeeTomJones(); employee4 = new Employee AliceBrown(). That is exactly the question you are asking and at least to me, I can come up with tons of problems with choice 2. In particular, what happens when you add another attribute that is worthy of being part of the class name? Commented Aug 19, 2014 at 17:36