Back to The tech awesomeness
Table of contents
Java chapters

The article for today.

While I was thinking sometime ago about the creation of null references and its implications, the following interface as an idea came to my mind.

 * @author oleksii kyslytsyn
public interface Is { /* 'Є' for its name in Ukrainian, meaning 'to be' for 
third person would be shorter, but 'Ye', 'Je' would be even more well-readble 
and then again 'Is' for its name is also readable and in English */
    static boolean such(final Object object) {
        return object != null;

And right after previous interface I got an idea for its rather relative interface:

 * @author oleksii kyslytsyn
public interface No {
    SessionProfile SESSION_PROFILE = null;
    Profile PROFILE = null;
    StopWatch STOP_WATCH = null;
    Object NO = null;
    Authentication master
    String localeString
    Locale locale
    static boolean such(final Object object) {
        return object == null;

I was considering to unite these two interfaces with their corresponding methods into single interface, named, for example, 'Statement' or 'Such', and later I droped that idea, because of possible usage patterns:

    if ( Statement.isSuch(color) ) { /* ... */ }

    if ( ) { /* ... */ }

    if ( ) { /* ... */ }
    if ( userProfile == No.PROFILE ) { /* ... */ }

    if ( Is.such(color) ) { /* ... */ }

    if ( color == null ) { /* ... */ }

    if ( answer == No.NO ) { /* ... */ }

Essentially, all of these interfaces, I thought of, were about encapsulation of null and labeling it with a finite value naming among possible ones. It should be better in deed.

Still existing java syntax for null checks is the shortest invocation in terms of code size, additionally, that it does not require another import and another method invocation.

Why could it matter at least till some extent after all?

The evident meaning for null is not always the same.

Some authors use null not only for indication of non-initialisation, and as well for indication of objection, others use it for indication of emptiness, and others use it for indication of absence. There could be probably more of the patterns for its usage.

Moreover sometimes, it is even mixed in the same context of code.

One advantage would be its readability for its usage and after its usage:

    if ( Is.such(programmingLanguage.getSyntax().getRules().isFinite()) ) {/* ... */}
    if ( No.such(data) ) { /* ... */ };
    assert Is.such(object) ;
    assert object != null ;
    No.such( masterpiece ) ? createMasterpiece() : masterpiece;
    if ( No.such(color) || picture.isMonochrome() ) {};
    if ( Is.such(color) || colorMode.isWavelength() ) {};

The ideal for me then is a human language syntax in programming language, so that a human with linguist profession would become almost proactively and automatically a human with better alacrity for development activities using such programming language than the human with developer profession on its own from the start. Of course, with a help of developers and scientists for such a programming language. For example,

    if these programming language's syntactic rules are finite, then...
    if there is no such data, then...
    verify that such object is ok.
    assert that object is in place.
    if that masterpiece is not existing, then it is better to create it or investigate similar masterpieces.
    if such color does not exist and the picture is monochrome, then...
    if attached color is well-known and current color mode is measured by wavelength, then...

Historically null is added already in java programming language so, it is therefore only an small addon for java programming language in projects, which is not interfering with the language implementation itself, such as its virtual machines. As almost any other addon, it could be used or be skipped.

One of the biggest disadvantages of this solution in my opinion is an inherent knowledge and other types of so called 'need to know' for these interfaces' file locations as a requirement.

Another disadvange is that this interface addition in a file looks like more a cosmetic addon and what is also called 'syntactic sugar' in computer science, than something valuable.

Also the disadvantage, that I was looking mainly for these two interfaces from my point of view within conditionals in java programming language.

Because of its addon nature, the following usages are possible only after import of these interfaces:

    assert Is.such(Is.class);
    assert Is.such(No.class);
    assert (Ye.class != null);
    assert (No.class != null);