Clever Engineer

Clever Engineer

Share

14/09/2025

๐—˜๐—ป๐—ฐ๐—ฎ๐—ฝ๐˜€๐˜‚๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ

Encapsulation is one of the core pillars of object-oriented programming (OOP). It refers to the concept of combining data (fields) and the functions that work on that data (methods) into a single unit

Real-World Analogy

Imagine a vending machine. You donโ€™t open it up to grab snacks or fiddle with the money system inside.

Instead, you use the buttons and coin slot interface.

The machine gives you limited, predefined options: insert money, select an item, get your snack.

You never see how the inventory is tracked or how the change is calculated.

Internally, the company may redesign how the machine handles inventory or payments, but your experience as the user stays consistent.

Also don't forget to follow this page

Serious about your Software Engineering growth ๐Ÿ‘‡๐Ÿพ

READ MORE

https://open.substack.com/pub/cleverengineer/p/encapsulation-explained?r=1nba3w&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true

01/08/2025

๐‡๐ž๐ซ๐žโ€™๐ฌ ๐š ๐›๐ž๐š๐ฎ๐ญ๐ข๐Ÿ๐ฎ๐ฅ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง ๐Ÿ๐จ๐ซ ๐ฒ๐จ๐ฎ:

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

Well, when I saw this question, I knew the optimal solution right out of the box because I have a bit of a mathematics background.
Transpose the matrix, then reverse it.

Transposing a matrix means making each row in the matrix its column and each column its row. It turns out thereโ€™s a constant when we transpose the matrix. Take, for example, the following matrix:

1 2 3
4 5 6
7 8 9
Thereโ€™s a constant diagonal of 1, 5, 9. Letโ€™s transpose this matrix, and I will discuss why this is, in fact, important to know:

1 4 7
2 5 8
3 6 9

If we move along this diagonal and swap opposite elements, then we have transposed the matrix: [0][1] = [1][0], [0][2] = [2][0], [1][2] = [2][1]

and the last part we can reverse every row
7 4 1
8 5 2
9 6 3

here is the question for you
https://shorturl.at/FKwBo

04/02/2024

๐Ÿš€ ๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†: ๐—จ๐—ป๐—ฑ๐—ฒ๐—ฟ๐˜€๐˜๐—ฎ๐—ป๐—ฑ๐—ถ๐—ป๐—ด ๐—”๐—–๐—œ๐—— ๐—ฃ๐—ฟ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐˜๐—ถ๐—ฒ๐˜€ ๐Ÿš€

Ever wondered how databases ensure the reliability and integrity of your data, especially in critical applications like banking and healthcare? Let's delve into the world of ACID properties โ€“ the backbone of database transactions!

๐ŸญอŸ.อŸ อŸ๐—ชอŸ๐—ตอŸ๐—ฎอŸ๐˜อŸ อŸ๐—ถอŸ๐˜€อŸ อŸ๐—”อŸ๐—–อŸ๐—œอŸ๐——อŸ อŸ๐—ฃอŸ๐—ฟอŸ๐—ผอŸ๐—ฝอŸ๐—ฒอŸ๐—ฟอŸ๐˜อŸ๐˜†อŸ อŸ๐—ผอŸ๐—ณอŸ อŸ๐——อŸ๐—ฎอŸ๐˜อŸ๐—ฎอŸ๐—ฏอŸ๐—ฎอŸ๐˜€อŸ๐—ฒอŸ:อŸ

ACID is like a set of rules that databases follow to make sure they handle data reliably and safely. It stands for:

๐—”๐˜๐—ผ๐—บ๐—ถ๐—ฐ๐—ถ๐˜๐˜†: Treats a set of operations as one whole thing. Either all of them happen, or none of them.

Description:

Start Transaction:

The transaction begins.
Execute Operations: Multiple operations are executed as part of the transaction.

Checkpoint:
A checkpoint is reached. At this point, the system ensures that all operations have been completed successfully.

Commit:
If all operations succeed, the changes are committed to the database. If any operation fails, a rollback is performed, and the changes are discarded.

๐—–๐—ผ๐—ป๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐˜†: Makes sure that the database is in a valid state before and after transactions.

Description:
Start Transaction:
The transaction begins.

Execute Operations:
Multiple operations are executed as part of the transaction.

Consistency Check:
After each operation, a consistency check is performed to ensure that the database remains in a consistent state.

Commit:
If the consistency check passes for all operations, the changes are committed to the database. If any consistency check fails, a rollback is performed

๐—œ๐˜€๐—ผ๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป: Keeps different transactions separate, so they don't interfere with each other.

Description:
Start Transaction (T1): Transaction T1 begins.
Start Transaction (T2): Concurrently, another transaction T2 begins.

Execute Operations (T1 and T2): Both transactions execute their respective operations concurrently.
Isolation: The operations of each transaction are isolated from each other, and neither is aware of the other's changes until they are committed.

Commit (T1 and T2): Each transaction independently commits its changes to the database.

๐——๐˜‚๐—ฟ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†: Once a transaction is complete, its changes are permanent, even if something goes wrong.

Description:
Commit: The transaction commits its changes to the database.

Write to Log: The committed changes are written to a transaction log or journal.
Checkpoint: Periodically, the system creates a checkpoint, ensuring that all committed changes are permanently stored.

Recovery: In the event of a failure, the system can use the transaction log to recover the database to its last consistent state.

Imagine ACID like baking a cake. You want all the ingredients mixed (atomicity), the cake to taste good (consistency), each step to be done without messing with other recipes (isolation), and once it's baked, it stays baked (durability).

Please give us a follow if you love this
Clever Engineer

Want your school to be the top-listed School/college in Monrovia?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


9 Street Sinkor
Monrovia
1000