Month: November 2018

The question of tradeoff in software, business, and life

Published on: 15.11.2018

In software development, it is common to have discussions about what technology is better or the best.

Those discussions look like a wise discussion for beginners, looking for a perfect solution, the holy grail.

But they are useless because there is no perfect solution, the much more important question to answer is what tradeoffs are you making and why?

Why tradeoffs are necessary?

In any system, if you want to increase one aspect of the system that has to come at the expense of some other aspect.

Let us take the car for example.

I am taking the car as an example because I suppose it is easy to understand.

If you want to make a car acceleration faster, you have to make it lighter and fuel consumption will go up.

So, to increase acceleration you have to decrease weight and fuel efficiency.

This is a simplified example, there are many imperfections, but I hope that reader can get the point.

Basically, you have to do tradeoff.

Back to the discussion on tradeoffs in software development

When you add business aspect into considerations, it is even more complicated.

Things that make sense from a technical standpoint, are a disaster for business and vice versa.

The hard thing about a tradeoff between business and technology is it is almost impossible to have one person who can understand just one side completely so what to say about both at the same time.

Today software systems are so complicated that it is common that there is no single person who understands everything.

That is why REST API is popular, but that is the discussion for another day.

Concrete software example

I have one personal program, that I use every day, it is responsible for saving me 1000$ on average per year, so I do have the real monetary use of it.

And SQLite DB is the main part of it, and I do not ever use indexes in it (no cost benefit from it).

I know that SQLite for my use case, from point of speed, is not the best option.

But I took SQLite because it was fast to start, backups are just copying one file and I am running SQL queries once per day while I am sleeping.

Currently, an average time for all SQL queries are around 30 seconds, and as DB file gets larger query time will also increase.

Even if it gets to 1 hour (what I am not expecting even in the next 100 years), that would be fine for my use cases.

My deployment platform is shared hosting with the flat monthly bill so increased CPU time is also not a problem from me, altho if I used platform with serverless billing per CPU time it could be.

Conclusion

Know what tradeoffs are you making and even more important is why.

Introducing PyAutoGUI

Published on: 01.11.2018

I found out about PyAutoGUI Python packet from Automate the Boring Stuff with Python book.

With PyAutoGUI you can automate GUI interaction on your computer.

PyAutoGUI is working on Windows, OSX and Linux, altho I have used it only on Windows.

Most GUI automation can be done just by automating mouse movements and keyboard input and PyAutoGUI supports it.

There are also functions for providing message boxes, saving the screenshot and finding an element from the image on the screen.

Personally, I have found PyAutoGUI useful, for automating some of my workflows.

To be honest, I use it for 45 minutes of work every month (I know this is not much), but I have found that if I manually have to do same interactions for 45 minutes it is really killing my soul, so I decide just to automate it.

If you want to automate web page interaction use Selenium, because with Selenium you can access elements on a web page independent of their position on the screen.

Because with PyAutoGUI you can just move the mouse to specific coordinates, that means if the resolution or layout of GUI has been changed, you need to update coordinates in your code.

Keep all coordinate in your code as constant in one place, so that you do not need to change them all over your code when change is needed.

This theoretically could be avoided if you use images as reference for finding elements on your GUI, but you will have the same problem if the appearance of the elements is changed, but then instead of changing coordinate in the code you have to change all reference images, what is more work.

My personal preference is to use hardcoded coordinated instead of images as the reference.

Using Selenium has also become popular for scraping pieces of information from web pages, but better is to use specialized framework for scraping like Scrapy, because of additional features like caching HTTP responses (quite a time saver in development).