Hacker News new | ask | show | jobs
by cyberpanther 4167 days ago
I think that boundary is important though. If you design your app correctly there won't be the need to rewrite code over the front and back. Also if your building an Android or iOS app you have to build that boundary. So why build the web frontend differently? They should all consume the same backend.

Of course there will probably be repeat code but I'd rather minimize that than try to make universal code.

1 comments

You're thinking of the wrong boundary. You should definitely have a boundary for your data that is agnostic of the view code.

However, a web application is not like an iOS or Android application. It has a server-side that sends pre-rendered view code and it has a client-side that renders view code on the fly. It still makes sense to share the view code between the server and the client and it still allows for a separate data backend.

These systems are surprisingly easy to create and maintain with React.

In essence three things are supplied to a client. A pre-rendered view, raw data, and the code to turn the raw data in to the pre-rendered view.

OK that is where we diverge, i'm thinking no pre-rendered view. Ideally your frontend would be serving statically from lets say Amazon S3 and your api from another domain. Treat your frontend as if it were a mobile app. Now if you apply the data bootstrapping technique this can't happen totally but the only thing to do dynamically is insert some initial API data.