5 Things I've Learned From One WordPress Calculator Plugin
Tags: wordpress, beginners
Published: 2019-12-16 16:56:26

I work for the largest online tech magazine in Israel as a full-stack developer. The fun part is that we always try to go the extra mile as part of our agenda. So when one of our partners reached out and said they'd like to implement a salary calculator in our WordPress based website, we said "sure!". They get exposure, our readers get value - everyone's happy. The really fun part? They got the data, and they wanted **me** to build it.

The thing is... I've started playing with software development ever since middle school. Yet, I started doing it professionally only a year and a half ago, when I graduated college - so I'm dealing with a lot of new problems. Therefore, I decided to write this article to help beginners like me with how they approach problems.

### 1. Plan ahead. It will save you more time than you think
The data I got from our clients was given to me in an Excel spreadsheet. Different categories, different titles, different conditions for display - *All in one spreadsheet of one file.* Dealing with Excel files isn't my first priority, so I've started thinking about how should I manage the data in order to easily use it in the plugin. In one of my last projects, I imported data from an external JSON file so I decided to play a bit more with this familiar format.

The problem was the need to rearrange everything in a proper way in order to differentiate the different categories and conditions for a certain salary. So I asked my developers friends [on Twitter](https://twitter.com/OmerLahav/status/1173574852374147073?s=20) and from seriously thinking about creating a 3-dimensional array in JSON, I figured an easier more logical way to arrange all the data. I even wrote part of the JSON file I plan to have in a notebook I have, just to be sure - and writing it manually actually made me find a mistake in the excel file.

### 2. The internet is full of shortcuts. *Use them!*
It will probably be the most obvious part of this article, but nowadays - we have online tools for everything. You don't necessarily have to install an add-on in your local software, nor install something completely new - there's probably something online that does exactly what you want. After I looked for a proper tool on the first two pages of Google, I found this open-source [XLSX-TO-JSON](https://kinoar.github.io/xlsx-to-json/) converter that's hosted on Github. It doesn't look anything fancy or requires any installment in your computer - but it definitely gets the job done.

### 3. Divide and conquer your plugin directory
I've seen two main work methods when it comes to software development. Some developers try to gather all of their code into the least amount of files and folders as possible.

I belong to the group that does the opposite.

I built this calculator as a Wordpress plugin that creates a Wordpress' shortcode of the calculator that I can place wherever I want. The layout I used was:
* **Assets folder** - A folder that contains all CSS, JavaScript and the JSON files (including any related images) of the project.
* **config.php** - A file that contains constant variables relevant to the plugin.
* **scriptsenqueue.php** - A file that enqueues all the CSS & JavaScript files that are relevant to this plugin.
* **main-plugin-file.php** - The main file of the plugins, that contains the relevant comments for a Wordpress plugin, and import all the other files in the folder. In this case, I put the shortcode content in this file, even though I could split it to another file as well.

Why such division is necessary? Even with such a small feature, there might be problems in different places like the shortcode's content, the CSS settings, the JavaScript's logic... No matter what's the problem, you'll know exactly where to find it.

### 4. Accept any small feature as a challenge
In the beginning, the initial request was: "Make us a salary calculator". They haven't told us anything besides they have the data for us, but they want us to develop it for them since it's our website and we're familiar with its infrastructure. I sent them the first draft of how the calculator would be - and I got gazillion other requests in return. From "make it look more like this other calculator", to "add an icon to make it pretty and make it spin!" and even "add a statistics feature to it!" after it was already uploaded to production (I'm not kidding).

Nonetheless, because of this one plugin - I've dealt with CSS' animations, integration to a Google spreadsheet, Wordpress shortcode & plugin creation, and JSON files related functions in jQuery. No matter which assignment you're asked to do - take it, because you might learn from it more than you think.

### 5. Dealing with clients is sometimes just part of the job
Depends on your workplace, you won't always have to deal with clients. Sometimes you will get requirements from your project/product manager, and sometimes you'll have to talk to the clients directly. Talking to someone who's not necessarily technical might be a bit challenging, but that's a skill you should have sooner or later.

Whether you'll begin to work freelance, become a product/project manager or even just a senior developer - having the skill of talking to clients can help you deal better with people, and knowing how such people think can help you define your problems and needs better, and because of that - create better products.

#### Take as many opportunities
Like plenty of other junior developers, I'm familiar with the thirst for developing gigantic stuff. My humble recommendation for any other junior developer - enjoy those small projects. They most definitely will help you in the long term.

**Credit:** And as a living proof for lesson #2 of this article, how do you think I made this article's banner? A small hint:

{% link https://dev.to/christopherkade/introducing-a-banner-generator-for-your-articles-on-dev-353a %}

*What do you guys think? Would you recommend anything differently, or do you have anything else to add for beginners?*