Home  >  Q&A  >  body text

java - app或者微信也公用这套后端代码可以吗?还是重写一套后端代码呢?

我现在做了一个类似投资理财的网站(pc端耳朵),有假数据,我想在app或者微信也公用这套后端代码可以吗?还是重写一套后端代码呢?pc和app微信各一套,如果就公用一套,我现在的后端代码怎么给app展现数据??没有做过app后端,大神们说说

高洛峰高洛峰2744 days ago614

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:49:48

    Whether it can be shared publicly depends on how you write the code. If it is a project with separate front-end and back-end, just reuse the designed API. If it is the kind of code that is responsible for both the data layer and the presentation layer, you need to provide a pure data layer interface based on this set of code.

    For example, you originally rendered the page like this
    // Pseudo code
    return res.render(view, data);
    Then you should now provide an interface with only data like
    // Pseudo code
    return data;

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:49:48

    Don’t reinvent the wheel. If it can be reused, why not reuse it? Otherwise, the workload will be huge during update and maintenance.
    Even if the API interface cannot be reused, the original business logic can abstract some reusable underlying logic, so that only the new upper-level logic can be opened.

    reply
    0
  • Cancelreply