Contributing to Open Source Phase at Encora Apprenticeship — Week 5

Ximena Sandoval
4 min readJan 17, 2022
Photo by Tianyi Ma on Unsplash

This post is part of a weekly assignment at Encora Apprentice and in this series, I’ll share my journey as a Software Engineer Apprentice. I hope these stories help and motivate others on their tech journey.

This week at Encora

With the phase ending just around the corner I worked on a new issue, keep researching about Bundler and how to solve the issue I picked, and concepts about object-oriented programming. Come take a look at the final week of the contributing to open-source phase!

Contributing to Open Source

This week I got to work on ml5-library, a library for machine learning for Javascript. The issue I worked on stated the need for a more informative error when a dataset only had one label for all the data. For that, I keep track of the labels in the data using a Map object, and if the number of keys wasn’t greater than 1, I would return an error telling the user about the number of labels. I also got to write some tests using Jasmine, to make sure that the error was occurring when it was needed.

For the Bundler issue, I make a mistake when comparing the errors in Ruby and the approach I mentioned last week would not retry on every error, even the network ones, but a maintainer suggested keeping an allowlist and checking if the error was part of that list to try or return. While researching I came across that this may be one of the best ways to handle network errors in Ruby, since there isn’t a class to encapsulate all these errors. Another approach I took was to check the error and see if it belong to the allowlist. In the end, I got suggested by the maintainer to change the Retry class and instead of passing the errors that can’t be retried to instead pass the errors that can be retried and stop for all the other ones.

Object-oriented programming

I also got to learn about interfaces and abstract classes in Java (kudos to my mentor!), and the main differences between them, as well as the difference between programming languages (where they don’t implement these concepts as such). Both abstract classes and interfaces cannot be instantiated, which means we cannot create an object from them.

Interfaces

They define behavior, what methods need to be implemented. They allow us to decouple behavior and consist of just abstract methods (they can’t have a body).

interface AnimalBehaviour {
void move();
void eat();
}
/**
Notice the methods have no body!
**/

Another characteristic of interfaces is that we can have an object that implements multiple interfaces.

Abstract classes

Abstract classes can have both abstract and nonabstract methods. One characteristic of abstract classes is that subclasses cannot extend multiple classes (whether they are abstract or not).

abstract class Animal {
public void eat() {
System.out.println(""This animal is eating!);
}

public abstract void move();
}
/**
Notice we can have both abstract and nonabstract methods
**/

Design patterns

As I mentioned last week, I started to read about design patterns. This week I got to read about the observer pattern, which defines a mechanism for objects that subscribe to another object of interest. This way, once the Publisher object has an update, it can notify only its Subscribers, and the Subscribers won’t have to waste resources since they don’t need to constantly check on the Publisher object state.

Image from Refactoring Guru
Image from Refactoring Guru

Final thoughts

As this phase is ending, I want to do a recap of some things a learned this month, in particular, to read code from other people and understand it, which can be a complex task to do when the project is big, but can be rewarding and helps us learn about more approaches to solve problems.

I also learned a lot about Ruby , Javascript, and how to set up debugging environment for both of these languages.

I also want to mention object-oriented programming principles and concepts that I got to visit in this phase, like abstract classes, interphases, the SOLID principles, etc. I want to keep working on these concepts to apply them when needed.

Finally, I want to give big kudos to my mentors, for helping me in not only this phase but throughout the program! And also the staff for the resources and help, as well as for allowing us to push us to be better software engineers!

--

--

Ximena Sandoval

Cloud Platform Engineer at Encora. Currently learning about CI/CD, Kubernetes and watching Studio Ghibli movies✨