
Terminology is the most important thing in any business. Without agreeing on terms it is impossible to succeed. What's wrong with programming? In particular in Java? Not very good, if not bad.
There seems to be no clear agreement even on basic terms. For example, if I say “inner class,” what would you think? I bet there will be more than one version of what is meant. And this is very bad. creates difficulties in communication and not only.
How is this situation corrected usually - GOST standards are issued. These GOSTs have the addition "Terms and definitions". For example - GOST R 7.0.8.-2013 “Record Keeping and Archiving - Terms and Definitions”.
But GOSTs are boring. Therefore, below I will give my contribution to eliminating chaos, at least in terms of terminology regarding Java classes.
')
So, in Java there are classes:
- “Radiant” - all classes are “radiant”. If you say “I wrote a radiant class,” it will mean that this is some of the following classes, that's all. All the classes listed below are “radiant”!
- “Soaring class” is a class, the description of which begins immediately after the “package” and “import” sections of the source .java file.
- “Sneaking” (sneaking class) - stealing classes 'live' (defined) only inside the “soaring”. This is a generic term for the following types of classes.
- The “sizzling class” is a static class declared directly inside the “soaring”
- "Piercing" (piercing class) - this is NOT a static class declared directly inside the "soaring"
- "Shadowy class" is an anonymous class.
- The “scammer” (yawing class) is a local class. Declared in code blocks (in class methods), as well as “shadow-like”
Specification just in case: in this scheme, "Radiant" is a generalization for all types of classes in general, and "Prowling" is a generalization for all those "Radiant" classes that are not "Soaring".
Read more
Soaring- The main type of classes is located directly on the “top level” of the source .java files.
SizzlingExample:
- essentially no different from the floating class, except for the place of your ad
- does not have access to non-static elements of its parent soaring class
Piercing (piercing)Example:
- has access to all elements of the parent soaring class
- cannot have static ads
- not being declared as public can only be instantiated within its parent soaring class
ShadowyExample:
new Thread(new Runnable() { public void run() { ... } }).start();
- located inside blocks of code (in methods). All other classes are first written with the assignment of a name and then this name is somehow used. The same class is written without a name and is immediately used with the new operator, i.e. immediately instantiated
- has access to the elements of the framing class
- It has access to the local elements of the enclosing code block (for method variables, for example)
- cannot define static elements inside itself except static final
Jumping (yawing)Example:
- located inside blocks of code (in methods)
- has access to the elements of the framing class
- It has access to the local elements of the enclosing code block (for method variables, for example)
- visible only within the block where defined
- cannot be declared private, public, protected or static
- cannot define static elements inside itself except static final
Conclusion
I gave this terminology the name [ydax] - a random, but unique name within me, generated by a special script.
And now let us rejoice brothers and sisters - there is less haoas in this world! Use this terminology, and if someone will not understand something - throw a link to this article. Goodbye)
PS This article can be taken for banter, but it is not - in each joke only a fraction of the joke)
PPS if where the wrong information led - correct me