frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

CoreWeave Is Under Review by a Major Partner (Microsoft)

https://simplywall.st/stocks/us/software/nasdaq-crwv/coreweave/news/coreweave-crwv-is-under-revie...
1•intrusive_mango•1m ago•0 comments

Studies: Does working life change our personality?

https://wiwi.uni-mainz.de/en/2026/09/08/studies-working-life-personality/
1•rohanm93•2m ago•0 comments

China Newspaper Dismisses Jensen Huang Spy Claim, Warns on Ties

https://www.bloomberg.com/news/articles/2026-11-09/china-newspaper-dismisses-jensen-huang-spy-cla...
1•saikatsg•8m ago•0 comments

Brotli CVE-2026-111497 reaches stock WordPress through pingbacks

https://hatamoto.dev/wordpress/brotli-flaw-wordpress-xmlrpc-pingback
1•zenincognito•10m ago•0 comments

Github.com 504 Gateway Timeout due to surge in anonymous users

https://www.githubstatus.com/incidents/c9px7cw2ghrs
4•wilsonfiifi•12m ago•0 comments

National Popular Vote Interstate Compact

https://en.wikipedia.org/wiki/National_Popular_Vote_Interstate_Compact
1•JumpCrisscross•12m ago•0 comments

Oriental Men's operating system [video]

https://www.youtube.com/watch?v=qvcwnwoQbWI
1•CHB0403085482•14m ago•0 comments

How I Give Feedback

https://diatone.net/feedback
1•diatone•16m ago•0 comments

Low Latency HLS: How to Fix High Latency Issue Step by Step

https://www.red5.net/blog/two-ways-to-fix-hls-low-latency-streaming/
1•mondainx•20m ago•0 comments

Those who have lost their job to AI what was your job?

1•dev_grex•21m ago•0 comments

Show HN: A bot attack forced me to rebuild my tools on Cloudflare Workers

https://sitetoolsbox.com/article.php?id=52
2•kagouhui•23m ago•0 comments

Can you help falsify this speculative quantum foundations idea?

https://zenodo.org/records/24072504
2•pankkum•23m ago•0 comments

What If the Next Computer Virus Isn't Software? Rise of AI-Powered USB Threats

https://medium.com/@makalin/what-if-the-next-computer-virus-isnt-software-the-rise-of-ai-powered-...
1•makalin•23m ago•0 comments

The tau protein (Alzheimer's) re=organiezed/folded/measured

https://github.com/alozano978-spec/the-tau-protein
2•forged-on-chain•28m ago•0 comments

Show HN: Logcrux – An intelligent local log analyzer

https://logcrux.com
2•ravipatib•33m ago•0 comments

AetherSkin User Testing

https://aetherskin.app
1•krrled•34m ago•0 comments

Colophon Protocol – How to Deal with Agents Emails

https://colophon-protocol.org/
2•valboa•45m ago•1 comments

Apple capped engineers at a $200 daily AI budget

https://www.stork.ai/newsletter/2026-11-08-apple-capped-engineers-at-a-200-daily-ai-budget#story-1
10•GloVin•47m ago•6 comments

Is PostgreSQL Winning?

https://stokerpostgresql.blogspot.com/2026/11/is-postgresql-really-winning.html
2•ejboy•49m ago•0 comments

Conductor's shutting down on the 20th so I built an alternative (founder, AMA)

https://concors.dev/
1•katalist•56m ago•0 comments

Anthropic secures $3.4B generator deal for AI data centers

https://www.reuters.com/business/energy/anthropic-secures-34-billion-generator-deal-ai-data-cente...
3•giuliomagnifico•57m ago•1 comments

Trying to outsmart the Apple News algorithm

https://www.fabian.fyi/2026/11/rock-veto-algorithm.html
1•optimiz•59m ago•0 comments

AI learns from the products of thinking, not thought itself

https://theconversation.com/ai-learns-from-the-products-of-thinking-not-thought-itself-thats-a-pr...
2•bitofenglish•1h ago•0 comments

The Origins of Peanut Allergy

https://stephenskolnick.substack.com/p/on-the-origins-of-peanut-allergy
2•bobbiechen•1h ago•0 comments

Four Useful Questions

https://www.henrikkarlsson.xyz/p/four-useful-questions
1•Curiositry•1h ago•0 comments

Show HN: An Ad-Free, 100%

https://minitooldesk.com/vs/
1•minitooldesk•1h ago•0 comments

Detecting signs of hypertension using wearable sensors

https://research.google/blog/detecting-signs-of-hypertension-using-wearable-sensors/
1•jonbaer•1h ago•0 comments

Show HN: Huobidex – A handpicked hub for tools and products

https://huobidex.com
1•dotcurio•1h ago•0 comments

A digital bank's collapse toppled Paraguay's president

https://www.reuters.com/business/finance/how-digital-banks-collapse-toppled-paraguays-president-2...
2•geox•1h ago•0 comments

View / Nvidia's $4.5T test of founder immunity

https://www.semafor.com/article/11/08/2026/nvidias-45-trillion-test-of-founder-immunity
1•snikolaev•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.