A Tale of a Careless Store Owner

Totally not an anti-pattern of well-written micro-services.

Once upon a time in a faraway kingdom, there was a tiny convenience store. It was small but very popular among the locals especially because of the apples. This store had to offer the finest, the biggest and the sweetest apples in town.

Customers came in long queues, and the store owner filled up their baskets with fresh apples all day long. Life couldn’t be any happier. Except that the store owner liked to sleep very much. He didn’t like it when a trader was knocking on his door early in the morning.

“Get-up sir, I brought the apple” – the trader said.
“Why can’t you come later when all my other suppliers do?” – the store owner replied.
“I have to travel to the farthest corners of the kingdom, I need to be on my way as soon as I can” – the merchant persisted.
“Eh, I give you the key to the store. Take it to the blacksmith he will make a copy for you” – closed the debate the owner.

For the time being, everybody was happy. The store owner could sleep longer, and the trader could unload his carriages any time he wished.
“What could possibly go wrong?!”
“Everybody here has the best of intentions.”
“What a fine solution!” – the store owner gave himself a pat on the back.

Months passed by, and life was thrilling. The kingdom was expanding, faraway lands have been conquered by the king. It was no longer just apples on the shelves. The early morning trader on his way back brought oranges, bananas, papayas, and much more. While the owner was asleep, he opened the storehouse again and unloaded the fruits all over the place. He mixed apples with oranges, grapes with bananas and so on.

“He really does create a mess” – the owner muttered.
“Ah, nevermind” – he continued.
“My dear customers should pick what they need or better cook a mixed fruit pie.” – concluded the debate with himself.

Life wasn’t as good as before, but still better than at most places. There was a small problem though. There was a cook who wanted the apples earlier than the shop was open.
“I have plenty of things to do, I cannot wait until that sleepyhead wakes up” – he argued.
“I don’t care how you do it, but give me my apples at dawn” – he was yelling at his scullion.
His servant was a smart boy. He knew that while the early morning trader empties his baskets the store will be unlocked. He went in and collected the finest of the apples. The cook was very pleased even gave his scullion a pay rise.

Months flew by, spring came. The apple trees were in full bloom. This was when a real tragedy occurred. An evil wizard sent a blizzard on the kingdom and froze half of the apple trees. There were famine and poverty. The king gave a strict rule to the shop owner:
“No one should buy more than two apples a day” – he ordered.
“Yes, my lord” – the store owner replied.

The shop owner did the best he could, but somehow he was always short on apples. Some customers left empty-handed, they could not even buy their two apples a day. Needless to say, the impatient chef never had to stand in line. There was always a sweet-smelling pie on his table.

The store owner has been punished harshly by the king for his negligence.
“What should I do?” – asked the owner desperately.
“I totally lost control of my business” – realized the situation.
“It would be painful to fix it, though” – he compromised.

So, the store owner continued in his old ways. As a result, some of his clients were happy some of the time. And this is how they lived sort-of happily ever after.

This is a fictional story. Any resemblance to computer systems where multiple applications or services without proper boundaries share and modify common data is purely coincidental.

Fractals in Software Development

Fractals are everywhere, from nature to software development – This thought struck me when I was listening to one of those corporate telephone meetings with 15+ people on the line where none of the participants really pays attention to. Except for the speaker, I guess.

You asking what fractals are? Fractals are abstract mathematical objects that commonly exhibit similar patterns at increasingly small scales. There are artificially created fractals like the Mandelbrot set or Menger sponge (see below), but natural fractals can be found in snowflakes, clouds, and tree branches too.

Menger Sponge
Menger sponge also known as Sierpinski cube

What the hell all of that has to do with software development? Bare with me, I will tell you in a minute.

The enlightenment came to me when I was listening to my bosses boss describing future plans and how the firm is keen on “finding synergies”. Finding synergies basically means trying not to reinvent the wheel every time some new functionality is required, but instead use something that already exists.

When we programmers write a function or a method we do it because there are some steps which we would like to execute together over and over again. Common functionalities are then coupled into classes and libraries for better re-use. When writing an application we try to break it down into multiple components where ideally none of the functionality is duplicated. Building a platform consisting of multiple applications or services is no different. One of the purposes of using a microservice architecture is to segregate well-defined functionalities into services which can be utilized by other services. When you have multiple independent systems under your firm’s umbrella it makes sense to investigate how could existing solutions deployed to new departments to address similar needs. In other words: finding synergies. In my eyes, all these use cases represent the same thing on a different fractal dimension.

I was sitting at my desk and I felt like I was Buddha under the fig tree. This is when I realized that under the surface programmers have more in common with high-level management than a lot of us initially might think. And that the end of the day software development obeys the same laws of nature as trees, clouds, or snowflakes.

Fractal TreesFractal CloudsFractal Snowflake

Frequent Coding Interview Exercises

I often conduct Java core competency interviews to support my current firm’s effort to bring in new talent. Most candidates are coming in reasonably prepared regarding theoretical knowledge at least. However, they often surprise me how a coding exercise catches them off guard – typical for fresh graduates. Here the intention is to use the produced code as a starting point for further discussions around coding paradigms and language constructs. This often gets crippled because we hardly finish with the coding bit in time.

You might think that the exercises are way too complex, but the truth is that they are not. I invite you to have a look if you are interested. In order to help rookie interviewers and interviewees, I decided to create a git repository to collect the most common coding assignments. The repository might be small for now, but I intend to add more stuff to it over time. Because I truly believe in test-driven-development each assignment has its own dedicated test class. To be up-to-date with the latest technology tests are written using the new JUnit5 framework.

The repository is available here: https://github.com/kurtiszabi/interview-coding-exercises

How to Pass Java 8 OCA Exam – Part 2

This is the second a final part of my writing on how to pass the Oracle Certified Associate Exam from Java 8. In case you haven’t read the first part you can do it here: How to Pass Java OCA 8 Exam – Part 1.

After I finished reading the official study guide I was looking for some tests I can practice on. I came across a software produced by a company named Enthuware. They offer a free testing framework and charge you for the question packages. Please make sure you download the Java 1Z0-808 package because this is what you will need. Compared to the price of the exam the cost of the package is very reasonable and represents a good value. The application offers multiple testing options but let’s get into that a bit later.

Week 3

Goal: Finish Enthuware objective-wise test 1-5; take standard test 1-3.

Monday Take Entuhware Standard Test 1 77 Hardcoded Questions
Tuesday Take Objective-wise Tests 1-2 Java Basics and Data Types – 40 Questions
Wednesday Take Standard Test 2 77 Hardcoded Questions
Thursday Take Objective-wise Tests 3-5 Operators, Arrays and Loop Constructs – 40 Questions
Friday Take Standard Test 3 77 Hardcoded Questions

By week number 3 you should have all the required lexical knowledge. So, you can move onto practicing sample tests. This is where you will need the Enthuware software. After installing the correct question package (make sure you download 1Z0-808) you can choose from several types of tests. Standard tests are the big ones. Answering 77 questions and reviewing the answers takes about 2 – 2,5 hours. It’s very demanding – I know. This is why I included “lighter” days between two big tests. The objective-wise practices roughly correspond to the chapters in the OCA book and help you to revise your knowledge.

Week 4

Goal: Finish off all the objective wise tests and standard tests up to #5.

Monday Take Objective-wise Tests 6-7 Constructors, Methods, Encapsulation, and Inheritance – 40 questions
Tuesday Take Standard Test 4 77 Hardcoded Questions
Wednesday Take Objective-wise Tests 8-11 Exceptions, Instanceof Operator, Java APIs and Lambda Expressions – 35 Questions
Thursday Take Standard Test 5 77 Hardcoded Questions
Friday Take the Easy Practice Test 30 Questions

This week is a continuation of the previous one and it is very demanding but it wall pay off.

Week 5

Goal: Finish off all Enthuware tests and go back to the OCA book to identify any weak spots.

Monday Take Standard Test 6 77 Hardcoded Questions
Tuesday Take the Though Practice Test 30 Questions
Wednesday Take the Very Though Practice Test 27 Hardcoded Questions
Thursday Take OCA Tests for Chapters 1 – 3
Friday Take OCA Tests for Chapters 1 – 6

For the last 3 weeks, you have been taking tests from the Enthuware testing framework. Now it’s time to go back to the OCA book for some change. Taking earlier objective-wise tests again helps you to identify areas of development, topics in which you are still not confident enough. You should answer all the questions and calculate the percentage of correct answers for each. Then you will need to re-visit chapters for tests with the two lowest scores. I really recommend to read through the chapters just as I did or at least identify the most relevant sections. For the last three days, I reserved three online tests. By buying the official study guide you automatically get access to 3 online tests. You will need to visit the site of the publisher – Sybex test bank – and take the practice exams from there.

Week 6

Goal: Fix weak spots and test again

Monday Re-visit the chapter where you scored the lowest
Tuesday Re-visit the chapter where you scored the second lowest
Wednesday Online Test 1 60 Questions
Thursday Online Test 2 60 Questions
Friday Online Test 3 60 Questions

You may say that I ran through the book very quickly and focus too much on the tests. The reason for this that is twofold:

  • I was already familiar with the basic concepts as I program in Java almost every day.
  • At the end of the day, the certification exam will be a test 😉

If you are new to the language you may need to spend more time with the study guide perhaps take fewer practice tests. It all comes down to your proficiency with the Java language. But one thing is sure: after week number 6 you should feel proud. After countless hours spent in front of tests, you are ready to go and take the real thing.

I Hope you find this post useful and I wish you good learning!

How to Pass Java 8 OCA Exam – Part 1

In this article, I’ll give you a step-by-step approach how to pass Java 8 Oracle Certified Associate exam. I’ll explain my method, how I scored 94% on this exam. For more on what this exam is or whether it’s worth taking it see my previous post: Should I become a Certified Java Developer?

There are two keys to success in taking exams. On one hand, you have to have the lexical knowledge. On the other hand, you have to be familiar with the way the exam is going to test your competence. Knowing upfront what kind of tricky questions to expect might mean the difference between passing or failing the exam. It’s better to be prepared because sometimes even the wording of the questions might be confusing.

The official study guide: Oracle Certified Associate Java® SE 8 Programmer I will help you with the lexical knowledge. It covers all the topics that are on the exam and nothing more. It’s very well written and easy to follow even for beginners. I strongly suggest buying a hard copy or download it as an e-book. After each chapter, there is a set of review questions to test your understanding.

The decision to take this exam takes courage, passing it successfully takes commitment and effort. I was wondering what technique I could use to improve my chance of success. At the end came up with a 6-week program similar to what personal trainers use to get you in shape. However, this program will exercise your brain instead of your muscles. Each day has a task assigned to it, but nothing is carved in stone. This program incorporates flexibility – the ability to respond to unforeseen events that otherwise might get you off track. This program is broken down into weeks and you should focus on accomplishing weekly goals – rather than worrying about missing a day or two. However the closer you can stay to the schedule the easier the process will be. Now let’s have a look at the step-by-step approach how to pass Java 8 OCA exam.

Week 1

Goal: Finish the first half of the study guide.

Monday Read Chapter 1 Java Building Blocks
Tuesday Answer Review Questions for Ch. 1
Wednesday Read Chapter 2 and Answer Review Questions Operators and Statements
Thursday Read Chapter 3 Core Java APIs
Friday Answer Review Questions for Ch. 3

You may go faster or slower. I followed this routine while working full-time.Depends on how fast you read but one chapter should be manageable in one day. If you need more time use a portion of the day reserved for answering review questions. One thing is very important, please check your answers for mistakes and make sure that you understand why you answered incorrectly before finishing a review day.

Week 2

Goal: Finish the second half of the study guide

Monday Read Chapter 4 Methods and Encapsulation
Tuesday Answer Review Questions for Ch. 4
Wednesday Read Chapter 5 and Answer Review Questions Class Design
Thursday Read Chapter 6 Exceptions
Friday Answer Review Questions for Ch. 6

As you probably have noticed I assigned more work to Wednesdays just to push myself a little harder, but I left the weekends empty. If you need more time to catch-up feel free to use the weekends. If you need some rest that’s also fine. Just make sure you stay focused.

By coming this far we have finished the official study guide. But, this is just the start, in the second part I’ll come back with more advanced stuff. Stay tuned.

Should I Become a Certified Java Developer?

The number of software developers doubles roughly every 5 years. Until artificial intelligence reaches a level where computers will be able to program themselves more and more programmers will be needed. There are tons of initiatives to teach programming not just for children but even for adults. But which programming language one should learn? If you would like to develop for mobile phones. Apple’s Swift language is a good start. Would you like to build online stores or blogs? Then PHP is a good pick. A lot of small and mid-sized companies build web services in C#. But is there a language in which you can do all of that, plus have a knowledge in your hand that is applicable from Wall Street to Silicon Valley? That would be Java, the programming language that is around from 1996 and will be for the foreseeable future.

robot thinker artificial intelligence progress pop art retro style. antique pose. science fiction and the robot character.

Oracle is the company behind Java and as such it organizes certification exams for developers. Because there is a lot of content to cover you have to pass two exams to become a certified Java developer: the Certified Associate (OCA) and the Certified Programmer (OCP). You can do it in any order you wish but keep in mind that the OCA exam is about the basic principles while OCP focuses on more advanced concepts. So, it makes sense do take them in that order.

In my opinion certification programs provided by Oracle should serve as a common denominator for Java developers. Sure, you can write good code without taking these exams. You can do it even without going through any formal education. But, how would you feel if your doctor or lawyer didn’t have any papers to prove they know what they do? More established professions already regulated themselves in order to guarantee the highest possible quality of services. Computer programming is still a very young field of profession. However, it’s only a matter of time when education and certification exams will play utmost importance. As Robert C. Martin the author of popular books like the Clean Code puts it: “we better regulate ourselves before politicians do”. The community of software developers should establish rules for its members. One of such rules could be the list of exams, a programmer has to take in order to become a member.

Does it worth the effort to study and take the certification exam until it isn’t a must? If you are a new graduate fresh out of college and looking for a job, try to look at things from an HR person’s perspective. Having a certification might not get you the job, but it certainly will help you to get on the shortlist. Another option is that you are a programmer who works with Java for many years. In that case, you might think it’s not all that important to have a paper. I’m myself an example of the later, except that I have a different opinion about the exam. The language itself evolves constantly. We had to wait for Java version 8 a very long time but it introduced a good deal of new stuff. Studying for a certification exam is a very good opportunity to keep up with the changes.

If you work as a full-time developer the odds are that you are performing very similar tasks day by day, month after month: work with Hibernate, writing Java Web Services, designing Rest APIs or constructing Sybase queries. And there’s nothing wrong with that because you can become an expert in those areas. But on the other side you easily loose the broader picture – use the programming language in a very limited way and forget the fundamentals. I kinda felt this way. So, I decided to take the certification exam. Without a doubt, it was a very good decision. I learned a lot and I even noticed that I even started using new coding patterns. I hope you will follow me and experience a similar joy and excitement going through this truly transformational process as I did.

P.S. …and make no mistake, artificial intelligence will one day take our jobs.