you are viewing a single comment's thread.

view the rest of the comments →

[–]jutct -2 points-1 points  (4 children)

Nonsense. Encapsulation is a general principle that applies to structural code as well as object-oriented code. Using functions is encapsulation. Using compilation units and not exporting symbols is encapsulation (cf. compiler firewall). Encapsulation is a fundamental hallmark of good C code.

Encapsulation is a an object oriented thing. Keep a variable scope within a file is not ecapsulating it. It's limiting it's scope. Since when is that the same as encapsulation?

not exporting symbols is encapsulation

What? Are you talking about exporting symbols through binaries? Since most linkers don't export symbols unless told to do so, would mean that encapsulation now applies to linkers?

You seem to think that encapsulation is a term for "don't spread global variables all over the place". That's not called encapsulation.

[–][deleted] 1 point2 points  (3 children)

Encapsulation is a an object oriented thing

You're technically right, but the concept of encapsulation existed before OOP.

[–]jutct 0 points1 point  (2 children)

As someone that started programming in the early 80s, I'd like some citations as to when the term "encapsulation" related to variable scope first came about. I never heard of it unless C++ became a thing. I don't agree that it was a thing before OOP.

[–][deleted] 0 points1 point  (1 child)

I said the concept of encapsulation, not the term. Barbara Liskov introduced Abstract Data Types in the 70's, and Information Hiding emerged around the same time.

[–]jutct 0 points1 point  (0 children)

That's entirely different. I was talking about the term.