encapsulation

make a module's xml layer visible to other modules

情到浓时终转凉″ 提交于 2020-01-06 07:16:00
问题 In Netbeans Platform I'm having one module watch the xml filesystem and respond when it's changed by other modules. I've created a layer.xml in another module. The changes show up in the IDE when in the watching module I click on XML layer node and open up . However during runtime when the watching module is looking at the xml filesystem the changes from the other module aren't there. The other module can see its own changes during runtime. Is there a setting somewhere for a module that lets

Encapsulation issue with delegates?

旧时模样 提交于 2020-01-03 16:43:49
问题 I'm wondering why this works? For example I have some executor class that looks like so: public class Executor { public void Execute(Action action) { action(); } } Now I have some need to be executed class that looks like: public class NeedToBeExecuted { public void Invoke() { Executor executor = new Executor(); executor.Execute(DoSomething); } private void DoSomething() { // do stuff private } } My question is why this is work's I pass a private method to other class ? Is this not an

Should I encapsulate my IoC container?

亡梦爱人 提交于 2020-01-02 03:00:13
问题 Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I'm trying to decide whether or not it makes sense to go through the extra effort to encapsulate my IoC container. Experience tells me that I should put a layer of encapsulation between my apps and any third-party component. I just don't know if this is bordering on overkill. I can think of

C++ Is private really private?

时间秒杀一切 提交于 2020-01-02 00:14:33
问题 I was trying out the validity of private access specifier in C++. Here goes: Interface: // class_A.h class A { public: void printX(); private: void actualPrintX(); int x; }; Implementation: // class_A.cpp void A::printX() { actualPrintX(); } void A::actualPrintX() { std::cout << x: } I built this in to a static library (.a/.lib). We now have a class_A.h and classA.a (or classA.lib) pair. I edited class_A.h and removed the private: from it. Now in another classTester.cpp: #include "class_A.h"

When should encapsulation be used? [closed]

旧巷老猫 提交于 2020-01-01 16:47:15
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I am completing Sun/Oracle's Trail (http://docs.oracle.com/javase/tutorial/java/TOC.html) and it keeps reiterating the importance of encapsulation. How important, really, is encapsulation? I mean, if I may need to access the value of a given class field, why would I do so

What are the different types of encapsulation?

霸气de小男生 提交于 2020-01-01 03:27:07
问题 What are the different types of encapsulation? Am I right in thinking this basically refers to central OO concepts such as Abstraction, Polymorphism and Inheritance? My understanding of encapsulation is that it is a method of hiding data / functionality, but I never really considered Polymorphism or Inheritance a form of encapsulation, although I can see how polymorphism could be considered encapsulation as it can hide the exact type of the object you are interacting with. So, would you say

An object that securely provides both public API (read-only) and private API (read-write)

放肆的年华 提交于 2019-12-31 05:31:07
问题 This is an architecture problem. Programmers encounter this encapsulation problem quite often, but I haven't yet seen a complete and clean solution. Related questions: readonly class design when a non-readonly class is already in place Controlling read/write access to fields Normally, in OOP paradigm, objects store their data in fields. The class' own methods have full access to its fields. When you need to return value, you just return a copy of the data, so that the outside code cannot

Do both these classes support encapsulation and …?

久未见 提交于 2019-12-31 03:30:50
问题 public class Normal { public string name; // name is public public String getName() { return name ; } public String setName(String newName) { name = newName ; return name ; } public static void main(String args[]) { Normal normal = new Normal(); normal.setName("suhail gupta"); System.out.println( "My name is : " + normal.getName() ); } } New class starts from here public class Different { private string name; // name is private public String getName() { return name ; } public String setName

Shorthand Accessors and Mutators

可紊 提交于 2019-12-30 02:49:06
问题 I am learning C#, and am learning about making fields private to the class, and using Getters and Setters to expose Methods instead of field values. Are the get; set; in Method 1 and Method 2 equivalent? e.g. is one a shorthand of the other? class Student { // Instance fields private string name; private int mark; // Method 1 public string Name { get; set; } // Method 2 public int Mark { get { return mark; } set { mark = value; } } } Finally, would Method 2 be used when you want to for

When should a class use its own getters/setters vs accessing the members directly?

拟墨画扇 提交于 2019-12-30 01:58:05
问题 When generating setters and getters in Eclipse one of the options is to use the getters and setters within the class rather than accessing the class members directly. Is this level of class internal encapsulation useful or is it taking a good idea one step too far? DUPE : Should you use accessor properties from within the class, or just from outside of the class? 回答1: I think it's a good idea if you want the potential side-effects to occur - validation, logging etc. (In C# I'd like to be able