Questions tagged [public-method]

A public method is a method declaration that allows access from other classes external to the current class.

A public method is a method declaration that allows access from other classes external to the current class. Public methods are used in many Object-Oriented programming languages including Java, C#, and Objective-C

From http://www.javabeginner.com/learn-java/introduction-to-java-access-modifiers

Fields, methods and constructors declared public (least restrictive) within a public class are visible to any class in the Java program, whether these classes are in the same package or in another package.

184 questions
20
votes
5 answers

public static factory method

First of all please forgive me if its a really dumb question, I am just trying to learn this language to its core. I am reading Effective Java and the very first chapter talks about Static factory methods vs. Constructors. Their pros and cons. Few…
t0mcat
  • 5,511
  • 19
  • 45
  • 58
16
votes
4 answers

How to retrieve all public methods from *.dll

I have *.dll written with C# and I need to get list of all public methods or classes contained in that *.dll. Is there some way to do it programmatically with C#?
Neveriah
  • 161
  • 1
  • 1
  • 3
12
votes
4 answers

Smalltalk public methods vs private/protected methods

I noticed that the Smalltalk language has no concept of private/protected methods. All methods are public. Coming from a Java/C++ background, I've thought of this as a fundamental weakness in the language as any application created in Smalltalk…
12
votes
5 answers

Default constructor of an Empty Class is public. But how?

I have a simple question: class my { }; my ob; Compiler allows me to create an object which makes sense. And, I am aware that you can't create object where the constructor is private. To me it looks that, everything inside the class is private but…
Uchia Itachi
  • 5,287
  • 2
  • 23
  • 26
10
votes
4 answers

Private class with Public method?

Here is a piece of code: private class myClass { public static void Main() { } } 'or' private class myClass { public void method() { } } I know, first one will not work. And second one will. But why first is not…
Sandy
  • 11,332
  • 27
  • 76
  • 122
10
votes
2 answers

__call equivalent for public methods

I have an API for interacting with my web app, defined by a class. Each publicly accessible method needs to have authentication done before running. Rather than putting the same line over and over in each method, I'd like to use the magic __call…
Bob Baddeley
  • 2,264
  • 1
  • 16
  • 22
10
votes
8 answers

Can findbugs detect unused public methods

Is it possible to detect unused methods in a source tree using FindBugs? I see some posts on SO where users are claiming to do that, some others asking how to do this in FB and others where they claim FB cannot do this. Does anyone know for sure…
Miserable Variable
  • 28,432
  • 15
  • 72
  • 133
9
votes
4 answers

Is there a custom FxCop rule that will detect unused PUBLIC methods?

I just tried FxCop. It does detect unused private methods, but not unused public. Is there a custom rule that I can download, plug-in that will detect public methods that aren't called from within the same assembly?
Corey Trager
  • 22,649
  • 18
  • 83
  • 121
9
votes
2 answers

Twitter widget methods for dynamic widget updating

I am trying to add an option to a profile page for twitter widget and I have a field where users can add their twitter accounts and below it shows a preview of the widget. It works fine if I enter an account and click save and come back. But what I…
jorjap
  • 358
  • 3
  • 7
  • 20
9
votes
4 answers

objective c accessing public method

I try to access a public method from another class. I already tried many examples I found in the web, but they didn't work in the way I wanted them to. Class1.h @interface anything : NSObject { IBOutlet NSTextField *label; } + (void)…
Vincent Friedrich
  • 1,027
  • 1
  • 8
  • 11
8
votes
9 answers

removing public access to methods on an object

I would like to take an object and remove some methods from it. i.e. I have internally have an object with getter/setters on it and I want to give external users access to it. I don't want them to have access to the setter functions. I don't want…
Raynos
  • 166,823
  • 56
  • 351
  • 396
8
votes
2 answers

How to easyily find unused public methods/properties

I have a .Net(C#) solution. The solution contains bunch of projects. The projects were implemented not by me. It is not a framework, it means that I need to have amount of public methods/properties as less as possible. My task is to identify methods…
Antipod
  • 1,593
  • 3
  • 23
  • 43
7
votes
8 answers

Extra public methods in derived classes?

If I have an abstract class and derived classes of that class, am I correct that, according to good and practical design practice, that the derived classes should not provide extra public methods (they should only implement abstract classes and…
Chad Johnson
  • 21,215
  • 34
  • 109
  • 207
7
votes
3 answers

to get all public methods in the project

i have a project. c# .net I would like to get names of all public function in all public classes in the project. is there any tool or can i write a program that take the project dll or even the project directory ,as input ,and find all public…
Kuttan Sujith
  • 7,889
  • 18
  • 64
  • 95
7
votes
4 answers

Public static methods vs public methods

What's the difference between a public static method and a public method? Why would you use a public static method?
redconservatory
  • 21,438
  • 40
  • 120
  • 189
1
2
3
12 13