Answer the question
In order to leave comments, you need to log in
What examples of correct Java code can you give?
Good afternoon!
For self-improvement...
Can you provide listings of the "correct" programs of the fathers of Java in terms of:
- Code formatting (CamelCase naming, indentation, commenting, etc.)
- Architecture (wide use of the standard Java class library, design patterns, correct use OOP...)
- Comfortable:
-- test coverage
-- handling of possible exceptions
-- multithread (if necessary)
-- the ability to use on different OS and architectures (that is, there is no binding to OS bitness, explicit directory separators in paths (ala ' \' or '/' ) etc., )
-- internationalization
And the task to be solved was moderately difficult, that is, not the search for the roots of a quadratic equation, but not the implementation of chess.
In terms of complexity ~ in the area of compiling crossword puzzles using a dictionary (as an example of working with a standard class library) or raytracing (as an example of architecture using OOP), etc. .
PS I mean Core Java examples.
Answer the question
In order to leave comments, you need to log in
Something tells me you're looking for a silver bullet, but it doesn't exist .
There is no such thing as perfect code, perfect pattern, perfect exception handling, etc.
Each pattern, each architectural solution perfectly suits a certain range of tasks, but this range of tasks is always limited. It is impossible to write code and say that this is a standard. If everything was so simple, the task of writing code would have been 100% automated by now.
What you are looking for can only come with experience and time.
Examples of solving specific problems - look on stackoverflow, "beautiful" code design - in open source frameworks on github ( https://github.com/spring-projects/spring-framework).
Why not start with the JDK? Download the sources and read on health :) By the
way, here is a good list of used OOP patterns in the JDK: Examples of GoF Design Patterns in Java's core lib...
"directories in paths (ala '\' or '/' )" - there is a constant for this separator in the java.io.File class
Sources: Spring Framework, Apache Commons, Guava, etc., in general, take any popular lib and look at the sources :)
Maven downloads libs, sources and documentation perfectly from the repository.
It may come in handy - habrahabr.ru/post/112042 . I often look there myself. And, as advised above, I also look at the code of open projects.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question