private-methods

What is the best practice for naming private and static private methods in C#?

I'm trying to figure out what is the smartest way to name private methods and private static methods in C#. Background: I know that the best practice for private members is underscore-prefix + camelcase. You could argue this with me, but trust me I've seen enough code from hardcore pros that follow this convention, it is the skilled in...

How do I define private or internal methods in object oriented Perl?

I'm using Damian Conway's "inside-out" objects as described is his wonderful book Perl Best Practices to construct an object-oriented interface to a security system at my client. I'm coming across the need to use internal helper methods within my module that I would normally designate as "_some_method". However, this seems to break enc...

Overriding private methods in Java

As succinctly described here, overriding private methods in Java is invalid because a parent class's private methods are "automatically final, and hidden from the derived class". My question is largely academic. How is it not a violation of encapsulation to not allow a parent's private method to be "overridden" (ie, implemented indepen...

Private Method For changing Setting of the iPhone

Which are the private methods available to change the settings of the iPhone, say Toggling Wifi, 3G. I know this will be rejected by the AppStore , But still curious to know how, atleast could be used for jailbroken device. ...

functional test for rails controller private method

I have a private method in my controller. which is used for some database update. this method i am calling from another controller method. and it works fine. But when i am trying to write a test case for that method then It is tripping on accessing (session variable and params) in my functional all other methods are working fine the pro...

Access inner function variables in Javascript

In many frameworks, internal function variables are used as private variables, for example Raphael = (function(){ var _private = function(a,b) {return a+b;}; var _public = function(a) {return _private(a,a);} var object = {mult2:_public}; return object; })(); here, we cannot access from the global namespace the variable...

How to use a object whose copy constructor and copy assignment is private?

In reading TCPL, I got a problem, as the title refered, and then 'private' class is: class Unique_handle { private: Unique_handle& operator=(const Unique_handle &rhs); Unique_handle(const Unique_handle &rhs); public: //... }; the using code is: struct Y { //... Unique_handle obj; }; and I want to execute such op...

Is it possible to use a static private method of a class as callback?

I saw code that contained the following line: preg_replace_callback($regex, 'TextileParser::replaceAnchor', $text); where TextileParser::replaceAnchor() is a private static method. Is that possible, or the code is wrong? ...

Private Variables and Methods in Python

Which should I use _foo (an underscore) or __bar (double underscore) for private members and methods in Python? ...

rails search with texticle: private method `scan' called for #<Array:0x103f03f08>

Hi, I have a rails app which I want to make searchable with tenderlove's texticle. In the console it works fine, but in my app I get an error like this: /opt/local/lib/ruby/gems/1.8/gems/texticle-1.0.3/lib/texticle.rb:65:in `index' /Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:92:in `call' /Users/v...

Publicize.exe exits with error "Value cannot be null. Parameter name : interfaceType

Hi, I'm trying to make private accessor class using Visual Studio 2010. Here is the return of Publicize.exe: Error occurred during processing of assembly xxx Value cannot be null. Parameter name: interfaceType I use internals and InternalVisibleTo in my project. Perhaps that is the cause of the problem? ...

"Monolithic" page classes - Is this a code smell?

I'm new to PHP and I'm trying to build a site for the first time without using a framework (n.b. I have nothing against frameworks, I just think I should learn to code from scratch before learning a framework on top of it. Sort of like learning Javascript before learning JQuery). I like OOP in concept, so I started there. I'm thinking o...

How can I call a inner function from the Python shell?

I have some code (that I can't easily modify), of the following form: def foo(x): do_other_stuff_that_I_do_not_want_to_do() def bar(): "do something" str(x) bar() I would like to call bar(), directly, from the Python shell. I don't mind using co_globals, or other internal bits. I have the feeling that this may b...

Partitioning struct into private and public sections?

In C++ and Java, data structures can have private, public and protected regions. I'd like to port this concept to a C language program I am writing. Are there any idioms for implementing private or protected function pointers and data fields in a C struct? I know that C structs are public, I'm looking for an idiom to help hide some i...

Testing classes with threads, events, and private methods

hey guys general consensus I've done quite a lot of reading up on the subject of testing complex classes and private methods. The general consensus seems to be: "if you need to test private methods then you're class is badly designed" "if your class is complex, then you need to separate it out" So, I need your help. the problem C...

Why can't I access private class methods in the class's companion object in Scala?

I'm working on a homework assignment for my object oriented design class, and I'm running into trouble with Scala's companion objects. I've read in a few places that companion objects are supposed to have access to their companion class's private methods, but I can't seem to get it to work. (Just as a note, the meat of the assignment had...

Which technique to use for creating private methods in Obj-C ?

When I want to create private methods in Objective-C, what should I use? 1) The well known categories technique. 2) @private directive. (I'm doing iOS development). ...