Course:CPSC312-2021/BarbershopScheduler

From UBC Wiki

Title

Authors: Siwei Zhang, Ziqing Yuan

What is the problem?

We created a customer scheduler for barber shops in Haskell language. The users will be able to choose their barbers, their preferred date and time, or look for available slots.

What is the something extra?

  • We implemented real-time Date data structures to make this application more feasible in real life.
  • We created custom time and slot data structures.
  • We implemented functions to read data and save data to/from csv files.
  • Also implemented functions to give suggestions (finds the nearest available time of chosen barber, check if other barber is available at the chosen time) when user's preferred time is unavailable.

What did we learn from doing this?

We learned that Haskell is a language that values are unmutated, so we always create new values in the functions instead of changing them. We pass the values in the parameters of functions instead of saving them outside the functions.

High-order functions are very useful in searching for data. In the program, we use map(), filter() to get the results we want and they make the logic of code cleaner.

A scheduler is often implemented use object oriented programming like Java. but our object shows that functional programming is also works for this program. Since we created custom Time and TimeSlot data type, it limits the format and range of data, and compiler of functional language is smart so it minimizes the problems that would arise during saving/reading or searching data.

The user interface is hard to design using functional programming, while our scheduler is high rely on the interation between user and what we shown in terminal. We tried to overcome this by separated the IO actions different blocks in charge of different stages of the program. The data carried information which need to be interpret are designed threaded through all blocks. Although our design for IO actions are like the structure of functions, but it only uses the information passed by other testable function rather interpret data themselves. That makes our function robust, and easy to debug or extend.

One improvement that could be make in the future is abstract this babershop specific scheduler to a general scheduler while split specific info of baber shop to another hs file (As a scheduler often in type of PickDate -> PickPerson -> PickTime -> CheckConflict -> Reschedule).

However, although our project shows the possibility for design a schedule using functional programming. Object oriented programming could still be more suitable for some real world program like our project. It will be easier for us to add more features and interactions using object oriented programming.

Links to code etc

https://github.com/ezzllyzz/barbershopscheduler