frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Show HN: A simple decision layer for coding agents

https://smarchone.github.io/signals/
1•smarch27•22s ago•0 comments

Show HN: Lanlan Jam – a multiplayer DJ booth in the browser

https://jam.lanlan.site/
1•wchest•37s ago•0 comments

Microsoft admits some emails bounced during Outlook outage, reveals new failures

https://www.neowin.net/news/microsoft-admits-some-emails-bounced-during-global-outlook-outage-rev...
2•DASD•2m ago•0 comments

HotCofy: Token-Based Restaurant POS

https://hotcofy.com/
1•upantaz•3m ago•0 comments

C64 ultimate firmware 1.2.1 released

https://downloads.commodore-international.com/documentation/changelog-1.2.1.txt
1•mikerg87•4m ago•0 comments

"A government that 'gets it'": Canada recommits to federal funding for news

https://www.niemanlab.org/2026/11/a-government-that-gets-it-canada-recommits-to-federal-funding-f...
2•DeepLogin•4m ago•0 comments

A Rust simulation engine for discrete-time controllers

https://www.modeloop.app/blog/porting-the-simulation-engine-into-rust
1•lucamark•4m ago•0 comments

The Birds of GTA 6: A Field Guide to Vice City and Leonida's Wildlife

https://www.audubon.org/magazine/birds-of-gta-6-field-guide-vice-city-wildlife
1•gaws•4m ago•0 comments

Detecting Bugs at the Interfaces of OpenBSD Privilege-Separated Programs [pdf]

https://mpi-sp-deos.github.io/assets/pdf/openbsd-civs-ccs26.pdf
1•beachhead•6m ago•1 comments

An A.I. Editor's Essential Tool: The Typewriter

https://www.nytimes.com/2026/11/22/insider/typewriter-artificial-intelligence.html
1•gaws•8m ago•0 comments

Show HN: A one-time $5 API pass for text,image,and audio models

https://ai.fissionagents.com/#models
1•12ziyad•9m ago•0 comments

Companies Suck at Internal Tooling

https://nonstationary.substack.com/p/companies-suck-at-internal-tooling
1•helicalmix•10m ago•0 comments

OpenRun 1.0 release – zero-config declarative deployments

https://openrun.dev/blog/openrun-1.0/
1•ajayvk•11m ago•1 comments

Mexico's President Flew 21 Hours to China in Economy (In a Middle Seat)

https://onemileatatime.com/news/mexico-president-flew-china-economy-middle-seat/
4•prmph•12m ago•1 comments

The first Britons were not 'black'

https://www.spiked-online.com/2024/02/07/no-the-first-britons-were-not-black/
2•jamesgill•15m ago•0 comments

Ask HN: Are startups today worth it even in a best case scenario?

3•enigmous_hippo•17m ago•1 comments

Meridian: Web-browser built on GPUI and Servo

https://op.tngl.io/meridian/
2•nerdypepper•18m ago•0 comments

Make your own Meta Muse / AI charm keychain

https://github.com/devniz/znp-re
2•nzr_ldn•19m ago•0 comments

Proposed proof of Riemann Hypothesis looks promising

https://www.scientificamerican.com/article/anthropic-mathematician-claims-to-prove-riemann-hypoth...
2•larryfreeman•20m ago•0 comments

Bell Canada says 'agentic' hacker stole enterprise customer data

https://www.bleepingcomputer.com/news/security/bell-canada-says-agentic-hacker-stole-enterprise-c...
3•ersinesen•22m ago•0 comments

Show HN: I made a manifestation film tool in 5 days

https://www.visionflick.com/
1•bjoern_live•22m ago•0 comments

The Shepard-tone theory of Capital

https://monofrogue.substack.com/p/the-shepard-tone-theory-of-capital
2•paulpauper•24m ago•0 comments

EAX x86 Register Meaning and History

https://keleshev.com/eax-x86-register-meaning-and-history/
5•ibobev•24m ago•0 comments

Dirac's Theorem at a Dinner Party

https://prideout.net/blog/dirac-dinner-party/
2•prideout•24m ago•0 comments

The Story of Ministry's Jesus Built My Hotrod

https://www.loudersound.com/features/the-story-of-ministrys-jesus-built-my-hotrod-gibby-threw-up-...
2•jruohonen•25m ago•0 comments

"Breathe"

https://mondmondmondmon.substack.com/p/breathe
1•paulpauper•26m ago•0 comments

The Short Age of Dragon Riders

https://atilloy.com/2026/11/16/the-short-age-of-dragon-riders/
1•libraryofbabel•27m ago•0 comments

AI and hiring: bad for employees, bad for employers

https://johnhempton.substack.com/p/ai-and-hiring-bad-for-employees-bad
2•rwmj•29m ago•3 comments

Boeing leaves open possibility of more layoffs amid stalled production plans

https://www.reuters.com/legal/litigation/boeing-leaves-open-possibility-more-layoffs-amid-stalled...
4•frank_clover•29m ago•0 comments

More load is faster: Tuning Postgres read replicas

https://clickhouse.com/blog/tuning-postgres-read-replicas
1•tudorg•30m 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.