« Java JSR » : différence entre les versions

De Lillois Fractale Wiki
Aller à la navigation Aller à la recherche
Contenu ajouté Contenu supprimé
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 35 : Ligne 35 :
*real-derived operations + - * / (with the restriction that the result is transformed into 1.0 (true) if it exceeds 1.0, and into 0.0 (false) if it falls below 0.0.
*real-derived operations + - * / (with the restriction that the result is transformed into 1.0 (true) if it exceeds 1.0, and into 0.0 (false) if it falls below 0.0.


== Access control to class variables (goodbye to getters and setters) ==


Access to class variables in java is determined mainly by the modifiers <span style="font-family:courier new,courier,monospace;">public protected private</span> (and <span style="font-family:courier new,courier,monospace;">final</span>)
== Access control to class variables ==

Access to class variables in java is determined mainly by the modifiers public protected private (and final)


This does not allow to distinguish between read access and write access.
This does not allow to distinguish between read access and write access.
Ligne 60 : Ligne 59 :
*<span style="font-family:courier new,courier,monospace;">'''rrr'''</span>
*<span style="font-family:courier new,courier,monospace;">'''rrr'''</span>
*<span style="font-family:courier new,courier,monospace;">'''rrn'''</span>
*<span style="font-family:courier new,courier,monospace;">'''rrn'''</span>
*<span style="font-family:courier new,courier,monospace;">'''rnn'''</span> (equivalent to <span style="font-family:courier new,courier,monospace;">private final</span>)
*<span style="font-family:courier new,courier,monospace;">'''rnn'''</span> (equivalent to <span style="font-family:courier new,courier,monospace;">private final</span>)


== Depending vars ==
== Depending vars ==

Version du 23 juillet 2018 à 19:54

Suggested improvements for the java langage

This page contains several improvements suggested for the java langage - my favorite programmind and thinking langage.

They would possibly be translated into JSRs, if this is not too complex and dissuasive.

Together, they describe the langage that would have loved to use...

Fuzzy primitive type

Besides the existing primitive types, it is suggested to add the fuzzy type, which may be consisdered as a mix of boolean and real value.

A fuzzy variable would be used to represent fuzzy logic values, probabilities, ad generally speaking real values in the [0.0,1.0] range. Example of computing and mathematics concepts are : saturation levels, permeabilities, similarities, etc...  

The code of an AI project using fuzzy logic would certainly be easier to write, read, understand and maintain (fuzzy logic is a key of AI - see Alex project) 

The fuzzy type should be involves in various casting process

  • fuzzy -> boolean
  • boolean -> fuzzy
  • real (double or float) -> fuzzy
  • fuzzy -> real (double or float)

Fuzyy variable should then be usable wherever boolean vars are used, like in if and while statements.

The displayed value (toString()) of a fuzzy var may be true, false or a real value between (excluding) 0.0 and 1.0 ;  true is a short form of 1.0 , false is a short form of 0.0. 

Operations on fuzzy variable should include

  • not (!x) :   !x == (fuzzy)(1.0-(real)x)
  • and (x&&y) :  x&&y ==  (fuzzy)((real)x * (real)y)
  • xor (x^^y) :  x^^y ==
  • or (x||y) : x||y ==
  • real-derived operations + - * / (with the restriction that the result is transformed into 1.0 (true) if it exceeds 1.0, and into 0.0 (false) if it falls below 0.0.

Access control to class variables (goodbye to getters and setters)

Access to class variables in java is determined mainly by the modifiers public protected private (and final)

This does not allow to distinguish between read access and write access.

As an indirect effect, the lack of read / write modifiers is generally circumvented by the sued of numeropus heavy getXXX() and setXXX() mothods, making the code heavy.

It is suggested here to define access to variable using a more granular modifier set.

The modfiers is defined as a 3-chars sequences. The first one related to this class, teh second one to this package, and the third one to the reste of the world.

Each char may be 'w' (read and write access) 'r' (read only access) and 'n' (no access).

The allowed values are:

  • www (equivalent to public)
  • wwr
  • wwn (equivalent to protected)
  • wrr
  • wrn
  • wnn (equivalent to private)
  • rrr
  • rrn
  • rnn (equivalent to private final)

Depending vars

Primitive type simplification

Simplified min affcat