cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
353
Views
0
Helpful
1
Replies

Pair O' Dimes: OOP, Procedural, Functional, Choose!

npetrele
Cisco Employee
Cisco Employee

What kind of programming do you do? Before you answer this, please read what I have to say about each, especially the section on OOP (Object Oriented Programming), because you might be surprised about how I use OOP and I'm curious if you have a similar attitude. 

I have 30 cents to spend on programming types. I'm only going to spend a pair o' dimes. My first dime goes to Procedural.

Procedural = 10 Cents

If you learned to program in a language like C, you know what procedural programming is like. Technically, if you're reading a post in Developer General Topics, I'm sure you know what procedural programming is. 

 

function do_something(x) {
    y = do_stuff_to(x);
    y = do_other_stuff(y)
    return(y)
}
a = do_something(b);

 

You simply write code that does something. And if you do something often enough, you write a function (subroutine) that does it, so that you don't have to write the same code over and over again. You simply call that function.

Technically, that's all an object is if you don't employ them edumacated fancypants feachurs like inheritance and polymorphism. An object is a bunch of procedural operations called "methods" and some variables. When it comes to writing code from scratch, I rarely see the point of wrapping procedural code and variables in a class or object. 

OOP = 10 Cents

865jtf.jpg

Though I rarely write Java code anymore (and never write C#), the language itself is based on objects, and I appreciate how they work. So a penny goes to Java, C#, and similar languages. 

However... I regularly use OOP libraries. When I want to write an app with a graphical UI, there's no better set of libraries than you get with Qt. I make use of the inheritance and/or polymorphism features of OOP libraries. But in these cases, I'm only using OOP because 99% of the work has been done for me. 

Maybe it's just a limitation in my brain, but when I set out to write an app, I don't envision a better way to do things by creating a class full of procedural code and refer to them as methods. I USE those features when they're available in a language or library, but I don't build them. I go right back to my roots and write and re-use functions. 

Zero Cents

Functional programming is getting a lot of attention on Youtube these days. Quite frankly, I have no taste for it at all. I don't care if Mary had a little lambda. I look at a couple lines of functional programming code and my face turns the same shade of green as when I look at Perl, Prolog, or regular expressions. Is it more efficient? Maybe. But I'll never adopt this trend because readability makes zero cents. 

The Big Question

So what kind of code do you write? Are you like me and go procedural except when handy objects are available in a library? Are you strictly procedural? Do you start your code with classes and go full OOP? Do you [gag, cough] go with functional? 

1 Reply 1

Ruben Cocheno
Spotlight
Spotlight

@npetrele 

Has this been resolved?

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/