0

What would be the sample class design of Outlook like meeting scheduler?

This should help you to schedule a meeting with the rest of the invitees and book a room as we do in offices.

Few things I omit purposely,i.e checking meeting room availability, person availability at looking his/her calendar.

Here is my approach to this. I would love to know what improvements can be there and mistakes have done in the process.

class Person{
   String name;
   Email emailId;
}

class Organizer{

   Person organizer;   //using composite here

   public void Organizer(Person p){
      this.organizer = p;
   }

   private boolean scheduleMeeting(){

      Meeting m = Meeting.getInstance();
      sendInvites(m);

   }
   private void sendInvites(Meeting m){
      for(Person p : m.inviteesList){
        send(p.emailId, m);
      }          
   }

}

class Meeting{

    private String agenda;
    private String bodyMessage;
    private String location;
    private TimeFrame time;
    private ArrayList<Parent> inviteesList;

    private Meeting(){}

    public static Meeting getInstance(){

        Meeting meet = new Meeting();

        agenda = addLocation();
        bodyMessage = addBody();
        location = addLocation();
        time = addTime();
        addInvitees();
        return meet;
    }



}

class TimeFrame{
    Time startTime;
    Time endTime;
}

Edit - Update on the above https://codeshare.io/5e4vNx

Any help on this would be appreciated.

Atiq
  • 490
  • 11
  • 28

1 Answers1

-1

Despite the oft-cited "favour composition over inheritance", Organizer is a valid extension of the Person class, provided it has additional responsibilites not fulfilled by the Person class. However, it is not its responsibility to create meetings and to send invites; that is the responsibility of a Scheduler.

Also, you might not need a separate Organizer class because it could simply be the role played on the Person side of a Meeting--Person relationship, as below.

       *      [organizer] 1
Meeting -----------------> Person
   |                          ^ * 
   |                          | [invitees]
   |                          | 
   +--------------------------+

Now, this is a nit-pick: I think Period is a better name than TimeFrame.

Also, I like your use of an abstract data type Email instead of a simple String; it helps enforce strict typing.

Without knowing the requirements of your system, I would go with something like the following.

class EmailAddress {
    String value;

    public EmailAddress(String value) {
        // TODO validate email address here
        this.value = value;
    }

    public String get() {
        return value;
    }
}

class Person {
    String name;
    EmailAddress emailAddress;

    public Person(String name, EmailAddress emailAddress) {
        this.name = name;
        this.emailAddress = emailAddress;
    }
}

class Meeting {
    Person organizer;
    Person[] invitees;
    Period period;
    String description;

    public Meeting(Person organizer, Person[] invitees, Period period, String description) {
        this.organizer = organizer;
        this.invitees = invitees;
        this.period = period;
        this.description = description;
    }
}

class Period {
    Date start;
    Date end;

    public Period(Date start, Date end) {
        this.start = start;
        this.end = end;
    }
}

class SchedulerFacade {
    public Meeting schedule(EmailAddress organizerEmailAddress, EmailAddress[] inviteesEmailAddresses, Period period, String description) {
        // TODO validate organizer and invitees
        // TODO create Person instances for organizer and invitees
        // TODO check for schedule conflict, etc.
        Meeting meeting = new Meeting(organizer, invitees, period, description);
        // TODO save meeting
        return meeting
    } 
}
RWRkeSBZ
  • 723
  • 4
  • 11