abiatarfestus | May 5, 2021, 7:29 p.m.
I’ve been watching lots of tutorials on Python programming for a while now. But last week I decided to step it up by working on an application as a practice project. So with different ideas on my mind, I settled on a multilingual dictionary application. I organised my thoughts and decided that the dictionary app should have the following features: take individual words or terms of English and Oshindonga and save them in a database; accept definitions and examples of usage in both languages; return definitions and examples of searched words; allow modification and deletion of words and definitions.
Because the saying goes, Python is easy to read and relatively easy to learn compared to other programming languages. Having tried Java and C# first, I tend to agree that Python is more approachable. I started checking out programming languages because of my curiosity about what really happens behind the scenes of apps. The experience is fascinating, and while learning this is a hobby, I really hope to creating something useful out of it. The benefit I’ve reaped out of it so far is that it helped me understand VBA Macros, and I’ve been able to write useful macros in Excel at work.
The idea was kind of lofty for a learning purpose, but I braced myself for the task anyway. But to implement it, in addition to Python in general, I also needed to learn two other new skills, features…or whatever: SQL and Tkinter. SQL is the language used to communicate with a database, while Tkinter is a Python package for programming a graphical user interface (GUI) of an application. The database management system I chose to use for this project is SQLite, so I had to learn SQL in the context of SQLite (sqlite3 in Python).
I’ve learnt that with this kind of project, it’s always best to thoroughly plan it out (design) before starting coding away. But I suck at planning and designing. I did some rough designs, though. These included database design (design of tables) and the GUI design. Even though the actual implementations of some parts differs to an extent from the designs, the designs were well worth it.
The database design includes four tables: one for English words, another for Oshindonga words and two for noun and verb definitions (each part of speech should have its own table in the current design). The GUI design includes six windows: the main window, and five others for adding words, definitions and deleting the same.
So with some rough design ticked off, it was time to get my hands dirty with some code. It took me roughly two weeks to accomplish what I have thus far, which you can see in this video here. It was a process of lots of reading, video-watching, and implementing what I learnt. I always found satisfaction in successfully implementing what I’d panned. But I wasn’t spared from the pain of seeing things not working out and struggling to figure out where the problem was.
For my coding I use Visul Studo Code (VSCode), which I find quite convenient to use compared to, say, PyCharm and others that I’ve tried. At the time of writing this (before code refactoring) my code base stands at 1074 lines of code. The project that I’m working on is publicly available at my Github repository, which can be accessed here, and it’s updated every time I make changes. I’d appreciate any comments, suggestions on the code.
Obviously the project is far from being done. Assuming that I maintain interest in the project, here’s what I wish to do next: The next step should be code refactorig, but before that I want to learn more about unit testing and write some tests before I start refactoring (for debugging now, I rely on print statements, but I understand unit tests are much more robust); this should then be followed by refactoring, during which I also want to learn more about writing classes (I haven’t written any class for the project, just a bunch of functions, so I want to look at the usability and possibility of writing some classes for this project).
The bigger idea is to implement this project as a web application, using Django framework and PostgreSQL, where the dictionary will be built by any registered user. The windows application will then be streamlined to be what it should be, just a normal dictionary app for searching definitions. So assuming the interest is maintained, this is what is planned going forward.
PS: By the way, the project really took all my time after work, causing the neglecting of my novel (The Dilemma, previously known as Slave of the Law) in the process. I hope my next article will be on the novel. Until then, peace!