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 370953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:04:05+00:00 2026-05-12T14:04:05+00:00

I write code primarily for personal use, but I’m considering releasing an application (scientific

  • 0

I write code primarily for personal use, but I’m considering releasing an application (scientific simulation/visualization) that I originally developed for personal use.

One of my habits is to use a main method in classes for testing the operation of the class in isolation. I figure that’s probably bad in someway (as are no doubt various other habits originating from self-teaching and the scientific development environment). However, it’s never been a problem for self-use stuff that I’ve noticed.

Would you all be so kind as to confirm (or deny) that the proliferation of mains is a problem for an application released to the scientific community (the source would also be open), and if so, why?

EDIT: To play devil’s advocate (okay, my advocate) relative to some of the offered answers: part of the “application use” is expected to be source modification by non-developers (the typical scientist) on a smallish scale. I know that on the receiving end, that having the tests for a class built directly into that class would be pretty straightforward for me to recognize and modify accordingly (especially if that were consistently the case for the classes). Would using something like JUnit provide similar utility, keeping in mind the audience?

ACCEPT DECISION: I think KLE’s answer is the best balance of thorough and succinct, so I picked it, but I think the discussion comments in Bill’s are also very helpful. I also don’t understand why Johannes’s answer was voted down – the “how does this piece work” perspective is very important to the scientific community coders – and while the other answers point out various reasons why separated unit tests are probably more useful than my current habit, they don’t really address that use, so his answer is far from “unhelpful”. Thanks to all current (and future) responders, and here’s to wishing there was a way to combine multiple responses as the correct answer!

  • 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-12T14:04:05+00:00Added an answer on May 12, 2026 at 2:04 pm

    JUnit lets you have tests, just like your mains, but also:

    • a main is typically only one method, that can get real big ; if extracting small methods used only for test, there is a risk to use that methods in regular code
    • doesn’t clutter the class itself with the testing methods, they are in a different class
    • allows inheritance in the test classes (main, as a static method, is impossible to inherit or reuse) ; typically, the setup before the actual test maybe pretty long, and reusing it naturally is great
    • a main has no result (success or failure), only an output ; you need to check manually the output to determine the result, and possibly understand it
    • allow execution of several tests (class, package, project, all) at once, which is required for regression testing (or you will spend your afternoon executing them one by one)
    • JUnit provide many additional features out of the box, like marking some tests as ignored, checking that a test is not too long, provide several launching UIs etc.
    • you can reuse some tests on each implementation or subclass (ex: checking for Liskov substitution), which allows you to test a lot without maintaining a lot of test code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write code in my controller that when run, will create a
I m trying write code that after reset set up rrpmax as 3000. It
I'm trying to write code that will load an image from a resource, and
The novice understanding of Node is that if I re-write synchronous, or in-line code,
I intend to write a small application to scratch a personal itch and probably
I am trying to write code for getting my cords on the mobile. I
How do I write code to connect through Windows VPN client? I want this
When I write code in Python with exception handling I can write code like:
How could I write code to get all the action names from a controller
I occasionally write code something like this: // file1.cpp #define DO_THIS 1 #if DO_THIS

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.