frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Five.sh Archive (64 GB)

https://five.sh/files/
1•o_-_o•1m ago•0 comments

Plazzle – daily pathfinding puzzle game

https://plazzlegame.com
1•argentumsurfer•1m ago•0 comments

The progress and strategies I'm considering for working on NuxiPro

https://center.nuxipro.com/en/blog/design-and-server/
1•sbabas•2m ago•0 comments

Bexos – Lightweight Flask/SQLite retro board for side-project ideas

https://bexos.pythonanywhere.com
1•MirasBeksultan•3m ago•0 comments

How many Phrack 73 articles used AI?

https://dustri.org/b/how-many-phrack-73-articles-used-ai.html
1•speckx•3m ago•0 comments

Building a Software Factory

https://runway.com/news/engineering/building-a-software-factory
1•aurbano•4m ago•0 comments

Starwright – a browser orbital flight game written by AI agents

https://github.com/jsmith0475/Starwright
1•jsmith0475•4m ago•0 comments

Humans Age Faster at 2 Sharp Peaks, Study of the Immune System Shows

https://www.sciencealert.com/humans-age-faster-at-2-sharp-peaks-study-of-the-immune-system-shows
1•randycupertino•6m ago•0 comments

Agentic Ads: How Advertising Changes When AI Agents Do the Shopping

https://alok929699.substack.com/p/agentic-ads-how-advertising-changes
1•gotraven•7m ago•0 comments

First Principles Thinking and a Skill to Use It

https://medium.com/towards-artificial-intelligence/first-principles-thinking-and-a-skill-to-use-i...
1•cadeos•8m ago•0 comments

Open-source harness that makes Claude better for game dev

https://wasdengine.com/
3•j_zhao•8m ago•1 comments

Show HN: AIVory Code – One screen for all your coding agents

https://github.com/aivorynet/aivory-code
1•ppiper•8m ago•0 comments

Toxic Dust Plume Concerns for Army Plans of Iowa Lead Azide Detonation on Monday

https://www.army.mil/article/296926/postponed_lead_azide_detonation
1•Jimmc414•9m ago•1 comments

Zero-dependency local Python utilities for B2B, FinOps and AI

https://www.sideprojectors.com/user/profile/288750
1•kesslerservices•10m ago•0 comments

Ruby2Shell

https://www.aikido.dev/blog/ruby2shell
2•spatten•13m ago•1 comments

Unforced Navier-Stokes Singularity and the Generalized Riemann Hypothesis

https://terrytao.wordpress.com/2026/11/20/unforced-euler-singularity-unforced-navier-stokes-singu...
3•archon1410•15m ago•0 comments

Data Hoarding

https://datahoarding.org/
1•o_-_o•16m ago•0 comments

Show HN: Straum – a Postgres materialized view that is never stale

https://github.com/janbjorge/straum
1•jeeybee•17m ago•0 comments

Visited Links Are Purple

https://dbushell.com/2026/11/16/visited-links/
3•birdculture•20m ago•0 comments

Video Archive (1.4 PB, 599,724 Files)

https://a.111477.xyz/
1•o_-_o•20m ago•0 comments

Diablo II

https://www.filfre.net/2026/11/diablo-ii/
3•edp•22m ago•0 comments

Running two PSP emulators on one Switch 2 and sharing one via GameShare

https://github.com/XITRIX/ppsspp-nx2/blob/master/SWITCH2-GAMESHARE.md
4•khalidkhair•23m ago•0 comments

Germany's China Shock

https://www.damagemag.com/p/germanys-china-shock
1•cainxinth•23m ago•0 comments

Show HN: SKV – hosted MCP memory that survives a new chat

https://skv.network/
1•skv_network•26m ago•0 comments

Trump to hold press conference after meeting with Xi and Putin

https://www.npr.org/2026/11/20/nx-s1-6047594/trump-asia-trip-xi-putin-press-conference
1•wslh•26m ago•0 comments

Elevated Errors in HCP Terraform

https://status.hashicorp.com/incidents/01M7WVH5PK724JXZEKMBR40P40
1•cebert•27m ago•0 comments

PostgreSQL 19: A hands-on tour with runnable browser examples

https://certuvia.com/blog/postgres-19
5•petrpravda•28m ago•0 comments

The Mickey Mouse Gas Mask for Children

https://gasmasklexikon.com/Page/USA-Mil-Mikey.htm
2•speckx•29m ago•0 comments

Code Inflation: AI Prints Code Faster Than Anyone Can Review It

https://www.everydev.ai/p/blog-code-inflation-ai-prints-code-faster-than-anyone-can-review-it
1•devhouse•31m ago•1 comments

Auditing 23.5k Google AI Ultra ($200/mo) SQLite logs: 0% KV cache and tiered IDs

https://github.com/fatrabbit29/antigravity-ultra-quota-audit
1•fatrabbit29•31m 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.