frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Show HN: I built a free astro and tailwind static site for GitHub pages

https://tariqdude.github.io/Github-Pages-Project-v1/
1•chiengineer•2m ago•0 comments

A macOS Window Manager Inspired by FancyZones on Windows

https://bentoboxapp.com/
1•alexktz•2m ago•0 comments

Kobo Articles Proxy – use Kobo Instapaper integration, without using Instapaper

https://github.com/marklar423/kobo-pocket-proxy
1•Curiositry•3m ago•0 comments

China's memory-maker CXMT unveils DDR5-8000 and LPDDR5X-10667 chips

https://www.tomshardware.com/pc-components/dram/chinas-banned-memory-maker-cxmt-unveils-surprisin...
1•vkaku•8m ago•1 comments

Built an AI agent that creates block code

https://huggingface.co/spaces/MCP-1st-Birthday/MCP-Blockly
1•owenkaplinsky•10m ago•1 comments

Bauble

https://bauble.studio/
1•phaser•10m ago•0 comments

Using game engines to train robotics, AV models, and AI pilots

https://alanscottencinas.medium.com/how-early-digital-systems-quietly-shaped-the-minds-building-t...
2•encinas88•16m ago•0 comments

Ask HN: Vandy grad seeking HN community's career advice

1•shannonalp•16m ago•0 comments

Textshader

https://textshader.com/
2•memalign•17m ago•0 comments

Show HN: Deploy Next.js to your own VPS via a lightweight agent

https://outlap.dev
1•ben_hrris•19m ago•1 comments

'Algospeak' is changing our language in real time (2022)

https://www.washingtonpost.com/technology/2022/04/08/algospeak-tiktok-le-dollar-bean/
1•thunderbong•20m ago•0 comments

Data Science Weekly – Issue 627

https://datascienceweekly.substack.com/p/data-science-weekly-issue-627
1•sebg•21m ago•0 comments

What Is HATEOAS?

https://blog.hmpl-lang.dev/2025/11/27/what-is-hateoas/
1•aanthonymax•24m ago•0 comments

Canada signs pipeline deal that could reverse oil tanker ban

https://apnews.com/article/canada-oil-pipeline-alberta-oil-british-columbia-carney-bdbd13b337ee12...
2•geox•28m ago•0 comments

Bending Emacs – Episode 6: Overlays [video]

https://www.youtube.com/watch?v=93wWCroTKnM
1•xenodium•29m ago•0 comments

Hydrogen fuel isn't always the green choice

https://www.nature.com/articles/d41586-025-03695-0
2•mpweiher•34m ago•0 comments

All OpenReview Data Leaks

https://twitter.com/iclr_conf/status/1994104147373903893
2•nsagent•38m ago•1 comments

Mapping a universe of open source software: the Nixpkgs dependency graph

https://www.tweag.io/blog/2019-02-06-mapping-open-source/
2•fanf2•38m ago•0 comments

Vibro-Braille for Deaf-Blind

1•Billiamdan•43m ago•0 comments

Acute Febrile Neutrophilic Dermatosis (Sweet Syndrome)

https://emedicine.medscape.com/article/1122152-overview
1•wjb3•43m ago•0 comments

Managed Code – New Site

https://www.managed-code.com/
2•managedcode•45m ago•0 comments

It's time to accelerate the development of antimatter for space propulsion

https://caseyhandmer.wordpress.com/2025/11/26/antimatter-development-program/
4•modeless•48m ago•0 comments

Requiem for Early Blogging

https://www.elizabethspiers.com/requiem-for-early-blogging/
3•bookofjoe•49m ago•0 comments

Baikonur launch pad damaged after Russian Soyuz launch to Space Station

https://www.reuters.com/science/baikonur-launch-pad-damaged-after-russian-soyuz-launch-internatio...
1•perihelions•49m ago•0 comments

Drones have revolutionized warfare. They're about to do it again

https://www.cnn.com/2025/11/27/world/history-future-of-drones-intl-hnk-ml-dst
3•breve•49m ago•1 comments

Lucas 'Granpa' Abela live [video]

https://www.youtube.com/watch?v=2aMBMbEWc6I&list=RD2aMBMbEWc6I
1•marysminefnuf•50m ago•0 comments

Emma Mazzenga is redefining athletic longevity at 92 years old

https://www.cnn.com/2025/11/27/sport/athletics-emma-mazzenga-redefining-longevity-92-intl
2•breve•51m ago•1 comments

From Cloudwashing to O11ywashing

https://charity.wtf/2025/11/24/from-cloudwashing-to-o11ywashing/
2•BerislavLopac•54m ago•0 comments

T1 accepts Elon Musk's challenge for top LoL team to compete against Grok AI

https://www.dexerto.com/league-of-legends/t1-accepts-elon-musks-challenge-for-top-lol-team-to-com...
1•andsoitis•55m ago•4 comments

Yawning Abyss of the Decimal Labyrinth

https://oh4.co/site/numogrammaticism.html
2•austinallegro•56m ago•0 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.