Pregunta

I am very much an amateur developer. I have written a web app which uses parse-server as a backend.

My question revolves around how agnostic the frontend should be to the backend (parse server)?

For example, on the client side (browser), I query the parse-server for data - let's say using function GetData(). My web app then renders that data to the user - say, using ShowData(). BUT, GetData() returns an array of Parse Objects - so the client side rendering function requires the data is an array of Parse Objects.

Essentially, my code is locked into using parse-server. If I ever decided to I wanted killer feature 'X' that's only available in, say, Firebase then I can't move easily.

For me, I have no plans to move backend but wanted to know how this is done in the professional circles?

So, would ShowData() be written in such as way that it requires the data in a generic format (e.g. JSON); and GetData() would ensure that whichever backend is used (parse, firebase, etc) it would always return data in the same format (JSON or whatever)?

Or is the way I have done it perfectly normal?

¿Fue útil?

Solución

You've correctly identified that there is a potential issue here if you ever want to replace parse-server with something else. The "solution" to this is, as you suggest, to ensure that all of your third party dependencies are wrapped with an adapter - then, if you ever need to switch out your dependency, you only need to rewrite the adapter.

In practice, many developers will not bother to do this. They will take the stance that it's not worth the extra development effort for something that they may never need. Others believe that it's worth the extra development effort anyway as it helps to structure the code and make it easier to read.

Licenciado bajo: CC-BY-SA con atribución
scroll top