main-method

Using the main method of classes for debugging?

It is good practice to use the main method to test a java/.net class? I've seen it reccommended in some text books, but to me it seems like using a unit testing framework would make more sense... The main method gives you one point of entry to the class and you can test one aspect of the classes functionality. You could I guess test ma...

How to write main() in an OOP way?

When I first started programming, I wrote everything in main. But as I learned, I tried to do as little as possible in my main() methods. But where do you decide to give the other Class/Method the responsibility to take over the program from main()? How do you do it? I've seen many ways of doing it, like this: class Main { public st...

Invoking Java main method with parameters from Eclipse

During development (and for debugging) it is very useful to run a Java class' public static void main(String[] argv) method directly from inside Eclipse (using the Run As context menu). Is there a similarily quick way to specify command line parameters for the run? What I do now is go to the "Run Dialog", click through the various sett...

Should I define a main method in my ruby scripts?

In python, a module doesn't have to have a main function, but it is common practice to use the following idiom: def my_main_function(): ... # some code if __name__=="__main__": # program's entry point my_main_function() I know Ruby doesn't have to have a main method either, but is there some sort of best practice I should fo...

Finding the class with the main method in an applet

I'm trying to use this tool https://swingexplorer.dev.java.net/ to find some information out about an applet's swing structure. Unfortunately, I didn't develop the applet. I've pulled the jars for the applet from the cache, but there are several hundred .class files in the jars, and I don't know which one has the main method. Is the...

Java methods and classes, how do they fit together? (Solved)

Currently I am writing a program for an introductory Java class. I have two pieces to my puzzle. Hopefully this is a relatively simple to answer question. Firstly, here is what I am trying to use as my main program: import java.util.Scanner; public class TheATMGame { public static void main(String[] args){ Scanner input = new S...

Name that pattern: Does a decent name for this type of executable module already exist?

I'm having trouble naming a set of software modules that follow the same pattern. I'm hoping this already is a named pattern as I can't come up with a decent name. The situation: I have a fairly sophisticated/complex object oriented application, complete with unit tests. I need to start running the thing and playing with it. There are m...

Joining Multiple Projects in one solution

I have started creating a game, and I added a second project, it's the standard XNA Windows game 3.1 project, and since the other project already had a Main to start the program and the 2nd is for game data, where as the first was for the drawing and graphical side of things (menu's etc) I thought I would remove the Main method, and now ...

Iterate through main function in C?

Here is my main function: int main(int argc, char **argv) { LoadFile(); Node *temp; char *key; switch (GetUserInput()) { case 1: temp = malloc(sizeof(Node)); printf("\nEnter the key of the new node: "); scanf("%s", temp->key); printf("\nEnter the value of the new node: "); scanf("%s", temp->value); AddNode(...

Proper use of UIApplicationMain

I have decided to load my views programmatically, so putting: int ret = UIApplicationMain(argc, argv, nil, nil); Would not work. I do have a ViewController and an AppDelegate, though. What would be the proper use of UIApplicationMain to use a ViewController and an AppDelegate. PS I am NOT using XCode or Interface Builder, I am develop...

Inheriting the main method

I want to define a base class that defines a main method that instantiates the class, and runs a method. There are a couple of problems though. Here is the base class: public abstract class Strategy { abstract void execute(SoccerRobot robot); public static void main(String args) { Strategy s = new /*Not sure what to...

TCHAR* envp[]: What is it?

I created a VC++ console project with Visual Studio and it auto-generated this function: int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { ... } I was just wondering what envp stands for and how/when I can/should use it? Thank you! ...

In languages where you have a choice, is it better to put the main function/method/code at the top or bottom?

When you're writing a program that consists of a small bit of main logic that calls a bunch of supporting functions, you can choose either put the main logic at the top of the file or the bottom (Let's assume the language allows either.) Which is better? Should I put my main logic at the beginning of the file or the end, after all the su...