I'm new to java development.
If i am writing a somewhat complicated program,
I hear that it is not good to write all processing in the main method.
What aspects aren't good?
In particular, I would like to ask what kind of problems there are in terms of quality control.
For beginners of development, I'm sorry, but I would like you to explain as much as possible.
Please give me an answer.
Are there any obstacles that could be a problem in the testing process?
Answer # 1
I'm talking about thought ...
Opinions from people who have been working as programmers for about 3 years.
For example, if everything is written in main, it will be written in one file.
First of all, if you have this in mind, the following issues arise:
When implementing complex processing, there are opportunities to diversify similar processing.
In the unlikely event that the code needs to be modified, all modifications will be required.
By making the processing common, it becomes a preventive measure against malfunctions by eliminating omissions and eliminating waste.
If you edit the same file with multiple people, it's easy to get problems,
It is preferred to implement separately.
Reading source code
If everything is written only in main, what processing means what?
There is a problem that you cannot understand unless you understand all of these points.
In principle, you can understand the contents of the implementation without reading the program by reading the design specifications.
However, if you list everything in one, it is highly likely that only the creator will understand.
In addition, Java is generally developed in an object-oriented manner.Conclusion
Considering that, it is a very big problem to list only main.
In my opinion, if you consider two points: "maintainability" and "general versatility", I think that it should not be written only in main.
I don't think it's a reason to praise it if it's developed by one person,
If you want to respond flexibly and quickly, it is better to subdivide into classes and methods, and to use different development methods depending on your needs.
Answer # 2
Writing such a program means that the author of the program does not understand the meaning and significance of object thinking, classes, and methods. And code written without understanding them"No maintainability" "No extensibility" "Bugs are easy to get out" "It is difficult to follow processing" "Not functional unit" " "It ’s not portable".
Java is designed with an emphasis on object thinking as it is called an object thinking language, but writing everything in main meansthrowing them allThere is nothing else.
Answer # 3
If it is a very simple program that can be written in one main and only needs 10 or more lines, that's fine.
If a larger scale program is written with one function, it will be difficult to grasp.
Answer # 4
Consider writing a sentence instead of a program.
If it is short, you can do it with one sentence.
As it gets longer, there will be more than one sentence.
If it becomes longer, it will be divided into paragraphs.
Next, we will divide into chapters or books.
In comics, there are one-frame comics and four-frame comics, but they are usually divided into chapters and volumes.
Writing everything in main () in a program is
It is equivalent to writing with one sentence and writing with only one frame.
Answer # 5
I can only think of a problem.Suppose you create an application with the constraint that
methods should not be created.
・ Since the same process cannot be made into a method, the same code must be written.
If this process is wrong, you must make corrections at all points.
・ There are many local variable conflicts, and it is impossible to grasp where the variables are used.
・ All field variables must be static
・ Because we cannot narrow down influence range, we cannot debug.
- where and how should i write the same contents that i want to reference from another class in java?
- java - code of error diffusion method in processing
- how to write java method arguments
- [java] why is it possible to write the iterator's next method in the conditional expression of the while statement?
- java - intelij replacement method
- swift - method processing order
- a method of adding multiples of 3 when java while num is 100 or less
- java - about the end of processing waiting for communication reception of bufferedinputstream
- java - i want to call an overloaded method with polymorphism
- return value of indexof method of java array list becomes -1
- Python learn to write data to file and save method
- xUnit write ASPNET Core unit test method
- java - about expansion and contraction processing of processing
- java - processing does not end with multidimensional array
- java method void
- java - about jpeg image compression method
- regarding the error resolution method "add unimplemented method" in java eclipse spring boot does not appear in your e
- java - [processing] give direction vector to boids(flocking) program by mouse click
- java - i want to write the time data acquired at regular intervals to csv
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved