Understanding of Java Collections

Java Collection is a pretty favorite subject in Java articles. But here, I'll share my personal thoughts and ideas that you might not know.

Discrete Math and Java Collection

From the first look, Java Collection is a set of structures that fit different problems, like quick data search. But in practice, Java Collection interfaces are representing notions from discrete math.

HTTP Protocol: Obviously Unobvious

Hyper Text Transfer Protocol

HTTP protocol nowadays is still one of the most popular protocols used over the internet. But many developers still can't explain clearly what is it. In this article, you will find out what HTTP is practically is. 

Protocol Meaning

But stepping back a little let's remind what is the meaning of Protocol. A protocol can be understood as a contract or agreement between sender and receiver. The HTTP protocol is described in RFC 2616. The main purpose of the HTTP protocol is to send web data to browsers to render it. 

How Readable Is Your Code? Part 2

Once Again About Cyclomatic Complexity

In the first part, I've introduced Cyclomatic Complexity (CYC) metrics in the previous part. So CYC has no intention to be a readability code metric. CYC was invented a long time ago (in 1976)  by Thomas J. McCabe. 

Cognitive Complexity Metric.

Cognitive Complexity (CC) attempts to count the cognitive effort required to understand the code's flow. Let's take a look at the next example:

How Readable Is Your Code? Part 1

There Is No Perfect Implementation?

Every developer has his own preferences and vision about problem-solving. Any problem can be solved in my différent ways following know practices like SOLID, KISS, etc. But how to compare 2 different implementations? Smaller is better? Only Object-Oriented? How practically evaluate notions like code maintainability, readability, transparency? Well, I'm not sure that there is absolute truth in such questions, but in this article, you will find a metric that can help you find out. 

Cyclomatic Complexity — Number of Scenarios in Code.

Cyclomatic complexity is a metric invented to find out the number of tests to cover the given code fully. This metric also can be used to measure the readability of your code.  Cyclomatic Complexity shows how many scenarios consist of your code (or how many independent ways inside its graph)

Inversion of Control (IOC), Dependency Injection (DI) Oversimplified

Introduction

IOC and DI are very useful patterns that are used in almost every production project. But, for me personally, they are pretty misleading and difficult concepts to understand. Here, I'll example what both of them are and implement a simplified proof of concept. 

Inversion of Control

Inversion of control is a pattern responsible for your class initialization. They will be created and set on startup or before each class is initialized. So initialization is not done in constructor but by classes themselves (control is inverted). In a configuration class, you can what implementation each interface will be used. 

Use Mocks in Testing? Choose the Lesser Evil!

Mocking Test Methodology 

The key idea of mocking is to replace real code (e.g. calls to a database or service) with artificial functionality that has the same return type. There are different approaches to this practice. Here, I explain best practices and why it might be better to avoid mocking to have real code quality.

User Service — Example to Be Tested With Mocks

Let's write a simple application that fetches users from HTTP service. 

Child IT Education: Learn Development While Playing Games

 

Nowadays, the majority of parents don't know about programming education for children. Meanwhile, there are a set of free games that help kids to learn how to develop "simple applications". Such learning games can be played even by children even three years of age. They can learn about topics like: 

  • Code instructions.
  • Iteration and loops.
  • Conditional instructions.

In this article, I'm going to review three games that can get kids to start development while having fun.

Java Enterprise Annotations Part 1

Most enterprise Java applications are driven by annotations. Java annotations encapsulate many different functionalities. Here, I’ll introduce some of the most popular annotations and explain what they are responsible for to sure up your understanding of annotations you’re already familiar with and introduce you to ones you may not know. 

Inversion of Control and Dependency Injection

These two patterns are responsable for bean initialization. IOC initializes beans and defines dependencies between them, while DI allows you to use them in your class without calling a constructor. There’s much more you can do with these, but for the sake of brevity, we’ll stop here. 

Is the Object-Oriented Paradigm a False Hope?

For the last 20 years, Java has become the most popular object-oriented language. It conquered the enterprise world and still has one of the biggest communities. Now industrial development exists only because of the object-oriented paradigm (OOP). But here, I want to bring up skepticism about its fundamental paradigm. First, let's return to the past when Java didn't exist.

You may also like:  Misunderstanding OO Programming

Historical Reference

Programming before Java

Mutation Testing: Covering Your Code With the Right Test Cases (Part 1)

Mutation Testing Basics

The concept of mutation testing is to modify code in a small way and verify that tests detect that modification. Undetected modification gives a hint to what test is likely missing.

Mutation Procedure Next Steps:

  1. Modify code in small way (creating mutant)
  2. Execute existing test suites (killing mutant)
  3. Verify that at least one existent test failed (mutant killed)
  4. If all test succeded (mutant survived), there is likely a missing test case

But why do we have to consider testing the result of the modified code? Let's take a look at an example: