private

Why defining private members below public members in C++?

In C++ sometimes in class definition public members are declared at first and privates later. But the variables or data members are normally private and used by the public methods. So, in this case variables are used but not even declared yet. Thus the code become difficult to understand. But I found renowned programmers, sites or books ...

Dumb Question about examples in Test Driven Development By Example by Kent Beck

I suspect that I'm missing something stupid, so feel free to blast me, but: I'm reading through Test Driven Development: By Example and one of the examples is bugging me. In chapter 3 (Equality for all), the author creates an equals function in the Dollar class to compare two Dollar objects: public boolean equals(Object object) { D...

Best Practice on local use of Private Field x Property

Hi, When inside a class you have a private fiels and expose that field on a public property, which one should I use from inside the class? Below you is an example on what I am trying to find out. Should manioulate the Private Field _Counter or the Property Counter? Public Class Test Private _Counter As Integer Public Property Counte...

What does "@private" mean in Objective-C?

What does @private mean in Objective-C? ...

Can we use more than one mock object in a unit test?

hello, i have read many articles about unit testing.. Most of the articles said that we should not use more than one mock object in a test..but i can't understand why :s sometimes we really need more than one mock object in a test.. ...

access private method in a different assembly c#

This may be a daft question as I can see the security reason for it to happen the way it does... I have a licensing c# project, this has a class which has a method which generates my license keys. I have made this method private as I do not want anybody else to be able to call my method for obvious reasons The next thing I want to do i...

Any way to Invoke a private method?

I have a class that uses XML and reflection to return Objects to another class. Normally these objects are sub fields of an external object, but occasionally its something I want to generate on the fly. I've tried something like this but to no avail. I believe that's because JAVA won't allow you to access private methods for reflection....

Using Prototype's Class.create to define private/protected properties and methods

There is a good generalized method for defining private and protected properties and methods in Javascript, here on the site. However, the current version of Prototype (1.6.0) doesn't have a built-in way to define them through its Class.create() syntax. I'm curious what the best practices are when developers want to define private and p...

Do you ever use protected visibility in Rails?

Confession: I only use private and public visibility for my methods! I have a feeling this is a bad thing. But in Rails it just doesn't seem to come up as an issue. Does anyone have an example in Rails where it would be a big mistake not to use protected visibility? ...

Why can clone set a private field on another object?

I'm learning Java, and the book I'm reading has the following example on cloning. In clone(), my first instance is able to set buffer on the new object even though buffer is private. It seems like it should require the field to be protected for this to work. Why is this allowed? Does clone() have special privileges that allows it to acc...

WordPress displays private posts to logged-in users -- how to turn this functionality off?

On a new WordPress 2.8 installation, I have some posts assigned to category Foo that were previously public but have since been made private. When I am logged into WordPress (as the admin) and happen to also be browsing the Foo category page in a different tab in the same browser, I can see the private posts on the category page, with t...

How to declare a resource from a private inner class in WPF?

Hi, all. I'm trying to declare a resource in a WPF UserControl, and I'd like the resource to be an instance of a private inner class. How do I do this? XAML: <UserControl ...> <UserControl.Resources> <local:MyConverter x:Key="MyConverter" /> </UserControl.Resources> </UserControl> Code Behind: public partial class M...

Doxygen - Objective-C - Document Private Class functions Private

In doxygen, I can create objective-c categories inside my implementation file to hide interfaces that shouldn't be accessed publicly. However, doxygen still documents the category as the members being "public". Even by adding the \protected or \private, this is still the case. Is there another method that I'm overlooking that would put...

Sql Server modify select

I'm pretty sure there is no way, but i'm putting this out there for those expert beyond my knowledge. What i am looking to do is to somehow alter SELECT statements before they are executed, at the database level. For a seriously pared-down example, i'd like to do something like the following... when someone executes the following SQL ...

How can hibernate access a private field ?

How can hibernate can access a private field/method of a java class , for example to set the @Id ? Thanks ...

Is there a way to access the private parts of a different instantiation of the same class template?

Hi all, In my continuing adventure with templates, I've templated my Container class not just on the ItemType it holds, but also on a Functor argument that determines how it should order the items. So far, so good. A little problem I've run into occurs when I want to copy the contents of one Container to another: If the two Container...

How do I read a private field in Java?

I have a poorly designed class in a 3rd-party JAR and I need to access one of its private fields. For example, class IWasDesignedPoorly { private Hashtable stuffIWant; } IWasDesignedPoorly obj = ...; How can I use reflection to get the value of stuffIWant? ...

static constructors in C++? need to initialize private static objects

I want to have a class with a private static data member (a vector that contains all the characters a-z). In java or C#, I can just make a "static constructor" that will run before I make any instances of the class, and sets up the static data members of the class. It only gets run once (as the variables are read only and only need to be...

How can I protect part of an array in php from being modified?

I have an array in php like this: $myArray = array('name'=>'juank', 'age'=>26, 'config'=>array('usertype'=>'admin','etc'=>'bla bla')); I need this array to be accesible along the script to allow changes in any field EXCEPT in the "config" field. Is there a way to protect an array or part of an array from being modified as if it where d...

A few C# naming convention questions

1) What's the policy for declaring a variable? Should you always use the keyword private, or is it OK to skip it? string MyVar1; vs. private string MyVar1; The only reason I see is that Microsoft one day can change the default access modifiers to public instead of private. Where does it say that private is optional? Any references...