Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1023143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:34:15+00:00 2026-05-16T11:34:15+00:00

You can actually just skip this first part cause it gets confusing, but I’ll

  • 0

You can actually just skip this first part cause it gets confusing, but I’ll keep it here cause I want to know if anyone else feels the same way. I am a CS undergrad who has have been using Java for 3 years, and I still find it difficult to comprehend how to include the Main function into my design. It feels wrong to place it in a class all on its own, but it also feels wrong to insert it into another class file. I see the latter as such because it doesn’t fit in with the rest of the class making it incohesive. I can’t just stick a main function on my DocumentReader object, for example. It would have nothing to do with the object. On the other hand, I can’t just make a Main class that only has a main function inside it because in object-oriented programming, you’re supposed to think in terms of objects effectively creating a miniature world in your head. For that miniature world to revolve around a single object that does nothing but exist just seems off. It doesn’t act as a narrator and character in a story because it does nothing, at the same time. I prefer C’s style of having a Main function that is separate from everything. It keeps the narrative of the story separate from the characters that are interacting with one another.

I want to know how the professionals mix the main method into the rest of their code. How do you make it fit in with the rest of the design. Also, are they generally long or short?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:34:16+00:00Added an answer on May 16, 2026 at 11:34 am

    I keep the main() function in a class named as my project. With this when you launch the application with the command line you type :

    java com.domain.project.ApplicationName
    

    It seems to me logic to have a simple Launcher name rather than :

    java com.domain.project.AClassWhichDoesntLookLikeAMainClass
    

    or the (too) classic

    java com.domain.project.Launcher
    

    But don’t bother too much for this class, it will probably never be executed by the end user like this. A script or another executable will launch it most of the time.

    Another thing, your main() method can get heavy, especially if you really use main args for more CLI options. Maybe it deserves its own class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure what this practice is actually called, so perhaps someone can edit
Last year, Scott Guthrie stated You can actually override the raw SQL that LINQ
Can someone give an example of a good time to actually use unsafe and
Can anyone link me to a decent c++ tutorial that's actually currently in date?
Is it at the state where it is actually useful and can do more
What program can I use to decompile a class file? Will I actually get
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can you cast a List<int> to List<string> somehow? I know I could loop through
can you recommend some good ASP.NET tutorials or a good book? Should I jump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.