I am starting to write a Java program and i need your help guys on how make a good design on the program i will be writing. assuming i have a class TaskInfo class TaskInfo { Person person; private TaskHistoryBase TaskHistory[]; } Now my concern is, Person class will be compose of different classes like 1. PersonalInfo 2. ContactInfo 3. BusEmpInfo 4. FamilyInfo How should I design Person class? Can i create the person class that extends the 4 other classes. Is that possible? And what should my Person class in my TaskInfo class should be private or public? Thanks a lot!
Vijayakumar Arya
Ranch Hand
Joined: Jan 27, 2003
Posts: 76
posted
0
Hi, Class design is not a complex thing, it is just the way what we realise the entities are. In you case you say that Person has PersonalInfo, ContactInfo, etc.. these are to be a part of the Person class because it belongs to the entity called Person.
All other will be common information can be grouped in a single class. You just replicate classes as how do you realize the objects.
Thanks,<p>Vijay<p>The Hand that gives, Gathers.
Jay Richards
Ranch Hand
Joined: Jan 16, 2003
Posts: 58
posted
0
Thanks a lot.
Jay Richards
Ranch Hand
Joined: Jan 16, 2003
Posts: 58
posted
0
assuming i have the ff code: class Person{ protected PersonalInfo m_personalInfo; protected ContactInfo m_contactInfo;... } class PersonalInfo{ String m_firstName; String m_lastName;
getFirstName(){ return m_firstName; } } class sample { Person person = new Person().....
how do i call getFirstName() of PersonalInfo in the Person class? assuming there were two the same getFirstName method on both PersonalInfo, ContactInfo class, how to i call the specific method? thanks in advance.
Vijayakumar Arya
Ranch Hand
Joined: Jan 27, 2003
Posts: 76
posted
0
Hi, First you have to get the PersonalInfo of the Person and then you have to get the firstName.
or you can have a method in the Person class itself to get the firstname
I prefer convention 1. [ February 11, 2003: Message edited by: Vijayakumar Arya ]
Jay Richards
Ranch Hand
Joined: Jan 16, 2003
Posts: 58
posted
0
Thanks a lot Vijay. -Cyber01
Hari Gangadharan
Ranch Hand
Joined: Mar 08, 2001
Posts: 73
posted
0
Cyber01, You are not respecting the Javaranch's official policy on displayed name. You have to change your display name to "Firstname Lastname" as described here: http://www.javaranch.com/name.jsp [ February 11, 2003: Message edited by: Hari Gangadharan ]
<B>Hari Gangadharan</B><BR>Unix is user friendly..<BR>but it chooses to whom it is friendly with!
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9001
posted
0
Hi, Jason
Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy. You can change it here.
Thanks! [ February 11, 2003: Message edited by: Marilyn de Queiroz ]
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt