Meta tags:
Headings (most frequently used words):
2021, september, blog, java, monday, march, 27, friday, this, technical, affiliations, not, if, null, else, the, of, with, inspired, by, actual, events, dustin, pages, 2023, saturday, 25, 17, wednesday, 15, thursday, 26, license, disclaimers, search, translate, archive, labels, subscribe, to, my, non, similar, blogs, popular, posts, software, development, support, wikipedia, openjdk, 21, compiler, warning, on, constructor, calling, overridable, methods, more, frequent, long, term, releases, jdk, 18, code, snippets, in, api, documentation, optional, does, supplant, all, traditional, or, checks, case, missing, jeps, surprisingly, high, cost, variables, capitalized, names, implementing, equals, object, instanceof, pattern, matching,
Text of the page (most frequently used words):
the (240), this (109), and (100), java (94), code (82), for (80), that (68), jep (60), with (47), null (44), new (43), jdk (41), not (33), are (29), var (27), september (27), optional (27), highlighter (25), #method (24), class (23), lts (22), date (21), share (21), have (20), function (19), return (19), value (19), use (19), march (19), openjdk (19), object (19), from (19), returned (19), match (18), index (18), years (18), has (18), jeps (18), snippet (18), one (17), constructor (17), can (16), may (16), was (16), january (16), february (16), 2021 (16), warning (16), but (16), more (16), document (15), december (15), june (15), out (15), final (15), escape (15), str (14), release (14), november (14), april (14), july (14), used (14), snippetexample (14), releases (14), div (13), name (13), october (13), august (13), been (13), two (13), will (13), javadoc (13), xlint (13), string (12), instanceof (12), examples (12), public (12), 187 (12), check (11), link (11), blog (11), methods (11), serialization (11), post (11), dustin (11), when (11), than (11), also (11), replace (10), developers (10), being (10), names (10), pattern (10), identifiers (10), void (10), snippets (10), documentation (10), newinstance (10), forward (10), reinhold (10), doc (9), sender (9), regexp (9), length (9), comments (9), tag (9), equals (9), non (9), called (9), empty (9), matching (9), which (9), message (9), approach (9), list (9), every (9), type (9), package (9), instance (9), iframe (8), createelement (8), else (8), matches (8), support (8), source (8), flashcopier (8), now (8), dustinmarx (8), development (8), there (8), classes (8), oracle (8), 2014 (8), labels (8), any (8), feature (8), states (8), cannot (8), private (8), proposal (8), generated (8), window (7), toolbar (7), css (7), software (7), via (7), time (7), using (7), based (7), because (7), had (7), its (7), only (7), general (7), pinterest (7), facebook (7), blogthis (7), email (7), example (7), advantage (7), all (7), read (7), variables (7), shown (7), what (7), timenowms (7), println (7), 145 (7), process (7), 413 (7), moving (7), faster (7), label (6), func (6), wnd (6), utils (6), true (6), regex (6), html (6), since (6), util (6), thing (6), ago (6), would (6), early (6), posts (6), javaone (6), 2012 (6), calling (6), 2023 (6), their (6), variable (6), these (6), long (6), static (6), types (6), does (6), above (6), present (6), even (6), rather (6), closed (6), three (6), directly (6), optionalreturn (6), override (6), overridable (6), abstract (6), about (5), while (5), false (5), lines (5), beginning (5), objects (5), available (5), instead (5), access (5), posted (5), days (5), whether (5), checking (5), other (5), goetz (5), points (5), related (5), dev (5), mailing (5), our (5), conventions (5), reading (5), first (5), convention (5), language (5), keywords (5), listed (5), such (5), same (5), timeunit (5), demonstrates (5), following (5), both (5), disappearance (5), draft (5), numbers (5), enhancement (5), traditional (5), isempty (5), next (5), over (5), year (5), replied (5), move (5), constructorcalls (5), parentwithabstractmethod (5), initializecustomlogic (5), warnings (5), protected (5), close (4), open (4), version (4), classname (4), commands (4), cmd (4), continue (4), min (4), parsing (4), you (4), recently (4), groovy (4), own (4), made (4), make (4), small (4), welcome (4), commit (4), changes (4), single (4), ptypes (4), manner (4), where (4), capitalized (4), lowercase (4), section (4), different (4), word (4), letter (4), naming (4), provides (4), makes (4), difficult (4), think (4), some (4), import (4), really (4), tomillis (4), before (4), run (4), most (4), surprisingly (4), compiled (4), withdrawn (4), state (4), like (4), better (4), number (4), features (4), just (4), less (4), ofnullable (4), way (4), substring (4), cadence (4), term (4), src (4), constructorcallsdemonstration (4), child (4), trigger (4), contentwindow (3), width (3), height (3), copystyles (3), write (3), innerhtml (3), fixforblogger (3), prototype (3), result (3), getmatches (3), exec (3), appendchild (3), clipboardswf (3), view (3), clipboarddata (3), style (3), syndicated (3), complete (3), dates (3), pass (3), postgresql (3), generally (3), arrays (3), enums (3), blogs (3), months (3), guava (3), build (3), windows (3), html5 (3), 2011 (3), stated (3), ability (3), net (3), similar (3), observations (3), review (3), compiler (3), archive (3), here (3), remain (3), regarding (3), effort (3), external (3), inspired (3), actual (3), events (3), several (3), see (3), into (3), express (3), uses (3), how (3), often (3), implemented (3), update (3), standard (3), implementation (3), take (3), core (3), libs (3), provide (3), letters (3), led (3), conclusion (3), programming (3), should (3), well (3), mentally (3), local (3), instantiation (3), main (3), arguments (3), datenow (3), listing (3), surprised (3), projects (3), seen (3), current (3), project (3), author (3), change (3), cost (3), cache (3), completely (3), needed (3), possible (3), changeset (3), internet (3), exist (3), end (3), status (3), rejected (3), far (3), describes (3), proposed (3), targeted (3), target (3), candidate (3), submitted (3), useful (3), digit (3), currently (3), roadmap (3), proposals (3), another (3), extra (3), logic (3), output (3), ifpresent (3), methodpotentiallyreturningnull (3), add (3), conditional (3), processing (3), returnobject (3), details (3), application (3), including (3), itself (3), level (3), highlight (3), appear (3), api (3), them (3), behalf (3), adds (3), must (3), javac (3), overridableinitializer (3), extending (3), focus (2), print (2), alert (2), body (2), removechild (2), _blank (2), scrollbars (2), strings (2), create (2), command (2), indexof (2), parentnode (2), sourcedoc (2), links (2), addcontrols (2), collapse (2), showcolumns (2), span (2), split (2), push (2), attribute (2), syntaxhighlighter (2), originalcode (2), clipboard (2), text (2), your (2), 0px (2), left (2), 500px (2), 2007 (2), affiliations (2), geeks (2), dzone (2), javaworld (2), worked (2), pgsql (2), very (2), numerous (2), interfaces (2), added (2), get (2), include (2), least (2), implementing (2), multiple (2), reasons (2), custom (2), demonstrations (2), rmoug (2), perform (2), filtering (2), collections (2), framework (2), introduces (2), checks (2), provided (2), questions (2), part (2), thoughts (2), blogging (2), technical (2), kind (2), atom (2), subscribe (2), loading (2), publications (2), jax (2), 2016 (2), 2013 (2), 2010 (2), javafx (2), idea (2), flex (2), commons (2), 2017 (2), 2019 (2), necessarily (2), respective (2), content (2), sites (2), writing (2), were (2), under (2), license (2), home (2), older (2), statement (2), feedback (2), associated (2), statements (2), always (2), concludes (2), key (2), past (2), lang (2), introduced (2), surprising (2), applying (2), operator (2), finalized (2), preview (2), friday (2), allow (2), running (2), camelcase (2), believe (2), readability (2), previously (2), consists (2), note (2), includes (2), reference (2), boolean (2), although (2), simple (2), who (2), quickly (2), known (2), accepted (2), complicated (2), assumption (2), allows (2), case (2), occurrences (2), system (2), exactly (2), bad (2), duplicateidentifiersdemo (2), after (2), future (2), across (2), perhaps (2), during (2), libraries (2), however (2), fields (2), they (2), find (2), responses (2), mercurial (2), wayback (2), machine (2), original (2), evidence (2), did (2), explanation (2), remove (2), appears (2), removed (2), 154 (2), additional (2), transitions (2), jbs (2), infrastructure (2), yet (2), bug (2), through (2), address (2), overview (2), results (2), efforts (2), rarely (2), wrapping (2), likely (2), worth (2), within (2), fluent (2), apis (2), bit (2), then (2), consumer (2), basic (2), come (2), goes (2), necessary (2), developer (2), pre (2), response (2), github (2), red (2), files (2), fragments (2), separate (2), preferred (2), addresses (2), shortcomings (2), jdk18 (2), emphasis (2), 8201533 (2), https (2), processit (2), intended (2), supported (2), syntax (2), included (2), introduce (2), inline (2), declare (2), fragment (2), released (2), schedule (2), reducing (2), between (2), builds (2), discussed (2), hale (2), many (2), users (2), frequent (2), tene (2), burden (2), team (2), great (2), right (2), enterprises (2), his (2), motivation (2), ship (2), mark (2), little (2), four (2), competitive (2), monday (2), suppressed (2), csr (2), cause (2), sub (2), lead (2), subclass (2), fully (2), initialized (2), demonstrate (2), privateinitializer (2), finalinitializer (2), parent (2), calls (2), lint (2), beta (2), printing, dialog, 300, 150, aboutdialog, tools, destdoc, getelementsbytagname, isbloggermode, regexlib, multilineccomments, singlelineccomments, singlelineperlcomments, doublequotedstring, singlequotedstring, nogutter, tabstospaces, wrapcolumn, sortcallback, addbit, test, bar, columns, showevery, trim, math, cdata, undefined, powered, blogger, wikipedia, expandsource, expand, collapsed, viewsource, plain, 750, 400, location, resizable, menubar, copytoclipboard, copy, setdata, printsource, csstext, position, absolute, top, 2004, alex, gorbatchev, http, www, dreamprojections, com, portions, javalobby, profile, nearly, times, formatting, handy, collection, stored, array, easy, passing, significant, coverage, announced, approximately, hold, commonly, writte, fortunate, enough, newly, obvious, choice, hashcode, tostring, might, want, relying, default, serializing, serializable, attributes, downloaded, laptop, programdata, javapath, decided, opera, training, picker, conveniences, easily, transformation, operations, transforming, collections2, isnullorwhitespace, white, space, popular, advanced, stump, chump, interview, bill, jackson, ruminations, log4j, fixes, auto, reconfigure, thread, leak, michael, ramblings, bigip, silly, reason, connection, error, ssl_hs_rxhello, 7295, unsupported, techstacks, quidi, vidi, practical, xquery, xml, wildfly, web, visualvm, vista, valhalla, unit, testing, testng, terracotta, swing, subversion, spring, management, 126, servlets, security, scala, ruby, rest, raspberry, puppet, properties, powershell, portals, poi, php, osgi, openxml4j, openlaszlo, nosql, noop, netbeans, mysql, mobile, maven, lucene, log4j2, linux, latex, kotlin, junit, json, jsf, jruby, jquery, jpa, jmx, jfreechart, jedit, jdeveloper, jdbc, jboss, jaxx, jaxb, javascript, 415, j2se, intellij, infinispan, humor, hazelcast, 147, gradle, glassfish, firefox, ecmascript, eclipse, dozer, docker, database, contributed, cloud, computing, clojure, cassandra, book, blazeds, arduino, apache, aop, ant, annotations, angularjs, android, amber, akka, air, actionscript, 185, 2008, 158, 2009, 156, 214, 112, 2015, 2018, 2020, translate, search, opinions, expressed, shared, employer, clients, organization, individual, trademarked, property, trademark, owners, guarantees, accuracy, usefulness, though, accurate, imply, endorsement, linked, animals, harmed, disclaimers, licensed, creative, attribution, international, marx, able, implement, fewer, improvement, nevertheless, converted, various, e9d913152cefda827e01c060a13f15eacc086b33, holdover, couldn, expression, almost, preferable, means, fall, back, control, flow, don, written, consistent, reminder, modified, brian, 8263358, leverage, ideas, begin, look, ubiquitous, believer, efficient, mental, reminded, greater, acceptance, particular, damaging, veer, constant, wondered, mentioned, tutorial, set, rules, kinds, allowed, choose, spell, capitalize, each, subsequent, prime, currentgear, gearratio, programs, mentions, literals, primitive, integer, int, tutorials, relatively, unusual, especially, experienced, learned, size, taking, coding, encountered, slightly, painful, parse, exact, realized, intuitively, initially, uppercase, instinctive, figure, hindering, put, special, allowing, myself, sharednames, concurrent, despite, measured, milliseconds, gettime, five, consecutive, daily, instances, represenative, hundreds, thousands, millions, career, baselines, articles, books, styles, represented, wide, variety, vast, majority, cases, constants, sometimes, differening, therefore, baseline, thankfully, otherwise, high, thursday, seems, rendered, obsolete, changing, developments, vanished, intact, compilation, aot, ahead, due, prevalent, speculation, similarly, explanations, removal, mostly, speculative, stackoverflow, question, fate, a16daa94ba0f, tweet, hotspot, disapperance, insuated, exploratory, titled, touched, towards, happened, unlike, fellow, moved, adding, suspicious, circumstances, surrounding, requests, lists, gone, unanswered, changesets, 5f24c115b6e6, 194, b2f990fa2dde, neither, documented, nor, unexpected, drop, delivered, integrated, evolved, potential, described, revised, shows, graphic, workflows, workflow, active, completed, funded, originally, could, finally, heading, remainder, range, generalized, inference, resolution, spi, month, 418, 101, incubator, modules, informational, template, collecting, reviewing, sorting, recording, enhancements, improvements, brief, discusses, mysterious, missing, wednesday, handles, needs, enjoy, simply, costs, chaining, work, shorter, still, comes, requires, invocations, further, feels, weird, immediately, follow, performed, becomes, wieldy, condition, demonstrateoptionalifpresentandisempty, variation, conjunction, form, doing, demonstrated, paradigm, essentially, call, versus, demonstrateoptionalusedlikenullused, involve, representative, occassionally, trying, explicit, detection, demonstratewithoutoptional, acting, tip, off, employs, against, invoked, doesn, mean, fact, expecting, common, real, flags, flag, addition, values, unfortunately, abuse, overuse, occasionally, clear, abused, supplant, contains, contained, concerns, metadata, implicitly, explicitly, specify, validated, presented, appropriate, placed, manipulated, editor, challenges, tags, comment, readable, viewed, presentation, distracting, approaches, summarizes, those, screenshot, capabilities, entrypoint, area, particularly, description, info, option, highlighted, sections, bold, tool, aka, bugs, browse, obtained, obtaining, performs, valuable, contrived, taste, brings, listings, file, objective, doclet, simplify, inclusion, covers, saturday, updates, accelerating, resources, latest, personal, plays, deals, frustration, versions, day, jobs, wait, updated, reflect, candence, designate, certain, intends, meaning, planned, quite, lot, people, week, prefer, good, library, maintainers, 10x, rémi, forax, nervous, yes, why, decision, nuanced, depends, perspective, taken, highly, resistant, upgrading, certifying, going, having, frequently, point, engineer, cycle, broadly, positive, biased, favour, feel, adverse, effects, upgrade, treadmill, andrew, redhat, azul, strong, maintenance, community, whole, opinion, gil, microsoft, engineering, endorse, user, ecosystem, prefers, stability, encourage, modernization, martijn, verburg, step, keep, vibrant, relevant, benefits, amazon, corretto, volker, simonis, request, already, interesting, thus, effect, line, developed, stable, ready, production, 2024, discussion, explains, excited, frustrated, away, employers, willing, deploy, applications, once, shipping, done, give, opportunities, increase, attractiveness, chief, architect, platform, group, adopt, strict, model, six, quarter, enabled, specifying, annotation, suppresswarnings, concrete, executing, generates, sourcepath, b15, extends, initialize, whose, notify, specifically, warn, constructors, avalable, background, justificatiion, 8299995, 6557145, 8015831, pages, select, formerly, concerning, cogitations, speculations,
Text of the page (random words):
ble on github this first contrived code listing makes use of snippet package dustin examples jdk18 javadoc demonstrates code snippet javadoc tag targeted for jdk as part of jep 413 aka bug jdk 8201533 ul li https openjdk java net jeps 413 li li https bugs openjdk java net browse jdk 8201533 li ul an instance of this class is obtained via my link newinstance method rather than via a constructor snippet final snippetexample instance snippetexample newinstance highlight substring newinstance instance processit public class snippetexample no arguments constructor not intended for public use use link newinstance instead to get an instance of me snippet final snippetexample instance snippetexample newinstance highlight substring newinstance private snippetexample preferred approach for obtaining an instance of me return instance of me public snippetexample newinstance return new snippetexample performs valuable processing public void processit when the above code is run through the javadoc tool with the private option code snippets are generated in the html for the class and no arguments constructor note also that the highlighted sections have bold emphasis in the generated html generated class level documentation with snippet generated method level documentation with snippet one area where i think the snippet may be particularly useful is in package documentation a code example of use for a package description is shown in the next code listing for package info java examples and demonstrations of javadoc related capabilities the main entrypoint for the snippets example is the link snippetexample class snippet final snippetexample instance snippetexample newinstance highlight substring snippetexample link substring snippetexample newinstance target snippetexample newinstance package dustin examples jdk18 javadoc the generated html output for this package level documentation is shown in the next screenshot one of the challenges in including code snippets in javadoc based documentation has been that the tags used to present the code such as pre code and code can make the javadoc comment less readable when viewed in source directly instead of via the generated html the snippet javadoc tag can make the code presentation better for the generated html while being less distracting in the source code itself jep 413 addresses the shortcomings of current approaches for including code snippets in javadoc and summarizes how snippet addresses those shortcomings a better way to address all these concerns is to provide a new tag with metadata that allows the author to implicitly or explicitly specify the kind of the content so that it can be validated and presented in an appropriate manner it would also be useful to allow fragments to be placed in separate files that can be directly manipulated by the author s preferred editor jep 413 contains far more details on application of snippet including the ability to reference code contained in external files by dustinmarx at september 25 2021 no comments email this blogthis share to x share to facebook share to pinterest labels java 18 friday september 17 2021 java s optional does not supplant all traditional if null else or if not null else checks java s addition of java util optional has been welcome and had led to more fluent code for methods that cannot always return non null values unfortunately optional has been abused and one type of abuse has been overuse i occasionally have run across code that makes use of optional when there is no clear advantage over using null directly a red flag that can tip off when optional is being used for no advantage over checking for null directly is when calling code employs optional ofnullable t against the returned value from the method it has just invoked as with all red flags this doesn t mean it s necessarily a bad thing to pass the returned value from a method to optional ofnullable t in fact it is necessary to pass to apis expecting optional but it is common for this approach to be used to provide no real value over using the returned value directly and checking it for null before optional was available code to check for null returned from a method and acting one way for null response and another way for non null response is shown next all code snippets in this post are available on github demonstrates approach to conditional based on code null or not code null that is traditional pre link optional approach public void demonstratewithoutoptional final object returnobject methodpotentiallyreturningnull if returnobject null out println the returned object is null else out println the returned object is not null returnobject code processing non null return object goes here for this basic conditional it s rarely necessary to involve optional the next code snippet is representative of the type of code i ve occassionally seen when the developer is trying to replace the explicit null detection with use of optional demonstrates using link optional in exactly the manner code null is often used conditional on whether the returned value is empty or not versus on whether the returned value is code null or not public void demonstrateoptionalusedlikenullused final optional object optionalreturn optional ofnullable methodpotentiallyreturningnull if optionalreturn isempty out println the returned object is empty else out println the returned object is not empty optionalreturn code processing non null return object goes here the paradigm in this code is essentially the same as the traditional null checking code but uses optional isempty to perform the same check this approach does not add any readability or other advantage but does come at a small cost of an additional object instantiation and method call a variation of the above use of optional is to use its ifpresent consumer method in conjunction with its isempty method to form the same basic logic of doing one thing if the returned value is present and another thing if the returned value is empty this is demonstrated in the following code demonstrates using link optional methods link optional ifpresent consumer and link optional isempty in similar manner to traditional condition based on code null or not code null public void demonstrateoptionalifpresentandisempty final optional object optionalreturn optional ofnullable methodpotentiallyreturningnull optionalreturn ifpresent it out println the returned object is not empty it if optionalreturn isempty out println the returned object is empty this code appears bit shorter than the traditional approach of checking the returned value directly for null but still comes at the cost of an extra object instantiation and requires two method invocations further it just feels a bit weird to check first if the optional is present and then immediately follow that with a check if it s empty also if the logic that needed to be performed was more complicated than writing out a message to standard output this approach becomes less wieldy conclusion code that handles a method s return value and needs to do one thing if the returned value is null and do another thing if the returned value is not null will rarely enjoy any advantage of wrapping that returned value in optional simply to check whether it s present or empty the wrapping of the method s returned value in an optional is likely only worth the costs if that optional is used within fluent chaining or apis that work with optional by dustinmarx at september 17 2021 6 comments email this blogthis share to x share to facebook share to pinterest wednesday september 15 2021 the case of the missing jeps the jdk enhancement proposal jep process is for collecting reviewing sorting and recording the results of proposals for enhancements to the jdk and for related efforts such as process and infrastructure improvements jep 0 is the jep index of all jdk enhancement proposals known as jeps this post provides a brief overview of current jdk enhancement proposals and discusses the surprisingly mysterious disappearance of two jeps jep 187 and jep 145 jdk enhancement proposal overview the jeps in the jep index with single digit numbers are process type jeps and are currently jep 1 jdk enhancement proposal roadmap process jep 2 jep template jep 3 jdk release process the jeps in the jep index with two digit numbers are informational type jeps are are currently jep 11 incubator modules jep 12 preview features the remainder of the listed jeps with three digit numbers in the jep index are feature type jeps and currently range in number from jep 101 generalized target type inference through jep 418 internet address resolution spi new candidate jep as of this month september 2021 finally there are some jeps that do not yet have jep numbers and which are shown in the under the heading draft and submitted jeps the jeps in this state do not yet have their own jep numbers but instead are listed with a number in the jdk bug system jbs originally a jep could exist in one of several different jep 1 process states draft posted submitted candidate funded completed withdrawn rejected active the explanation of evolved potential jep states is described in jep draft jep 2 0 draft 2 this document has a workflow section that states that the revised jep process has the following states and transitions for feature and infrastructure jeps and shows a useful graphic of these workflows this document also describes the states of a feature jep draft submitted candidate proposed to target targeted integrated complete closed delivered closed rejected proposed to drop neither these documented states for feature jeps nor the additional text that describes these state transitions describes a jep with a jep number rather than a jbs number being completely removed and this is what makes the disappearance of jep 187 serialization 2 0 and jep 145 cache compiled code unexpected the disappearance of jep 187 serialization 2 0 jep 187 is not listed in the jep index but we have the following evidence that it did exist at one time original message on openjdk core libs dev mailing list 14 january 2014 internet archive wayback machine 24 june 2014 14 45 39 2 july 2014 19 39 24 mercurial changesets openjdk jep jeps changeset 194 b2f990fa2dde 187 serialization 2 0 13 january 2014 openjdk jep jeps changeset 65 5f24c115b6e6 154 remove serialization 1 april 2012 it s surprisingly difficult to find any explanation for what happened to jep 187 unlike fellow serialization related jep 154 remove serialization which has been moved to status closed withdrawn jep 187 appears to have been removed completely rather than being present with a closed withdrawn status or closed rejected status adding to the suspicious circumstances surrounding jep 187 two requests on openjdk mailing lists regarding the state of this jep 14 december 2014 on core libs dev and 6 september 2021 on jdk dev have so far gone unanswered the reasons for the complete disappearance of jep 187 can be insuated from reading the exploratory document titled towards better serialization june 2019 i also previously touched on this in my post jdk 11 beginning of the end for java serialization the disapperance of jep 145 cache compiled code like jep 187 jep 145 is not listed in the jep index but there is evidence that it did exist at one time original message on openjdk hotspot dev mailing list 28 february 2012 28 february 2012 tweet internet archive wayback machine 5 may 2014 00 18 04 mercurial source openjdk jep jeps changeset 54 a16daa94ba0f 28 february 2012 also similarly to jep 187 it is surprisingly difficult to find explanations for the removal of jep 145 there is a stackoverflow question about its fate but the responses are mostly speculative but possible the most prevalent speculation regarding the disappearance of jep 145 is that it is not needed due to ahead of time aot compilation conclusion it seems that jep 187 serialization 2 0 and jep 145 cache compiled code have both been rendered obsolete by changing developments but it is surprising that they ve vanished completely from the jep index rather than being left intact with a closed or withdrawn state by dustinmarx at september 15 2021 no comments email this blogthis share to x share to facebook share to pinterest labels java general thursday september 9 2021 surprisingly high cost of java variables with capitalized names i ve read hundreds of thousands or perhaps even millions of lines of java code during my career as i ve worked with my projects baselines read code from open source libraries i use and read code examples in blogs articles and books i ve seen numerous different conventions and styles represented in the wide variety of java code that i ve read however in the vast majority of cases the java developers have used capitalized identifiers for classes enums and other types and used camelcase identifiers beginning with a lowercase letter for local and other types of variables fields used as constants and static fields have sometimes had differening naming conventions therefore i was really surprised recently when i was reading some java code not in my current project s baseline thankfully in which the author of the code had capitalized both the types and the identifiers of the local variables used in that code what surprised me most is how difficult this small change in approach made reading and mentally parsing that otherwise simple code the following is a represenative example of the style of java code that i was so surprised to run across code listing for duplicateidentifiersdemo java package dustin examples sharednames import java util date import java util list import java util concurrent timeunit import static java lang system out demonstrates ability to name variable exactly the same as type despite this being a really really really bad idea public class duplicateidentifiersdemo time now at instantiation measured in milliseconds private final static long timenowms new date gettime five consecutive daily instances of link date private final static list date dates list of new date timenowms timeunit days tomillis 1 new date timenowms new date timenowms timeunit days tomillis 1 new date timenowms timeunit days tomillis 2 new date timenowms timeunit days tomillis 3 public static void main final string arguments string string final date datenow new date timenowms for final date date dates if date before datenow string past else if date after datenow string future else string present out println date date is the string the code i encountered was only slightly more complicated than that shown above but it was more painful for me to mentally parse than it should have been because of the naming of the local variables with the exact same names as their respective types i realized that my years of reading and mentally parsing java code have led me to intuitively initially think of identifiers beginning with a lowercase letter as variable names and identifiers beginn...
|