Kasama Chenkaow
3 min readMay 11, 2023

Diving Into Programming: OOP from Above, FP from Below - And a Few Jokes Along the Way

Greetings, coding enthusiasts! I'm glad you've found your way to my little corner of the Internet. Now, let's embark on this joyride through the fun, and sometimes confusing, world of programming paradigms.

Object-Oriented Programming (OOP): Viewing the World from the Top

Have you ever found yourself organizing your sock drawer or kitchen utensils? You've been practicing object-oriented thinking all along. It's just like sorting socks by color or utensils by function. You're classifying, categorizing, and establishing relationships - much like in OOP.

In OOP, we start from the top. We begin by defining what is what, and who is a subtype of whom. We're the grand architects, establishing the high-level design of our application or system. Think of it as building a house. You don't start with the wallpaper or the type of door handle. You begin with the blueprint - the overall structure, the rooms, and their relationships.

In the world of OOP, we're a bit like a mischievous toddler categorizing the world. The dog? That's a four-legged furry creature. The cat? Also a four-legged furry creature. But anyone who's ever tried to bathe a cat knows there's more to that story.

Functional Programming (FP): Building Up from the Ground

Now, let's take a hike down to the valley of Functional Programming (FP). It's a bit like being a master chef, crafting a gourmet meal from raw ingredients. You start from the bottom, combining basic components into complex creations.

In FP, we start with simple functions, like chopping onions or sautéing mushrooms. Then, we start composing these together into more complex functions (or dishes, if you're still following my culinary analogy). This is the heart of FP: the idea of composing smaller functions to create more complex ones, building from the bottom up.

Interestingly, FP is often more reasonable and deterministic. Why? Because functions in FP are pure, meaning they don't have side effects. They simply take an input and produce an output, much like a well-behaved blender. This predictability makes FP deterministic, which can be a real comfort when you're navigating the wild and woolly world of code.

In this world, we're more like a naturalist observing the world. We don't impose rigid classifications; instead, we watch how things naturally combine and interact. It's a bit like watching a group of birds. You don't care about their taxonomy; you're interested in how they fly together.

OOP vs FP: It’s All About Perspective

So, I've been working with C#, which is primarily an OOP language, but it has some FP concepts tucked away in its folds, kind of like finding a little leftover Christmas chocolate in February - a pleasant surprise! But this blend can make it confusing to understand what programming paradigm we're really using.

However, I’ve had a lightbulb moment. It’s not just about the style of your code, it’s about your mindset when you analyze problems and design solutions. Do you start with a grand blueprint (OOP) or do you start with the bricks and mortar (FP)?

The Nature of Things: FP vs Human Nature: OOP

Interestingly, I’ve begun to see that FP aligns more with nature’s way of doing things - no hard classifications, just things flowing and combining in a million layers. On the other hand, OOP is more like us humans, always trying to categorize and classify everything. Sometimes we get it right, other times, it’s like trying to put a square peg in a round hole (or a cat in a bathtub).

So, there you have it - a whirlwind tour of OOP and FP, a few laughs, and maybe even some enlightenment. Remember, it's not about which paradigm is better; it's about finding the right tool for the job - or the right approach for the problem at hand.

As you continue on your coding journey, don't be afraid to mix and match OOP and FP concepts. After all, the beauty of programming lies in its flexibility and the endless possibilities it offers. And who knows? You might just come up with the next groundbreaking solution by combining the best of both worlds.

Keep exploring, keep laughing, and keep coding, my friends. Until next time, happy programming!