frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Maybe We Were Wrong About Blockchain

https://www.bloomberg.com/news/newsletters/2026-10-20/maybe-we-were-wrong-about-blockchain
1•monkeydust•33s ago•0 comments

WCS recrute un Chef de garage et un Gestionnaire de charroi

https://www.impactpool.org/jobs/1243049
1•kivuhub•34s ago•0 comments

Show HN: Local DirectML AI and Floating Toolstrip for PhotoCraft in Rust

https://github.com/kobaltgit/photocraft-companion
1•kobaltGIT•6m ago•0 comments

Artificial Domain Intelligence (ADI) – Embedded Intelligence for Appliances

https://github.com/Tem-Degu/adi
1•tomarche•7m ago•0 comments

Elon Musk confirms talks to merge Tesla and SpaceX

https://www.bbc.co.uk/news/articles/cmlyl09xjke4o
4•iamflimflam1•9m ago•0 comments

AI Slowdown, What Slowdown?

https://13trillionparameters.com/comics/003-the-slowdown
1•ed-is-ai•9m ago•1 comments

Accessibility in WordPress

https://blindaccessjournal.com/2026/10/an-open-letter-to-matt-mullenweg-on-accessibility-in-wordp...
1•edent•10m ago•0 comments

Survey: Any pains when you create a product demo video?

1•loveTech•11m ago•0 comments

AI for Music – a guideline for the responsible use of AI in music

https://aiformusic.info/
1•dr_kiszonka•12m ago•0 comments

Php.net Is Down

http://php.net/
1•thomasfromcdnjs•14m ago•0 comments

Anthropic Talk: The End of the Anthropocene

https://twitter.com/rdominguezibar/status/2111873903970881738
2•_ink_•14m ago•1 comments

Lego Getting More Adults to Tinker with Their Toy Bricks

https://www.wsj.com/business/retail/lego-adult-sets-gaming-formula-one-d7ccbc9d
2•bcaulfield•14m ago•0 comments

Using AI to Delete Code: Agentic Tech Debt Cleanup at Uber

https://www.uber.com/us/en/blog/ai-code-cleanup/
1•damowangcy•19m ago•0 comments

SpacemiT Vital Stone V100 RISC-V server processor

https://www.spacemit.com/products/keystone/v100
1•pjmlp•19m ago•0 comments

Strongbox password manager, uses analytics in the freemium version

https://termsapply.fyi/publications/strongbox-ios-network-traffic/
1•antonyvanhamlin•21m ago•0 comments

Empires of AI: The Rise and Fall of a New Global Order

https://www.foreignaffairs.com/china/empires-artificial-intelligence-ferguson-klaassen-schmidt
3•doener•21m ago•0 comments

ArcSkin gives QGIS an interface inspired by ArcGIS Pro

https://github.com/envirosolutionspl/arcskin
1•marklit•25m ago•0 comments

Morphe – Android app modification tool (for patching apps)

https://morphe.software/
1•yehoshuapw•28m ago•0 comments

Show HN: A retro arcade style tower climber where your only weapon is a shield

https://the-last-word.ca/return-to-sender/
1•dmaybeck•31m ago•0 comments

My Experience with the MoonSwatch Mission to the Moon

https://www.kulman.sk/en/moonswatch-mission-to-the-moon-review/
1•ig0r0•33m ago•0 comments

How to Use Decision Models for Evals

https://twitter.com/HamelHusain/status/2112588257104216294
1•pretext•37m ago•0 comments

File-PII – Extract text, metadata and PII from PDFs in pure JavaScript

https://github.com/axium-lab/file-pii
1•luisperis1011•38m ago•0 comments

CVE-2026-106173: FortiSIEM gRPC Path Traversal RCE

https://horizon3.ai/attack-research/cve-2026-106173-deep-dive-fortisiem-grpc-path-traversal-file-...
2•frostbyte7•43m ago•0 comments

Turn any single player PC game into coop instantly

https://github.com/cranebeaker/coop-anything
1•vivzkestrel•46m ago•1 comments

ReactOS reaches major milestone with NTFS install support

https://arstechnica.com/information-technology/2026/10/reactos-reaches-major-milestone-with-ntfs-...
4•joozio•49m ago•2 comments

Grimoire for Biology

https://grimoire.bio
1•levmiseri•55m ago•0 comments

SpaceX and Tesla have formed committees to discuss potential merger, Musk

https://www.cnn.com/2026/10/20/business/spacex-tesla-merger-musk
1•pseudolus•58m ago•0 comments

Show HN: See AI trends heat up in real time

https://ai-news.jagular.io
2•jnaina•1h ago•0 comments

Ossdoctor – a health check for open source repos that fixes what's missing

https://github.com/jalensuggs77/ossdoctor
3•firstAu•1h ago•1 comments

Burbank's Real-Time Intelligence Center

https://burbank-ledger.pages.dev/articles/rtic-surveillance/
3•measurablefunc•1h ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•1y ago
I'm relatively new to Java. I often notice a pattern where there is a list of constant which value are equal to the name.

  class Constant {
    public static final String ALBUM = "album";
    public static final String NAME = "_name";
    public static final String DISPLAY_NAME = "display-name";
    public static final String SERVICE_NAME_METRIC_NAME_PREFIX = "service_name.metric_name";
  }

Here is a public example of this practice I could find: https://developer.android.com/reference/android/provider/MediaStore.MediaColumns

I could understand that this might help in 2 ways refactoring and typo. This reduces chance of typo because you'll get compile error instead of run-time error if you typo a constant. This might also help in refactoring if you ever wants to change the value. but if may use this android public API example, I don't think it's wise to change a field name ever. If it's decommissioned, it's good to keep it so we don't re-use the field. If it's a new better field available, I think it should have a different name. I maybe making a straw man argument here. Let me know. If it's an internal API where such refactoring might make sense -- I still kind of think internal API should also be backward compatible, replacing a string are not a complicated operation in my opinion.

I see that this practice has a cost. One being that in every class that use this API. You need to add an import. It's also often the const is only used once from my experience.

  import static com.example.MediaFields.NAME;
  import static com.example.MediaFields.DISPLAY_NAME;

  String value = json.getString(NAME);
  String value2 = json.getString(DISPLAY_NAME);
vs

  String value = json.getString("name");
  String value2 = json.getString("display_name");
You write 1 line for declaration plus 2 lines for each class using this API. This is not a big deal in terms of LoC and I'm not an LoC police. However, my sense is the cost outweigh the benefit.

What do you think?

Comments

lanna•1y ago
You just made TWO typos: "display-name" vs "display_name" and "_name" vs "name", automatically counter-argumenting your point.

It is also for documentation. With the declared constants, we know all possible values. With plain strings, how am I supposed to know which values to use?

The benefits far outweigh the marginal cost.

ramsicandra•1y ago
The -, _, and leading _ are just variations of white space / separator I have encountered. I think it's possible to document all the allowable values in the Javadoc section of the function that takes in string as their argument.

In the specific android example, I would put it here. Under projection params where it takes in all the Images.Media.* string consts.

https://developer.android.com/reference/android/content/Cont...

Though, if it's a practice of Java Engineer to document allowable enum like string as a constant, then I can say that's a valid argument.