Yegor Bugayenko's Blog, page 18
October 16, 2017
Lazy Loading and Caching via Sticky Cactoos Primitives
You obviously know what lazy loading is, right? And you no doubt know about caching. To my knowledge, there is no elegant way in Java to implement either of them. Here is what I found out for myself with the help of Cactoos primitives.
[image error]Reality (2012) by Matteo GarroneLet's say we need an object that will encrypt some text. Speaking in a more object-oriented way, it will encapsulate the text and become its encrypted form. Here is how we will use it (let's create tests first):
interfa...October 9, 2017
Streams vs. Decorators
The Streams API was introduced in Java 8, together with lambda expressions, just a few years ago. I, as a disciplined Java adept, tried to use this new feature in a few of my projects, for example here and here. I didn't really like it and went back to good old decorators. Moreover, I created Cactoos, a library of decorators, to replace Guava, which is not so good in so many places.
[image error]La Haine (1995) by Mathieu KassovitzHere is a primitive example. Let's say we have a collection...
October 2, 2017
Java 9: The Good, The Bad, and Private Interface Methods
Java 9 was released a few weeks ago. Check the release notes, they include many interesting features. However, I think that not everything is as good as Oracle and Java adepts seem to picture it. I see three trends in the Java world, which are good, bad, and ugly, respectively. Let's start with the good one.
[image error]Birdman (2014) by Alejandro G. I����rritu The PlatformThe first trend is an obvious improvement of the platform that compiles Java, packages JARs, and runs the bytecode. It definite...
September 25, 2017
ThreeCopies.com���Server-Side Data Backup Service
I have a number of data resources which exist in one place only and which I don't really want to lose. For example, I have a hosted PHP website, and a MySQL database hosted at the same place. I also have a NoSQL database at Amazon DynamoDB, a PostgreSQL database at Heroku, and also... Well, there are many of them. How to back them up was always a question for me.
[image error]The most straightforward way is to rent a cheap $15/mo server (or use an existing one) and configure Cron to run a custom ba...
September 18, 2017
What Motivates Me as a Programmer
I wrote a number of sarcastic articles about management and motivation, where some traditional and very popular practices were criticized. Now I've decided to think it all over and summarize what actually motivates me as a programmer when I'm working for someone else. Let's say you hire me tomorrow as a Java coder and ask "What do you want us to do for you so that you will be most productive?" This would be my wish list.
[image error]300 (2006) by Zack SnyderThe list is in no parti...
September 11, 2017
Yet Another Evil Suffix For Object Names: Client
Some time ago we were talking about "-ER" suffixes in object and class names. We agreed that they were evil and must be avoided if we want our code to be truly object-oriented and our objects to be objects instead of collections of procedures. Now I'm ready to introduce a new evil suffix: Client.
Let me give an example first. This is what an object with such a suffix may look like (it's a pseudo-code version of the AmazonS3Client from AWS Java SDK):
class AmazonS3Client { c...September 4, 2017
ReHTTP.net���HTTP Repeater
I faced a problem a few weeks ago with 0pdd.com, one of my web apps that is supposed to receive HTTP requests (known as webhooks) from GitHub: sometimes the app is down, GitHub gets an HTTP error, and never sends the request again. The request simply gets lost. There is absolutely no way to receive it again once the app is back up. I realized that I needed a service mesh between GitHub and my web app, to accept HTTP requests and repeat them later if they can't be delivered immediately.
...August 28, 2017
XCOP ��� XML Style Checker
One of the biggest advantages of XML versus many other data formats is that it is human-readable. Well, to some extent, you may say. Indeed, a badly formatted XML document may be rather difficult to digest. I'm not talking about XML validity now, but about its formatting style. Just like we format our Java/Ruby/Python nicely and then check their "prettiness" with static analyzers, we can also check our XML documents. Six years ago I asked the StackOverflow community for such a t...
August 21, 2017
To Be Nice or Not to Be Nice?
I stumbled upon this two-year-old article Why It's Safe for Founders to Be Nice, written by Paul Graham (a co-founder or Y Combinator), whom I honestly respect, and I decided to explain why I disagree. Not that I think we shouldn't be nice. Not at all. But I do think that "being nice" is not a solution for organizational, management, marketing, sales, or business development problems. Moreover, in most cases it is actually not safe for founders to be nice.
[image error]Scarecrow (1973)...August 14, 2017
Bitcoin Is Not a Pyramid. Coinbase��Is.
In September 2016 I paid Coinbase $1,222 for two BTCs, $611 each. Seven months later, in April 2017, they paid me back $2,490, which was $1,245 for each BTC. My profit before tax was $1,268, over 100% of the investment, in just seven months. Moreover, if I had waited until today, I would have made $6,800 profit instead. Actually, I still have a few BTCs in my Coinbase account and I can make that 750% profit, if I sell now. Should I? The BTC price is over $4,000. Will it go up? Or down? What w...


