When OOPS meets Crypto
A classic geek article for crypto fans & Object Oriented Programming Enthusiasts!
When OOPS meets Crypto 🚀
Geek Alert ⚠️
A few days ago, I was trying to recall the concepts of Object Oriented Programming Structures taught WAYYY back in my second year at college. For most of us who are Computer science (or related) engineers, the concept of OOPS - is one of the most widely utilised one; and if taught really well, can be translated into easy and interesting examples!
A lot of crypto tokens and projects can be taught to computer engineering students and working professionals in a language they ( probably ) like - that is; with the concepts of OOPS !
Interestingly, there are some basic similarities between the concepts of OOP and certain crypto tokens that can help you understand both concepts better. For example, both OOP and crypto tokens rely on the principles of abstraction and encapsulation to promote code modularity and reduce complexity. But before this becomes too complex or difficult; lets try and simplify each and every concept
Here we go →
Think of 4 friends, who started their own company called OOPS. These 4 friends, viz. Abstraction, Encapsulation, Inheritance & Polymorphism figured, that the previous programming mechanisms, were a little too complex and difficult to maintain-codes.
So these 4 folks took up individual responsibilities in their new firm, OOPS.
Abstraction, took up the role of making programming less complex and easier to understand. His task is to show, only what’s important and relevant; and hide the rest of the details. When asked to draw a Human Body, Abstraction created a figure that showed only the relevant necessary body parts like heads, arms, hands and avoided details like skin folds, skin texture, the nervous system etc.
Encapsulation, on the other hand, took up the role of keeping code organised. His task is to make sure that the code is organised, structured and safe. Nobody likes a cluttered or a messy room and encapsulation solves for this; by keeping the code within a “ class “
Polymorphism believes in being flexible. “ Objects “ in OOPS can have various forms, or types. His inspiration was his mother, who was a teacher at school, a mother at home, a singer by hobby - she could do everything without breaking a sweat - Flexible Pro Max.
& Inheritance, decided to understand history and make the most of it! He quickly understood that he had a lot of qualities that his parents had, and was similar in nature when it came to making decisions. Also, that sharing of resources = Optimal utilisation of resources → this way he also found a win-win property for himself.
But now comes the question, how are Crypto tokens similar to each one of these?!
Well well
To start with, lets look at Inheritance.
Bitcoin and Litecoin are both decentralized, peer-to-peer cryptocurrencies that use blockchain technology to facilitate secure and transparent transactions. Bitcoin was the first crypto that was launched in 2009 and has its own set of properties. The Litecoin network on the other hand, went live in October 2011.
There are several similarities between these two cryptos; for example both are mined, using the Proof of Work algorithm. BTC & LTC have a limited supply, and both tokens have deployed a halving mechanism to control the rate at which new coins are created. In fact, Litecoin is a fork of the Bitcoin codebase, meaning it shares many of the same technical features as Bitcoin.
So, are we safe to say, Litecoin is a {child} & Bitcoin is the {parent}?
BTC & LTC have some individual factors and fundamental differences also. In inheritance: when a child class is defined, it can include additional properties that are specific to that class, which are not present in the parent class. These additional properties can be used to represent new data or behaviours that are relevant to the child class, but not to the parent class.
So, while Litecoin shares a few similarities with Bitcoin, it has several key differences that make it a unique and distinct crypto. These differences impact its performance, adoption, & total supply.
Moving on to the concept of zk-rollups & the fancies surrounding it →
The concept of zero knowledge proofs and abstraction in OOP share only a few similarities, but enough for us to create a basic example!
Zero knowledge proofs are a cryptographic technique that enables one party to prove to another party that they know a certain piece of information, without revealing the information itself. In other words, zero knowledge proofs allow you to prove something without revealing how you know it. This concept is often used in secure communication protocols and authentication mechanisms.
A few popular zk-rollup assets that are trending are Polygon ( $MATIC ), Loopring ( $LPR) amongst others.
Abstraction in OOPS, is used to simplify complex systems & codes. While both zero knowledge proofs and abstraction involve the idea of hiding details, they are used in different contexts and for different purposes. Zero knowledge proofs are used to enhance security and privacy, while abstraction in OOP is used to enhance modularity and reusability of code.
& what about Sharding, have you heard about this term?
In a traditional blockchain system, every node on the network processes and stores a copy of the entire blockchain; except, that this idea is great theoretically. When the network grows in size keeps becoming more and more preferred / used, storing an entire copy becomes difficult logistically and expensive.
With sharding, the blockchain is partitioned into smaller, more manageable subsets called shards. Each shard contains a subset of the blockchain's data and is processed and stored by a subset of the network's nodes. Rings a bell ? Sharding can be thought of as a mechanism similar to Encapsulation. Encapsulation is intended to protect the data within the class from being accessed or modified by code outside of the class, except through specific methods defined within the class. To make things more clear, Both encapsulation and sharding involve grouping elements into smaller, more manageable subset. However, they serve very different purposes. Encapsulation is primarily used to improve code maintainability, while sharding is used to improve system scalability and performance.
The benefits of sharding have been well utilised by our friends at NEAR Protocol in their blockchain network, and Polkadot in their parachains - which offer distributing the data on a blockchain, creating a simpler perspective to manage it.
Hold on, no discussion can be concluded without the mention of smart contracts in the crypto ecosystem. Especially when the concept is a great analogy to Polymorphism in OOPS.
Simply put, smart contracts are smart codes, or self-executing programs that run on blockchain platforms and can be used to automate / enforce the terms of an agreement between two parties.
When we extrapolate our analogies used so far; smart contracts, like the property of Polymorphism can represent different types of objects or agreements. They can be reused and modified to fit different use cases, making them flexible and adaptable. Additionally, just as polymorphism allows a single object to take on different forms, smart contracts can be designed to have different functions or behaviors depending on the inputs they receive.
Overall, while smart contracts and polymorphism operate in different domains, they share some similar characteristics, such as reusability and flexibility.