access-levels

Java Protected Access Not Working

In java, there's three levels of access: Public - Open to the world Private - Open only to the class Protected - Open only to the class and its subclasses (inheritance). So why does the java compiler allow this to happen? TestBlah.java: public class TestBlah { public static void main(String[] args) { Blah a = new Blah...

Common CMS roles and access levels

I am currently writing a CMS and remember someone (it might have been on here) criticise the existing CMS for not having a robust enough user permissions system. I've got a method planned out but it I feel it has fallen into the usual trap of being a bit too fine-grained which makes understanding and implementing it a horror for end use...

Is there a language with object-based access levels?

A common misconception about access level in Java, C#, C++ and PHP is that it applies to objects rather than classes. That is, that (say) an object of class X can't see another X's private members. In fact, of course, access level is class-based and one X object can effortlessly refer to the private members of another. Does there exis...

What access level should loggers be set to?

I'm using SLF4J with Log4J underneath. What access levels should I be setting my loggers to? static final Logger logger = LoggerFactory.getLogger(ClassName.class); ...

How to restrict access to nested class member to enclosing class ?

Hi, Is it possible to specify that members of a nested class can be accessed by the enclosing class, but not other classes ? Here's an illustration of the problem (of course my actual code is a bit more complex...) : public class Journal { public class JournalEntry { public JournalEntry(object value) { ...

C# protected field to private, add property--why?

In Visual Studio 2008 Team System, I just ran Code Analysis (from the Analyze menu) on one of my C# projects. One of the warnings produced was the following: Microsoft.Design : Because field 'Connection._domain' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibil...

access exception when invoking method of an anonymous class using java reflection

Hello I'm trying to use an event dispatcher to allow a model to notify subscribed listeners when it changes. the event dispatcher receives a handler class and a method name to call during dispatch. the presenter subscribes to the model changes and provide a Handler implementation to be called on changes. Here's the code (I'm sorry it's ...

Rails authlogic : How to make Levels?

Hello, i followed this tutorial fo setting Autlogic up properly. So, my site needs a form of level, like "Admin", "Moderator", "User", "Guest". So Admins can do everything, where Moderators may not can make site changes. And Users can't destroy, Update or Create. I've have googled a bit.. But nothing found, so i thought you guys might ...

What do you choose, protected or internal?

If I have a class with a method I want protected and internal. I want that only derived classes in the assembly would be able to call it. Since protected internal means protected or internal, you have to make a choice. What do you choose in this case - protected or internal? ...

Are protected members/fields really that bad?

Now if you read the naming conventions in the MSDN for C# you will notice that it states that properties are always preferred over public and protected fields. I have even been told by some people that you should never use public or protected fields. Now I will agree I have yet to find a reason in which I need to have a public field bu...

Error with C++ partial specialization of template

I am using PC-Lint (great tool for static code analysis - see http://www.gimpel.com/) For the following chunk of code: class ASD { protected: template<int N> void foo(); }; template<> inline void ASD::foo<1>() {} template<int N> inline void ASD::foo() {} PC-lint gives me a warning: inline void ASD::foo<1>() {} m...

C# compile error: “X is inaccessible due to its protection level”

hi, when c# gives this compile error? 'Favorite.Favorites.FavoriteCollection' is inaccessible due to its protection level private void Form1_Load(object sender, EventArgs e) { Favorites objFavorites = new Favorites(); objFavorites.ScanFavorites(); foreach (WebFavorite objWebFavorite in objFavorites.FavoriteCollecti...