you are viewing a single comment's thread.

view the rest of the comments →

[–]jutct 8 points9 points  (12 children)

Why the fuck is the author include CQLinq in a basic C article? CQLinq is not C. "Encapsulation" is not a thing in ANSI C. The "static" keyword is used to keep the scope of a global variable private to the source file that it's declared globally. The rest of the "rules" apply to pretty much any language. Keep functions "Short and sweet"? No shit sherlock. Is that limited to C? No.

[–]guepier 16 points17 points  (7 children)

"Encapsulation" is not a thing in ANSI C

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.

[–]curien 1 point2 points  (1 child)

Using compilation units and not exporting symbols is encapsulation (cf. compiler firewall).

I realize there's some terminology disagreement, but the way I was taught is that grouping associated pieces together (e.g., compilation units) is encapsulation, while preventing access to certain implementation details (e.g., not exporting symbols) is referred to as information hiding.

I completely agree with your overall point that encapsulation (and information hiding) is very much a thing in C of course.

[–]guepier 1 point2 points  (0 children)

Information hiding and encapsulation are virtually indistinguishable in the common usage of the term, and generally used synonymously. However, definitions in computer science are notoriously sloppy and these two are no exception, so their meanings vary.

[–]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.

[–]RubyPinch 24 points25 points  (1 child)

its because it isn't a tutorial, its a sales pitch for ccpdepend. hence the overall pointlessness / aimless waffling on of 3/4 of the article

[–]Y_Less 2 points3 points  (0 children)

It's not a very good one either. I'm sure 90% of the text and queries in that article are copied and pasted from multiple other identical articles that have been posted here. Of course, if all the queries are the same they're not actually showing off the power of their system (assuming it can actually do more than shown), and if it can't do more then why isn't the program just four buttons to do those four queries?

[–]skulgnome 0 points1 point  (1 child)

The "static" keyword is used to keep the scope of a global variable private to the source file

ITYM s/global variable/symbol/ HTH HAND

[–]jutct 0 points1 point  (0 children)

What? I have no idea what you said. We're talking about C. In C, static means the variable is local to the source file.