Why encapsulation is an important feature of OOP languages? [closed]

Encapsulation helps in isolating implementation details from the behavior exposed to clients of a class (other classes/functions that are using this class), and gives you more control over coupling in your code. Consider this example, similar to the one in Robert Martin’s book Clean Code: public class Car { //… public float GetFuelPercentage() { /* … Read more

How do you manage per-environment data in Docker-based microservices?

Docker compose supports extending compose files, which is very useful for overriding specific parts of your configuration. This is very useful at least for development environments and may be useful in small deployments too. The idea is having a base shared compose file you can override for different teams or environments. You can combine that … Read more

System design: Strategies for dealing with heavy writes to a DB

I’d say a solution will be highly dependent of what exactly you need to do. A solution to write thousands of records per second might be very different from incrementing a counter in the example you provided. More so, there could be no tables at all to handle such load. Consistency/availability requirements are also missing … Read more

Where to implement Automapper in a DDD + layered architecture

To answer your specific question I will speak more generally about your architecture. The architecture you’ve devised for your project is subtly different from a typical architecture used with DDD. While the way you’ve partitioned responsibilities is typical, in DDD, domain classes aren’t responsible for their own persistence. In fact a mantra of DDD is … Read more

How to set Architecture for docker build to arm64?

For building single docker images: Set your environment variable using the command line or modifying your .bashrc or .zshenv file. (introduced in v19.03.0 in 03/2019) export DOCKER_DEFAULT_PLATFORM=linux/arm64 Alternatively, in the Dockerfile, include the following flag in the FROM command (for a multi-stage Dockerfile build, the flag is only needed for the first stage): FROM –platform=linux/arm64 … Read more

Why put a DAO layer over a persistence layer (like JDO or Hibernate)

You make some points. But I nevertheless use a Dao layer, here’s why: Database accesses are calls to a remote system. In all such cases (also web-service, ajax etc…), the granularity of interaction need to be big enough. Many tiny calls would kill performance. This performance necessity requires often a different view of the system, … Read more

Why is a CPU branch instruction slow?

A branch instruction is not inherently slower than any other instruction. However, the reason you heard that branches should avoided is because modern CPUs follow a pipeline architecture. This means that there are multiple sequential instructions being executed simultaneously. But the pipeline can only be fully utilised if it’s able to read the next instruction … Read more

Transactions best practices [closed]

I always wrap a transaction in a using statement. using(IDbTransaction transaction ) { // logic goes here. transaction.Commit(); } Once the transaction moves out of scope, it is disposed. If the transaction is still active, it is rolled back. This behaviour fail-safes you from accidentally locking out the database. Even if an unhandled exception is … Read more