1

Contract-oriented programming, like Solidity, is similar to OOP, in a syntactical sense. For example, both have concepts of encapsulation, abstraction, inheritance, and polymorphism. They also share similar keywords, and a contract seems analogous to an object. However, they are not.

Does anyone know of any resources regarding contract oriented design?

6
  • Hi there. Have you seen this term used in the Ethereum space? Contract-orientated programming in a computer science/software engineering sense is nothing to do with smart contracts, unless there's now a blockchain-specific definition :-) Commented May 23, 2021 at 20:00
  • Ah I must be mistaken then. For some reason I swear I've seen the term "contract oriented programming" somewhere, maybe at the introduction of a tutorial. Update: here it is: tutorialspoint.com/solidity/index.htm. Is there a difference? I'd never heard of "design by contract" before Commented May 23, 2021 at 20:27
  • Interesting. In more recent versions of the Solidity docs, they've changed "contract-oriented" to "object-oriented" -> docs.soliditylang.org/en/v0.8.4 Perhaps they realised that it wasn't the right term to use? Commented May 23, 2021 at 20:30
  • 1
    I've added an answer in case it helps other people wondering a similar question. Commented May 23, 2021 at 20:30
  • Okay, final update. It looks like originally "contract-oriented" was meant as a pun on "object-oriented", which implies they probably didn't know about the definition I've mentioned in my answer. -> github.com/ethereum/solidity/pull/4995#discussion_r218450303 Commented May 23, 2021 at 20:42

1 Answer 1

1

Contract-Orientated Programming - also called Design by Contract (DbC) - is a software engineering paradigm aimed at making software more reliable.

"Design by contract (DbC), also known as contract programming, programming by contract and design-by-contract programming, is an approach for designing software."

The "Contract" part of the name has (confusingly) nothing to do with smart contracts.

Further, it isn't tied to a particular language, nor a particular language type, rather it's a methodology and approach to writing code.

(There's the related "Condition-Orientated Programming" that Gavin Wood wrote about, here. Again, this is a methodology rather than syntax or language trait, but that article does give a walk-through of how it can be applied to Solidity.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.