Member-only story

No Access to Others’ Private Parts: One of the Many Reasons OOP Never Reached its Potential

Sean Hoffman
8 min readOct 6, 2021

TL;DR Version: Please stop using the private keyword and start using protected instead in your C++, C#, and Java classes. Over-use of the private keyword enforces an unnecessarily Draconian limitation and fundamentally limits code-reuse.

The OOP Paradigm has been around since the mid-60s, but it was right around 1990 when I bought my first C++ compiler, taught myself C++, and actually used it for my job. I was writing financial applications to mark-to-market Interest Rate Based Derivatives (Interest Rate Swaps, if you have a background in Finance or are curious), and while the data was stored in DBF (good ol’ dBase III) format, for performance reasons, the mark-to-market and portfolio position calculations were done in C. “Mark-to-Market” is just a fancy finance term meaning “calculate an asset’s future cash flows based on ‘current’ rates at present-value.”

In C (obviously) you have to be very disciplined with memory management. Any memory you allocate you have to clean-up somewhere or you’ll have memory leaks. One of my personal “best practices” when writing C is to write the cleanup code immediately after making a RTL allocate call (malloc, calloc, etc), even before writing a single additional line of business or program logic.

--

--

Sean Hoffman
Sean Hoffman

Written by Sean Hoffman

Software Developer (C++, C#, Go, others), Husband, Father. I eat fried potatoes annually on July 14th.

No responses yet