frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Neocities

https://neocities.org/
1•DeathArrow•1m ago•0 comments

Platform Pricing Comes at a Cost

https://www.wreflection.com/p/platform-pricing-comes-at-a-cost
1•nowflux•3m ago•0 comments

Amper Update, November 2025 – Extensibility Preview

https://blog.jetbrains.com/amper/2025/11/amper-update-november-2025/
1•clanky•4m ago•0 comments

EU–INC: Pan-European legal entity

https://www.eu-inc.org/
1•throwoutway•4m ago•0 comments

The failed socialist alternative to Los Angeles in the Mojave desert

https://kubicki.org/letters/the-dogs-of-llano-del-rio-ii/
3•kosmavision•4m ago•0 comments

Data center provider razes 55 homes to make room for Illinois campus

https://www.networkworld.com/article/2071209/data-center-provider-razes-55-homes-to-make-room-for...
2•mudil•5m ago•0 comments

The Varying Strictness of TypedDict in Python

https://snarky.ca/the-varying-strictness-of-typeddict/
1•BerislavLopac•5m ago•0 comments

Apache DataFusion 51.0.0 Released

https://datafusion.apache.org/blog/2025/11/25/datafusion-51.0.0/
2•killme2008•6m ago•0 comments

Fuzzy -simple tiny fuzzer written in Go

https://github.com/cecinuga/fuzzy
1•cecinuga•7m ago•0 comments

Show HN: WResume – Free Conversational Resume Editing and Built-In LaTeX Editor

https://www.wresume.ai/
1•skoushik•10m ago•0 comments

Video Downloader Pro – Download Videos from Any Website – Free Tool

https://plugmonkey.xyz/product/video-downloader-pro/
1•yazeedaloyoun•10m ago•0 comments

When Fake Security Is Mandated Real Security Becomes a Crime

https://techrights.org/n/2025/11/25/When_Fake_Security_Back_Doors_Disguised_as_Security_is_Mandat...
1•amcclure•15m ago•0 comments

Georgia Gkioxari Co-Leads Major 3D Perception Model Built on AI

https://www.caltech.edu/about/news/georgia-gkioxari-co-leads-major-3d-perception-model-built-on-ai
1•stmw•15m ago•0 comments

Ask HN - LaunchPad Replacement on MacOS

2•zahirbmirza•16m ago•1 comments

Counter Galois Onion: Improved encryption for Tor circuit traffic

https://blog.torproject.org/introducing-cgo/
1•wrayjustin•18m ago•0 comments

Slimmable Neural Amp Modeler Models

https://arxiv.org/abs/2511.07470
1•dtauzell•20m ago•0 comments

Misunderstanding That "Dependency" Comic

https://bertptrs.nl/2025/11/24/misunderstanding-that-dependency-comic.html
2•birdculture•20m ago•0 comments

Gemini 3 pro advanced biometric scan to find your famous twin

https://facejudge.com/
1•levigrace•21m ago•1 comments

The Whisper That Could've Rewritten History

https://ochatapp.substack.com/p/what-if-a-single-hey-this-is-wrong
1•petercode•21m ago•0 comments

Servo: Lightweight, high-performance alternative for embedding web technologies

https://servo.org/
1•doener•22m ago•0 comments

Mizar Language

https://mizar.uwb.edu.pl/language/
2•varjag•23m ago•0 comments

Speed: Engineering Airbyte's 4-10x Performance Breakthrough

https://airbyte.com/blog/speed-improvements
1•JakaJancar•23m ago•1 comments

Show HN: MCP Security Scanning Tool for CI/CD

https://smart.mcpshark.sh/
11•devops-coder•28m ago•0 comments

LLM Societies (they are social critters)

https://www.mslinn.com/llm/7998-social-llms.html
2•mike_slinn•28m ago•0 comments

ZoomInfo CEO Blocks Researcher After Documenting Pre-Consent Biometric Tracking

https://github.com/clark-prog/blackout-public
3•SignalDr•31m ago•1 comments

Show HN: A tiny browser-based voice-to-text tool (no signup, no tracking)

https://www.voicetotextonline.com/
1•digi_wares•32m ago•0 comments

The Local-First Comeback You Didn't See Coming

https://shivekkhurana.com/blog/sync-engines/
1•shivekkhurana•34m ago•0 comments

Topological turning points across the human lifespan

https://www.nature.com/articles/s41467-025-65974-8
1•bryanrasmussen•34m ago•0 comments

We Are Better Off Than a Century Ago

https://www.thenewatlantis.com/publications/why-we-are-better-off-than-a-century-ago
3•SCEtoAux•35m ago•2 comments

Walmart Is Exploring Bringing Ads to Sparky, Its New AI Shopping Agent

https://www.wsj.com/business/retail/walmart-is-exploring-bringing-ads-to-sparky-its-new-ai-shoppi...
2•fortran77•35m ago•1 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•6mo 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•6mo 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•6mo 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.