Questions tagged [private-methods]

285 questions
0
votes
1 answer

Rails best practices : Public methods in model

I'm a newbie and I'm wondering if my app is going to fail is a near future because I don't understand all subtleties of Rails. So I prefer to ask you :-) I have a User and a Product model, and I want to create a method that could be used like that…
Flo Rahl
  • 1,044
  • 1
  • 16
  • 33
0
votes
1 answer

Private and public methods and variable in JavaScript

I am having some problems to understand how to implement and use classes with private/ public methods and use it, even after some read around. I have the following code: var _Exits = 0; var _Shuttles = 0; function Parking(_str) { var Floors =…
0
votes
1 answer

Why the error C2248 when the copy constructor is private in the code below?

This code emits error C2248: 'A::A' : cannot access private member declared in class 'A' in VS2010, although RVO doesn't need a copy constructor. To prove this, just turn public the declaration A(const A&); below, and the code will execute without a…
Belloc
  • 6,318
  • 3
  • 22
  • 52
0
votes
1 answer

Does @Remote in Java EE 6 make private methods accessible?

Consider this code: @Remote public interface ISayHello { private void sayHello(); } Will the sayHello method be accessible from the outside world or not?
Martin Andersson
  • 18,072
  • 9
  • 87
  • 115
0
votes
1 answer

Rationale behind allowing Ruby constants to be re-defined and allowing access to private methods via send() method?

When we try to redefine a constant, Ruby shows only a warning, but not any error. So one can always redefine a constant in Ruby? Also a private method of a class can be invoked using the send method: Const = 12 puts Const #only an warning: already…
Curious
  • 2,783
  • 3
  • 29
  • 45
0
votes
1 answer

PHP Class private variable misdirected value

first of all, my problem is from my php class called by a php file who is accessed by an AJAX call. The problem is that the return value is totally wrong and is not the same as the sybase_result value. So what am i missing? Here are the steps of my…
m4dd
  • 89
  • 1
  • 2
  • 7
0
votes
2 answers

PYTHON: virtual method behavior differences for public, private(single underscore) and private(double underscore) methods

I was trying out NVI(Non-Virtual Interface) Idiom in python, and noticed that private(double underscore) methods don't seem to be acting as virtual. class A(object): def a(self): print "in A.a" self.b() self.__b() …
skydeep
  • 3
  • 1
0
votes
1 answer

Selectively allowing classes to use others' private class methods, or equivalent solution

In my project Bar, I have this class Foo, whose instances represent unique, named real-world objects. References to these instances are scattered under good care around the data structures in my project, but also, I have decided to make them…
Boris Stitnicky
  • 12,444
  • 5
  • 57
  • 74
0
votes
2 answers

Unable to access a private function

//**** Build of configuration Debug for project Calculator **** **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\Calculator.o ..\src\Calculator.cpp ..\src\/Calculator.h: In function…
Harsha
  • 5
  • 1
  • 5
0
votes
2 answers

PHP - calling a private method for testing, what's the correct design?

Possible Duplicate: PhpUnit private method testing In my unit tests I need to call a private method to set my fixtures to a given state. On the other hand, I'd rather not make this method public. How do I go about this?
d33tah
  • 10,999
  • 13
  • 68
  • 158
0
votes
3 answers

Access a member variable from a private method in JavaScript

lick() is a private method of Cat. Unfortunately, Cat's this.paw is not accessible in lick(). Is there a simple way to create a private method that has access to the member variables of its containing class?
David Winiecki
  • 4,093
  • 2
  • 37
  • 39
0
votes
1 answer

Local method and namespace in jquery plugin

I created a plugin but want to be sure about what I do with "local" functions. Here is schematically what I did : (function($) { var methods = { init : function( options ) { // CODE ... // Call of a local function …
bastien
  • 209
  • 2
  • 14
0
votes
3 answers

Calling a private static method from __callStatic

I want to use __callStatic as a preProcessor for calling static methods. My idea is to make the methods private so every static call is forwarded to __callStatic. Then I could use this to do some stuff and call the method then. But it seems not…
-1
votes
1 answer

trying to avoid violating encapsulation

starting some new stuff in Java and im kind of having a hard time. I feel like im on the right track just for some reason cannot find a way around the problem I am having without violating encapsulation. I have these two classes called Weight and…
Oquin123
  • 9
  • 1
-1
votes
2 answers

Accessing public methods in private inner classes

I have the following code, I wanted to know how to access the public method:locationFinder in the private inner class:LocationBasedFormatter of the outer class:LocationFormatter. Basically I would like to access the method locationFinder from…
BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98
1 2 3
18
19