Better HN
topnewbestaskshowjobs
Log inSign up

hakunin

2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions

https://max.engineer, mastodon:ruby.social/@maxim, x.com/hakunin, bsky.app/profile/max.engineer

meet.hn/city/43.1009031,-75.2326641/City-of-Utica

---

Submissions

481.

Maintainable Code Explains Itself(max.engineer ↗)

3 points · by hakunin · 5y ago · discuss

482.

Mindful Code Reviews(max.engineer ↗)

1 points · by hakunin · 5y ago · discuss

483.

Mindful Code Reviews(max.engineer ↗)

2 points · by hakunin · 5y ago · discuss

comment 5y ago · link · parent

In case anyone else feels that this article leaves enough wiggle room to accidentally end up with something like 015a described, here are the 3 rules I implied in answering the above post:

1. All structure and content goes to backend. 2. Find good names for size-adaptive sections. 3. Responses to write requests can be anything.

I think 1 and 3 are covered in the article, but elaborating on them is probably out of its scope. And 2 is more of a general programming advice.

comment 5y ago · link · parent

> if you have a person's profile picture, and you want to round it, should that be a property on the JSON structure?

You can decide what to leave to frontend on a case-by-case basis. I would say unless people can choose if a picture is rounded and it's saved in database, this is valid to leave up to frontend.

> Maybe its text weight: How generic should it be? Very-generic: "title". Kinda-generic: "heavy". Or literally just CSS.

If text has sections that are formatted differently, backend could provide content for those sections separately. Styles are up to frontend.

> Does the contract allow for lee-way in how its responses are interpreted? How much lee-way?

Structure and content on the backend, presentation on the front-end.

> designers want it to become a bottom bar. No problem, except, uh, the API says it should be a sidebar

Call it something a little more encompassing, like "secondaryNavBar".

> you just doubled the work of a visual redesign. If the data model were generic, your backend team may not have even had to have been consulted.

There's a fair criticism in here, however the work is not doubled. 1. You can make some redesigns without changing field names, then slowly align JSON keys. The damage from this concession is contained in each page individually. That said, updating the JSON keys as you go should not be much more work than the redesign itself. 2. Should we be optimizing for rare redesign when instead we could optimize for ongoing maintenance? 3. How likely is it that redesign doesn't need anything new from backend anyway? 4. How likely is it that redesign won't introduce new N+1 problems?

> Do you have something like { "form": [ { "formTextField": { "id": "firstName" } } ... { "formSubmitButton": { "endpoint": "/createUser", "verb": "POST", "arguments": { "id": "firstName" } ... } } ] }

To render the form, you don't need to send the form to the frontend. Frontend could render the form by itself. You just just send it any pre-filled values. Form's action/method are also okay to include.

> What if one page that calls /createUser needs to display the error in a snackbar, but another page needs to display it in-line with the button? Do you just... not do that? Just throw every error into a snackbar?

Just because you mostly render full pages, doesn't mean it's illegal to have endpoints that give you snippets of data in response. Your createUser endpoint can respond with just a list of errors. It wouldn't be bad for mutating endpoints to do that, the benefits of this approach still remain.

I've addressed the points you've made, but seems as though they allowed you to build up a strawman, and the rest of the comment is knocking down that strawman. That's not what's being proposed here. It's okay, maybe you are arguing against specifically what you have at your work. I could help adjust your framing if you'd like, let me know.

comment 5y ago · link · parent

I think this is totally fine if you're willing to accept some performance trade offs in favor of productivity, you're staying mindful of limits and scoping, and just generally you're accustomed to living in the GraphQL world.

comment 5y ago · link · parent

I'd argue that the difference between "we're changing schema for all callers" vs "we're changing schema for 1 page of 1 frontend that we fully control" is so profound, as to render that whole concern moot.

comment 5y ago · link · parent

If everything on the page is slow to load, then I would agree. Twitter is such a crazy outlier that I can't even imagine what they have to deal with. In a usual case you'd get a rare 1-2 slow retrievals, and the rest of the page can show up immediately.

489.

Don't build a general-purpose API to power your own front end(max.engineer ↗)

128 points · by hakunin · 5y ago · 107 comments

comment 5y ago · link · parent

Someone has to maintain an always-running listener for `/events`. If a server does that, and triggers client calls, we call that webhooks. If a client does that, and triggers internal functions, it's what the op describes. I think that for APIs, `/events` should indeed be the fundamental feature, and "webhooks" should be a nice-to-have service on top of `/events`, for those who don't want to maintain a local subscriber.

491.

CMS Trap (2013)(max.engineer ↗)

2 points · by hakunin · 6y ago · discuss

492.

A rubygem to look up data directly from disk(github.com ↗)

1 points · by hakunin · 6y ago · discuss

comment 6y ago · link · parent

I wrote about this a few years ago.[0] The gist to avoiding premature over-architecting is to keep sticking with as static/hardcoded behavior as possible to meet the requirements. Just make sure it’s well organized and cleanly written in your language of choice. Then over time add configurability to that behavior as specs change. Architecture is easy to change not when it correctly predicts future change (almost impossible), but when it is straightforward enough to follow and reshape.

In my experience, keeping behavior static/hardcoded is the architectural equivalent of avoiding premature optimization.

[0]: https://max.engineer/cms-trap

comment 6y ago · link · parent

How about git push heroku master from local branch?

495.

Reasons Not to Implicitly Memoize(max.engineer ↗)

3 points · by hakunin · 6y ago · discuss

496.

Three Reasons Not to Implicitly Memoize(max.engineer ↗)

11 points · by hakunin · 6y ago · discuss

comment 6y ago · link · parent

People ate bats; Chinese government covered up the virus for a while; big US pharma wasn’t incentivized to research a solution; underinsured Americans were afraid to go to doctor; immigrants were afraid to go to doctor; US government just sunk trillions into economy (which vanished in mere hours), but can’t promise free tests and treatment for everyone; US government messed up the cautionary messaging; US has no systems in place to handle anything like this.

^ this is a list of problems I read in the news over the past few days. Pretty sure there are a lot of solutions people have been proposing, most of which are completely feasible.

comment 6y ago · link · parent

Latest update[1] says it's routing issues, which sounds less bad than what it could've been.

[1]: https://status.heroku.com/incidents/1973

comment 6y ago · link · parent

I can’t help but wonder if perhaps the helpfulness of a lot of these principles is different for people who can or cannot see/hear in their mind.

https://news.ycombinator.com/item?id=19618927

comment 6y ago · link · parent

Pick up the phone and stay silent until they speak. It should also help reduce incidence of scam calls.

comment 7y ago · link · parent

I've seen your other projects from years ago, e.g. your bookmarks site. I think you have great ideas and skill. I appreciate the effort towards being no bullshit. May I suggest a no-BS approach that replaces highly subjective humor with a copy that focuses on (hopefully also no-bullshit) aspects like

  1. clearly stating how you gonna scale image delivery
  2. clearly stating how you store files
  3. clearly stating how you're financially sustainable
I love businesses with personality. It's just hard to do good humor. This humor reminds me of a 20yo me in college, a time when my sense of narcissism was way outperforming my sense of good taste.

502.

Don't use docker to run your app in development(hakunin.com ↗)

2 points · by hakunin · 8y ago · discuss

comment 9y ago · link · parent

Some weird tricks that worked for me:

1. Hire a weight lifting trainer. I go 3 times a week, and I never have to think about it. The "not having to think" is important.

2. Get a standing desk. I don't always use it (especially hard after leg day), but it's good to alternate sitting/standing.

3. Don't get too excited or too frustrated about gym. Just another day. The more days you go the less you care about an occasional bad day.

4. Don't eat sugar on purpose (including candy, cake, jam, too much fruit). Entirely stop drinking coke and similar sodas. If you have to, replace them with kombucha.

5. Drink water. A lot.

comment 9y ago · link · parent

Yes, a typical Elixir/Erlang application is a process tree with parent processes acting as supervisors to children processes. Each supervisor knows how to handle its children crashing, and properly replace crashed processes. They can do things like “if one child crashed restart all children” or “only restart the crashed child”.

comment 9y ago · link · parent

Yes, connecting to any node connects you to all nodes. I have done exactly this in a production app.

506.

CMS Trap(hakunin.com ↗)

1 points · by hakunin · 9y ago · discuss

comment 9y ago · link · parent

We went with good old Heroku and Redis for the real-time Elixir component. It isn't a full-blown OTP setup by far, but we just needed stable performance with many websocket connections, for which it didn't even break a sweat. We have set up OTP clusters for other projects however, but that's a story for another day.

comment 9y ago · link · parent

Hey folks, I am the back-end/infra dev on this project, AMA. It's built with a combination of Elixir/Phoenix, Rails, and React (+Native). If you'd like to work with me on stuff like this feel free to apply by shooting us an email with some info about yourself. You can find the contact at http://www.crossfield.com

comment 10y ago · link · parent

My thoughts conveying similar message from a different angle: http://hakunin.com/cms-trap (for those who might've missed it when it got upvoted on HN 3 years ago).

510.

ElasticSearch gems and modules, clearly explained(hakunin.com ↗)

1 points · by hakunin · 11y ago · discuss

1
1516171819