I have to maintain the software I wrote 8 years ago

There is no keywords or meaning in this post, I only write it for reflection.

I am working with the same company which I worked for 8 years ago, despite I left it 2 years in between. Recently, I was told the GM want to abandon using WebSphere as a j2EE container and want to estimate the effort to move the application to a freeware.

8 years ago I wrote that simple Java Servlet application and they decided to use a fully fledged WebSphere server as a container. I thought it was overpowering for such a simple task but who was I to say no when management had decided to dump money to IBM just for security in mind? It was a simple application which display a pdf mobile phone bill upon any request.

Well, it replaced HP’s solution

The web application was intended as a contingency/backup for HP’s solution, it turned out that HP’s software had performance problem and they couldn’t fix it. My web application became the regular player on the field. It work as intended for 8 years.

Being an experienced programmer

Although it is a simple application that TomCat could easily power, but we still have to go through everything formally. That mean drafting a fallback plan and a deployment plan and probably parallel run.

This is the burden of being an experienced programmer. If I have been younger, sure I would want to boot it up with tomcat right away, but it’s now, not 8 years ago. Management loves it when you say you have a plan, and a fallback plan.

Project process – Things got into shape, and I finally know to appreciate REST APIs

Language Translator from IBM Cloud

Language Translator

The project has finally gotten into shape! Last time I wrote that I wanted to include a translation by google translate in my web application, it turned out Google charge quite a bit for the Google Translate API, so I turned for other free service and found Language Translator from IBM Cloud. It allows free translator of 1,000,000 characters per month and is enough for development purpose.

latest screenshot of the web application

Product Layout

Now this web application is divided into four sections ( excluding the button ):

Left-Top section: Source text provided by user

Middle Top section: A tokenized version of the source text by part-of-speech. Access by a REST API written with Flask.

Rightmost section: A list of words translated by a free Japanese-English dictionary JMdict.

Lower section: A large textarea which hold the translation result by IBM Cloud Language Translator.

Product Functions

  • Tokenize Japanese text according to its part-of-speech, which are estimate by MeCab
  • If mouse over a tokenized word, the tooltip would show part-of-speech
  • Provide dictionary result of the words
  • Provide real translation by translation service

 

Now I am not going to make it prettier just for the sake of it. I have to ready the production environment and how to ship it. Also I have to wrap my REST API with HTTPs and make sure no one could access it except my server.

To be honest, the Language Translator API sucks

IBM Cloud provided four ways to access its Language Translator, they are: curl, Node, Java and Python. Ideally I would have chosen the Python way to access it. However, it requires Visual C++ Framework 14.0 and I would have to download Gigabytes of data just to install the Visual Studio Community 2017 which contains Visual C++ compiler. To be honest, I hate Microsoft stuff with passion because of the horrible experience with coding Visual Basic.

Since it is a Python project, I don’t want to mix it with Java or NodeJS. The last option is an ugly Curl API like this:

curl --user apikey:{apikey_value} --request POST --header "Content-Type: application/json" --data "{\"text\": [\"Hello, world!\", \"How are you?\"], \"model_id\":\"en-es\"}" https://gateway.watsonplatform.net/language-translator/api/v3/translate?version=2018-05-01

It has to use slashes ( ‘\’ ) to escape the double quotes ( ” ) in order to send a JSON over curl data. And in order to use this in a Python Program, not only do I have to Use Python Subprocess to call external program “curl”, I have to escape the slashes one more time with a double slash ( \\\ )

“curl –user apikey:XXXXXXXXXXXXXXXXXXXXXXXXXXXX –request POST –header \”Content-Type: application/json; charset=UTF-8\” –data \”{\\\”text\\\”:[\\\”” + text +”\\\”],\\\”model_id\\\”:\\\”ja-en\\\”}\” \”https://gateway-syd.watsonplatform.net/language-translator/api/v3/translate?version=2018-05-01\””

 

Man this is ugly, but it comes with free service. Now I finally understand why REST API is a thing. You don’t need to install anything, you just send a request over HTTP and it magically return something to you!

Project progress – Added access to dictionary and new problem

Screenshot at the prototype

What were done:

  • I have added usage of JMdict in my website. JMDict is an opensource Japanese-English dictionary.
  • Functionality to tokenize Japanese text, copy the text and paste the result to the original “right” box.
  • Added an extra column to the far-right which shows some words definitions, with help of JMdict.

What I want to do:

  • ┬áMake the dictionary translation more accurate
  • Add an extra area down there which provide a translation result using Google Translate API.

Problem:

Since I am not familiar with frontend/html/css stuff, I don’t know how to fit an extra box in that area because that area was occupied already although it looks empty. The column in the far right is in the same flex group with the other two box, since it need extra height to display stuff, the whole flex box stretched and occupied the empty space below.

 

 

Project progress – How to synchronize two development machines

Sample screenshot, the result has a space inserted between words

 

Screenshot of the Backend API when it was called.

I have some progress on the project but I have delayed because of 1) busy work, 2) The incessant rain in July and August, 3) I don’t want to manually synchronize two copies on my notebook and my home machine, which are on different OS.

I figured out how to use React and put some UI on the web page. Now there is a button which would call a HTTP REST API , take the input from left textarea, that put the result to the right textarea.

Problem: Perform development on two separate machine ( Windows and Linux ), without the need to manually copy and compile program

Thoughts:
– [Done] First, put Frontend code on dropbox, because it’s just html/js with library of React, semantic UI
– [Problem solved] There might be problem with backend because it’s development used Windows python/virtualenv, Pip, and Flask

– [Done] I am going to put it on github and sync it with git push and git pull
– Also I want to set a Git Hook which trigger a git pull from my other machine. Since it involve embedding a username password, I would do it later.