Method Injection and Property Injection Design Patterns

Hello, In this article we’re going to explore the Method Injection and Property Injection design patterns. To demonstrate the patterns I’m going to add a new interface named Encoder to the printer.py file and a concrete implementation for two encoders: Rot13Encoder and NullEncoder. class Encoder(metaclass=abc.ABCMeta): def encode(self, message: Message) -> Message: raise NotImplementedError("encode must be implemented!") class Rot13Encoder(metaclass=abc.ABCMeta): def encode(self, message: Message) -> Message: return Message(codecs.encode(str(message), 'rot_13')) class NullEncoder(metaclass=abc.ABCMeta): def encode(self, message: Message) -> Message: return message The Encoder will be used by the printer in order to encode the messages before printing them....

December 28, 2020 Â· 2 min Â· Denis NuČ›iu

Nucu Car Devlog: 0x03 – Android

Hello everyone! I’ve been working lately on my little project involving Raspberry Pi and .NET, during my free time. Now, I’ve introduced a new technology, Android! The project needed a front-end and It took me a long time to decide how to implement it and what technology to use. I was conflicting between a cross platform desktop application or a web application. I initially thought Electron would have been a great choice since it covers both, but it doesn’t work out of the box with gRPC and I needed some proxies which complicated the things on the backend, not to mention JavaScript is horrible in every imaginable way....

November 30, 2020 Â· 2 min Â· Denis NuČ›iu

LeetCode: Reverse Linked List Solution and Explanation

Hi, In this article I will explain my solution for the following LeetCode problem: Reverse Linked List. If you’re interested in solving this problem then please try to spend at least one hour or more on it before looking at my solution. To help you solve this problem I’ve created the following table: Current Prev 1 NULL 2 1 3 2 NULL 3 Think about how you can use this table to write an iterative or recursive algorithm that reverses the linked list....

November 17, 2020 Â· 3 min Â· Denis NuČ›iu

Constructor Injection and Null Object Design Patterns

The Constructor Injection design pattern is a pattern that helps you declare all the required dependencies of a class in it’s constructor. This is useful because it helps you decouple the code, you can specify an interface instead of a concrete type, remember, program to an interface. Also, in the constructor it is easier to guard against null objects. The calling code doesn’t have to worry about null exceptions every time it uses a dependency....

November 7, 2020 Â· 2 min Â· Denis NuČ›iu

Composition Root Pattern: How to Write Modular Software

The composition root is a design pattern which helps you structure a software application by implementing a class that builds all the other classes. In this example we will examine this pattern in Python. Here’s the object graph of the classes that we’re going to implement: I have designed a sample application that we’re going to use. It contains three components: ConsoleInputListener, ConsolePrinter and RomanianTranslator and a value object class: Message....

November 6, 2020 Â· 3 min Â· Denis NuČ›iu

Kafka Connect GitHub source connector

Hello! In this article we will discuss how to quickly get started with Kafka and Kafka Connect to grab all the commits from a Github repository. This is a practical tutorial which saves you some time browsing the Kafka’s documentation. Environment Kafka is bit difficult to setup, you will need Kafka, Zookeper and Kafka Connect at least. To simplify the setup we’re going to use Docker and docker-compose. Once you have Docker and docker-compose installed on your system, you can run a single command and get a Kafka environment for developing....

July 29, 2020 Â· 5 min Â· Denis NuČ›iu

How to use Windows 10’s Wireless Display feature

Hi, In this article I will show you how to use your Windows 10’s wireless display feature in order to use your Laptop/Xbox as a wireless display. Initial Setup First things first let’s enable network discoverability on both PCs. Open up Control Panel, go to Network and Internet, next Network and Sharing Center and click on Change advanced sharing settings Then expand the Private tab and use the same settings as I do, only enable File sharing if you need it....

July 22, 2020 Â· 2 min Â· Denis NuČ›iu

LeetCode: Flood Fill

Hello, Here’s my solution for the flood fill problem, found on LeetCode. If you want me to write about certain topics please let me know in the comments, thank you! Link to the problem: """ An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image....

July 16, 2020 Â· 2 min Â· Denis NuČ›iu

Introduction to Pyenv for Linux Users

Hello, In this article I will introduce you to pyenv, a tool for managing python environments. Installing pyenv is pretty straight forward, you’ll need to clone the repo and add the binaries to the path. For a typical Debian based distro using the Zsh shell the instructions would be: git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc Then, in order for this to take effect, you need to reload the shell with: source ~/....

June 27, 2020 Â· 4 min Â· Denis NuČ›iu

LeetCode: Find The Town Judge

Hello In this article I will present you my Python3 solution for the following problem which I found on LeetCode: find-the-town-judge. Note: The solution is on the second page, so you won’t get spoiled if you want to attempt to solve the problem by yourself. Have fun! from collections import defaultdict from typing import List """ In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge....

May 11, 2020 Â· 2 min Â· Denis NuČ›iu