Member-only story
What is Component-Oriented Programming (COP)?
Component-oriented programming is the new object-oriented programming
With all the latest front-end frameworks — such as React, Angular, and Vue — we’re seeing a cool new paradigm rise. It’s known as component-oriented programming, and it’s all about stitching reusable components together like Lego blocks.
At its core, component-oriented architecture embraces the Don’t Repeat Yourself (DRY) dogma. Repeating code is time and efficiency wasted. The less time we spend repeating ourselves, the faster we can build our applications. As software engineers, with the deadlines we’re sometimes set, taking any advantage can be crucial in satisfying our overlords.
What Component-Oriented Programming Looks Like
If you know any modern front-end frameworks, such as React, Angular, or Vue, you might know already what component-based architecture looks like. Here’s a basic example of a Header
component:
import React from 'react';
import { Logo, ProfileImage, BurgerMenu, HeaderWrapper } from 'components';
const Header = () => (
<HeaderWrapper>
<Logo></Logo>
<ProfileImage></ProfileImage>
<BurgerMenu></BurgerMenu>
</HeaderWrapper>
)
export default Header;