Clever Engineer
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
๐ ๐จ๐ป๐น๐ผ๐ฐ๐ธ๐ถ๐ป๐ด ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ ๐ฅ๐ฒ๐น๐ถ๐ฎ๐ฏ๐ถ๐น๐ถ๐๐: ๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ๐ถ๐ป๐ด ๐๐๐๐ ๐ฃ๐ฟ๐ผ๐ฝ๐ฒ๐ฟ๐๐ถ๐ฒ๐ ๐
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
Click here to claim your Sponsored Listing.
Category
Telephone
Website
Address
9 Street Sinkor
Monrovia
1000