nus-cs2103-AY1718S1 / forum

Discussion Forum
5 stars 0 forks source link

Export to CSV Command #158

Open AceCentury opened 6 years ago

AceCentury commented 6 years ago

Re-use offer

As per title, this command exports the data of address book into a standard CSV file. It would allow users to mass update the email addresses of their contacts in their preferred email client.

It also provides the flexibility to allow users to easily update the data on other contacts apps on platforms where address book is currently not available (Android, iOS).

To do: Try to reduce coupling and eliminate "hard coding"

generatePersonData is somewhat hard coded with the fields of a Person. This is unlike the constructHeaders function where it will update accordingly as the fields of a Person are updated.

Idea: My initial idea was to store the getter functions of a Person into a list (like in Python). However, this has posed to be a difficult task for me as Java does not allow it to be done so easily.

Any suggestions would be highly appreciated.

Source file for reference: https://github.com/AceCentury/addressbook-level4/blob/21f904103a33314dcf5a1f77179aca24970f3830/src/main/java/seedu/address/logic/commands/ExportCommand.java

DeveloperGuide is not yet updated. Will update soon. This post will be updated with more implementation details as soon as the DG is updated.

You may refer to the branch below for the full list of files accompanying this function (tests, documentation etc.)

Branch: https://github.com/AceCentury/addressbook-level4/tree/Add_Export_Command

huyuanrong commented 6 years ago

Hello @AceCentury , I would like to re-use your code to implement it in our program!

AceCentury commented 6 years ago

Hi @huyuanrong, sure, you may reuse my code.

Do pay close attention to the generatePersonData method. It most likely has to be tweaked to work with your own Person.

Also, be sure to modify your ReadOnlyPerson to include the necessary method for constructHeaders to work. Alternatively, you may opt to hard code your headers into the method or change where it obtains the headers from.

huyuanrong commented 6 years ago

@AceCentury Roger that, thanks for the advice!

huyuanrong commented 6 years ago

@AceCentury Hi, regarding your Sequence and Class diagrams, how do I generate the png from the xml files? I need to edit the Class and Sequence diagrams to make the change from Person class to Place class to be relevant to our application.

Thanks!

EDIT: I found out already, by opening the .xml file in draw.io. Thanks!

AceCentury commented 6 years ago

Hi @huyuanrong, I used the website, draw.io, to do up my diagrams. To open the file for editing, you have to select the import from device option on the website. After that, simply select the XML file.

huyuanrong commented 6 years ago

@AceCentury Hi, I have referenced this issue and credited you in my DeveloperGuide. Thanks a lot!

AceCentury commented 6 years ago

@huyuanrong No problem. You actually did quite a fair bit yourself by tweaking it to suit your own app.

AceCentury commented 6 years ago

@huyuanrong I did a brief glance through of your DG. Be sure to update the sequence diagram and other parts too. Some parts still reference my own app which would look a bit weird in yours.

huyuanrong commented 6 years ago

@AceCentury Thanks for the compliment! Not too sure which parts of yours did I still reference your own app though? Don't mind enlightening me? 😄

AceCentury commented 6 years ago

@huyuanrong

  1. The image of the sequence diagram is missing.

  2. The presence of ReadOnlyPerson. I added a snippet so it's easier for you to locate.

Code is adaptable should new fields be added to ReadOnlyPerson. 

*Cons:*
Additional processing overhead.

Difficult and time-consuming to implement.

The implementation of the method is credited to Ryan Teo and
this issue.