This HTML5 document contains 37 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

Namespace Prefixes

PrefixIRI
dctermshttp://purl.org/dc/terms/
dbohttp://dbpedia.org/ontology/
foafhttp://xmlns.com/foaf/0.1/
dbpedia-huhttp://hu.dbpedia.org/resource/
n12https://global.dbpedia.org/id/
dbthttp://dbpedia.org/resource/Template:
rdfshttp://www.w3.org/2000/01/rdf-schema#
freebasehttp://rdf.freebase.com/ns/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
owlhttp://www.w3.org/2002/07/owl#
wikipedia-enhttp://en.wikipedia.org/wiki/
dbphttp://dbpedia.org/property/
dbchttp://dbpedia.org/resource/Category:
provhttp://www.w3.org/ns/prov#
xsdhhttp://www.w3.org/2001/XMLSchema#
wikidatahttp://www.wikidata.org/entity/
goldhttp://purl.org/linguistics/gold/
dbrhttp://dbpedia.org/resource/

Statements

Subject Item
dbr:Constant_interface
rdfs:label
Constant interface
rdfs:comment
In the Java programming language, the constant interface pattern describes the use of an interface solely to define constants, and having classes implement that interface in order to achieve convenient syntactic access to those constants.However, since constants are very often merely an implementation detail, and the interfaces implemented by a class are part of its exported API, this practice amounts to putting implementations details into the API, which was considered inappropriate by, e.g., Java designer Joshua Bloch. In general, collecting system constants into classes independent of behaviour might create a poor object-oriented design because it is often a sign of low cohesion. For these reasons, constant interfaces may be considered an anti-pattern.
dcterms:subject
dbc:Java_(programming_language) dbc:Anti-patterns
dbo:wikiPageID
21871116
dbo:wikiPageRevisionID
988978011
dbo:wikiPageWikiLink
dbr:Interface_(Java) dbr:Static_import dbr:Binary_code_compatibility dbr:Anti-pattern dbr:Object-oriented dbc:Java_(programming_language) dbr:Design_pattern_(computer_science) dbr:Run_time_(program_lifecycle_phase) dbr:Joshua_Bloch dbr:Java_5 dbr:Cohesion_(computer_science) dbr:Compile-time dbr:Java_programming_language dbr:Class_(computer_science) dbr:Marker_interface_pattern dbr:Namespace dbc:Anti-patterns
owl:sameAs
n12:4iK5X dbpedia-hu:Konstans_interfész wikidata:Q5163653 freebase:m.05pbr4c
dbp:wikiPageUsesTemplate
dbt:Reflist dbt:NPOV dbt:OR
dbo:abstract
In the Java programming language, the constant interface pattern describes the use of an interface solely to define constants, and having classes implement that interface in order to achieve convenient syntactic access to those constants.However, since constants are very often merely an implementation detail, and the interfaces implemented by a class are part of its exported API, this practice amounts to putting implementations details into the API, which was considered inappropriate by, e.g., Java designer Joshua Bloch. In general, collecting system constants into classes independent of behaviour might create a poor object-oriented design because it is often a sign of low cohesion. For these reasons, constant interfaces may be considered an anti-pattern. Use of this pattern has a few other downsides: 1. * It pollutes the class namespace with read-only variables that may not be of use. 2. * Contrary to the compile-time tactical utility of implementing a constant interface, the incidental run-time artifacts have little practical purpose (cf. marker interfaces which also have no methods but are useful at run-time). 3. * If binary code compatibility is required in future releases, the constant interface must remain forever an interface (it cannot be converted into a class), even though it has not been used as an interface in the conventional sense. 4. * Without an IDE that resolves where the constant are coming from, tracking it back to its containing class or interface can be time consuming. 5. * An instance of the interface is syntactically no more useful than the interface name itself (since it has no methods). 6. * Unless a developer checks any implemented interfaces when adding a constant to a class, or does so but makes a typo in the name of the added constant, the value of a constant can be silently changed. Consider Example 2 below. Note that the Java libraries use constant interface pattern themselves, showing that it may be a reasonable choice in some situations.
gold:hypernym
dbr:Part
prov:wasDerivedFrom
wikipedia-en:Constant_interface?oldid=988978011&ns=0
dbo:wikiPageLength
5375
foaf:isPrimaryTopicOf
wikipedia-en:Constant_interface
Subject Item
dbr:Static_import
dbo:wikiPageWikiLink
dbr:Constant_interface
Subject Item
wikipedia-en:Constant_interface
foaf:primaryTopic
dbr:Constant_interface