On Tue, 16 Apr 2013 18:51:06 +0100, Tofu Ninja <emmo...@purdue.edu> wrote:
On Tuesday, 16 April 2013 at 15:23:56 UTC, Regan Heath wrote:
I would question always question "fully intended" on a case by case
basis:
http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197
I agree that grouping functions together that should be used together,
or on the same type of object is a good idea from an organisational
point of view but that shouldn't be the only reason for making them
class member functions.
R
I think a lot of people give too much credit to encapsulation. I mean
don't get me wrong its cool and all and it has its place, but it seems
like some people make it seem a lot more important than it really is. I
mean having lots of encapsulation really doesn't do anything for your
program, it won't run faster or do more things. If any thing, more often
than not, it makes things run slower, as you can't see what's in the
black box.
Thats just my opinion on the whole thing...
True, but this is what I'd call a short term view of encapsulation and
code quality.
Thinking about encapsulation in the short term is important because it
forces you to properly design things for the long term. If you don't care
at all about encapsulation (or orthogonality) you probably wont bother to
actually define the interface between two potentially orthogonal pieces of
code.
If there is no separation "designed in" to start with then code tends to
tie itself together in sometimes surprising ways typically creating
unintended dependencies or complexity. Essentially the code becomes
harder to reason about, harder to change and therefore harder to improve.
So, ultimately encapsulation (one aspect of good design) should lead to
code which is better in every measurable way, including running faster.
Sure, there will be the odd case where encapsulation decreases
performance, in those cases I would take the practical route of breaking
encapsulation to solve the issue. In short, encapsulation is important
and useful but not paramount.
:)
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/