• Latest
  • All
  • News
  • Business

The Importance of Decoupled Objects in OOP

Jul 21, 2017
How are Slots & Other Online Casino Games Programmed?

Slot Selection: Choose The Game That Applies Best To Your Interests

Mar 17, 2023
Five Top Tips On How To Choose The Best Gaming Headset

Five Top Tips On How To Choose The Best Gaming Headset

Mar 17, 2023
A Guide On How To Choose The Best Gaming Mouse

A Guide On How To Choose The Best Gaming Mouse

Mar 17, 2023
Buying A Gaming Monitor: What You Should Look For Before Choosing The One To Buy

Buying A Gaming Monitor: What You Should Look For Before Choosing The One To Buy

Mar 17, 2023
A Step-by-Step Guide on How to Get Your CleanMyMacX Activation Number

Different Factors To Consider When You Want To Choose A Keyboard For Gaming

Mar 17, 2023
10 games that are designed to keep you engaged

Useful Tips for Choosing Your New Gaming Chair

Mar 17, 2023
Discovery Phase For Software Development: How Much Does It Cost?

The 3 Main Reasons To Identify Security Problems in Software Code

Mar 15, 2023
The Evolution Of Air Conditioning Technology And Its Impact on the Way We Live And Consume

The Evolution Of Air Conditioning Technology And Its Impact on the Way We Live And Consume

Mar 14, 2023
What You Should Know About The Maker Protocol: A Comprehensive Guide

What You Should Know About The Maker Protocol: A Comprehensive Guide

Mar 14, 2023
Tableau Developer Career Path in 2023

Tableau Developer Career Path in 2023

Mar 13, 2023
5 Best Data Security Practices

Digital transformation trends businesses need to watch in 2023

Mar 13, 2023
The Biggest Innovations in Business Communication Technology

How to Leverage the Power of Intelligent Leadership

Feb 23, 2023
  • Guest Posts
  • Advertise
  • Contact Us
  • Privacy Policy
Friday, March 17, 2023
Tech Featured
  • Home
  • Latest Tech
  • Apple
  • How to’s
  • Apps
  • Automobiles
  • Gadgets
  • Gaming
  • Reviews
  • Tech Tips
No Result
View All Result
No Result
View All Result
Tech Featured
No Result
View All Result
Home News

The Importance of Decoupled Objects in OOP

by techfeatured
Jul 21, 2017
in News
0
0
SHARES
13
VIEWS
Share on FacebookShare on Twitter

In OOP (object oriented programming) it’s important to remember why you are building an application with objects instead of mere functions (procedural programming). Sometimes programmers will treat objects more like functions which completely defeats the purpose of objects in the first place! The purpose of this post is to explore the real benefit of OOP and how to structure your models appropriately.

What is a decoupled object?

Contrary to the novice OOP programmer’s belief, an object is much more than a collection of data members and related methods. It’s important to remember that an object embodies data and methods that pertain only to itself. The term “decoupling” is used to identify the separation of software blocks that shouldn’t depend on each other.

Why is it important to decouple objects?

Let’s say that we have a Car Class with the methods driveForward(), stop(), turn(), honkHorn(), and changeLanes(). This object has a poor design because one of the methods, changeLanes(), might depend on a Street class. What if you were trying to reuse this class for a car that only drives off-road? In this case, the changeLanes() method is completely meaningless to your object instantiation. Furthermore, if the turn() method were to reference the changeLanes() method, the entire object would start to seem too specific to instantiate and work with an off-road car. In addition, if a change is made to the Street class, it’s very likely that the Car class will also have to be modified. Since Car has a method that depends on another object, this object is said to be “coupled” (which is what we are trying to avoid).

How to decouple objects

To create what I call “purified objects”, we need to completely decouple them in such a way that all of their fields and methods are specific to what the object can do in any circumstance. To decouple the Car class, you would want to move the changeLanes() method to another object that interacts with Car, like CityDriving. This new object acts as a mediator because it uses the Car class for special circumstances without tainting its pure definition.

When designing your object models, ask yourself “are these objects purified? Are they decoupled?” If you religiously ask yourself this question when creating new objects, not only will you end up creating much cleaner code, you’ll also spend less time re-factoring. Good luck!

Tags: androidimaciphonemacbooktechnology news
ShareTweetShareSendShare

For any queries, you can reach us at [email protected]

Latest Posts

  • Slot Selection: Choose The Game That Applies Best To Your Interests
  • Five Top Tips On How To Choose The Best Gaming Headset
  • A Guide On How To Choose The Best Gaming Mouse
  • Buying A Gaming Monitor: What You Should Look For Before Choosing The One To Buy
  • Different Factors To Consider When You Want To Choose A Keyboard For Gaming
Tech Featured

© 2022. All Rights Reserved.

Navigate Site

  • Guest Posts
  • Advertise
  • Contact Us
  • Privacy Policy

Follow Us

No Result
View All Result
  • Home
  • Latest Tech
  • Apple
  • How to’s
  • Apps
  • Automobiles
  • Gadgets
  • Gaming
  • Reviews
  • Tech Tips

© 2022. All Rights Reserved.