M
M
Marat2016-02-03 09:43:13
Java
Marat, 2016-02-03 09:43:13

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

6 answer(s)
S
sirs, 2016-02-03
@sirs

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).

E
Evhen, 2016-02-03
@EugeneP2

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.

A
Aleksey Pleshkov, 2016-02-03
@AlekseyPleshkov

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.

V
VZVZ, 2016-02-03
@VZVZ

> Java
> correct use of OOP...
There is no such thing.

A
asd111, 2016-02-03
@asd111

Intelli IDEA Community
https://github.com/JetBrains/intellij-community

A
angry_cellophane, 2016-02-11
@angry_cellophane

Not java core, but still - look at guava sorts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question