Hello all, today I’ll discuss my experience of working with an open source library for the very first time.
I won’t delve too much into the details and requirements of this assignment, you can see them at Release 0.1. Keep reading for more information on how I tackled this project.
What I Built
For this assignment, I built a simple web service using Node.js, Express, and an npm package called google-libphonenumber. It’s basically a simplified version of Google’s libphonenumber library, that I used to parse and validate phone numbers in text snippets and text files. My project code in its entirety can be found here. Basically, it supports two types of data requests – to start off, you have to run the project, navigate to the correct url (as is in the github readme file), and then do one of two things – either provide a string containing a phone number inside the url box (which is a get request), or use the file upload url, which will take you to an upload file form, where you can browse and upload a text file from your machine. If you provide a string through the url, it will parse one phone number and display the JSON array output (more numbers will be parsed only is you use a delimiter of ; or ,), and if you upload a text file, it will parse the entire file (with delimiters of ; or , or line breaks).
The Process
Since we were allowed to use any programming language we wanted, I was very confused as to what to use (most assignments I’ve done were to be completed with one specified language, that we were all familiar with). When peers started discussing various frameworks and languages I had not used much before (or at all), I was even more confused. Since some people said they’d like to use Javascript, I thought “oh well, this isn’t too bad, I learned Javascript in web development in 2nd semester, so I can do that”. But no, apparently you had to use Node.js, which I was not familiar with at all. I had installed node.js on my machine some time ago, but had never gotten around to using it. Looks like that had to change.
Thanks to Professor David Humphrey mentioning using node.js with a framework called Express, I was able to learn how to set up a simple web service, and after more research, learned how to incorporate libphonenumber into my project.
Tools, Languages, and Dependencies
As I mentioned above, I used node.js, express, and eventually, multer for handling the upload and data content of text files. I used these tools because they seemed to be the most popular and commonly used tools for this sort of project, and also, upon glancing at my classmates’ repos, I found that many of them were also using these tools at well, so I had to be doing something right.
For testing purposes, I was also introduced to two new dependencies: mocha, and chai. I used these because they were well known, and many of the node.js tutorials I had read included them for testing.
Challenges
Of course, creating a web service in node.js was not an easy task, since it was my first time and I had not been taught the basics by anyone beforehand. Since it’s javascript based, and there’s a ton of tutorials out there on creating web services, I didn’t find it to be that bad. Ironically, the few serious errors I did have, were just syntax or spelling errors. One of these dumb errors happened near the beginning, when I thought I had included google-libphonenumber, but had actually included a slightly different library called libphonenumber-js. After figuring that out, things went well. My next dumb error had to do with file handling – I had named my file as ‘upload’ in my upload.html file, but gave it the name of ‘file’ inside my server code, so the file couldn’t open. Of course, I laughed like a maniac when I figured out that was the error (took me a good two hours at least). Other than those two dumb errors, I didn’t run into any major challenges (inserting a try/catch block fixed most of my errors).
Maintaining vs Contributing
After finishing my code, I had to fix two issues in my peers’ repos. While most of us had posted the same issues, I did find two issues, one regarding parsing phone numbers without text, another regarding returning a unique array of phone numbers. They were easy to fix, because I had already struggled and figured out both issues when implementing my own project. Thus, I would say that contributing to someone else’s repo was more fun, provided you had already solved the same issue in your own code. When you go through an experience yourself, it’s fun to help someone through the same problem. Plus, it was the first time I had created a pull request, so that was nice.
What I Learned
I learned that even though the first glance or reading of an assignment’s instructions may seem terrifying (I had contemplated dropping the course at first), once you actually start to research and read into its specifications, it’s really not that bad. I also learned that I shouldn’t shy away from writing a program in a language I had never learned before, because I might just surprise myself at the end.
What I Want to Learn More About
I noticed that alot of my peers were using tools like routing, as well as Postman for their HTTP requests. I didn’t use such things, and would like to learn of newer technologies to complete this project.
Well, that’s all for this time, thank you for reading.