封装的反义词是什么?

def*_*ode 10 oop unit-testing encapsulation terminology

使用在线词典工具并没有多大帮助.我认为封装的方式在计算机科学中的使用并不完全符合它在简单英语中的含义.

计算机科学版本的反义词是什么?更具体地说,什么是封装的反义词,它将作为函数名称使用.


我为什么要在乎?这是我的动机:

// A class with a private member variable;
class Private
{
public:
   // Test will be able to access Private's private members;
   class Test;
private:
   int i;
}

// Make Test exactly like Private
class Private::Test : public Private
{
public:
   // Make Private's copy of i available publicly in Test
   using Private::i;
};

// A convenience function to quickly break encapsulation on a class to be tested.
// I don't have good name for what it does
Private::Test& foo( Private& p )
{ return *reinterpret_cast<Private::Test*>(&p); } // power cast

void unit_test()
{
   Private p;
   // using the function quickly grab access to p's internals.
   // obviously it would be evil to use this anywhere except in unit tests.
   assert( foo(p).i == 42 );
}
Run Code Online (Sandbox Code Playgroud)

cdh*_*wie 20

The antonym is "C".

Ok, just kidding. (Sort of.)

The best terms I can come up with are "expose" and "violate".

  • +1"暴露".不太确定"违反":函数的存在违反了封装,但函数所采取的动作并非违反封装.不过,这是一个很好的区别.该函数确实违反了C++标准,因此无论如何都可以证明这些理由;-) (3认同)

Kel*_*nch 9

The purpose behind encapsulation is to hide/cover/protect. The antonym would be reveal/expose/make public.


lia*_*iaK 5

解封装怎么样..

虽然它不是计算机科学术语,但在医学科学中,通过手术去除胶囊或包膜..这里查看..

  • 场景:(下班后在拥挤的酒吧)Dev1 对 Dev2 说:“你今天做了什么?” Dev2 回答说:“我不得不对某人的代码进行解封装。” 附近的人群以为听到了“我必须斩首某人”,露出滑稽的表情并后退。 (6认同)