PHP to Java (using PtoJ)

前端 未结 5 2400
感动是毒
感动是毒 2021-02-15 15:32

I would like to transition our codebase from poorly written PHP code to poorly written Java, since I believe Java code is easier to tidy up. What are the pros and cons, and for

5条回答
  •  盖世英雄少女心
    2021-02-15 16:29

    I would say that automatic conversion from PHP to Java have the following:

    pros:

    • quick and dirty, possibly making happy some project manager concerned with short-time delivery (assuming that you're lucky and the automatically generated code works without too much debugging, which I doubt)

    cons:

    • ugly code: I doubt that automatic conversion from ugly PHP will generate anything but ugly Java

    • unmaintainable code: the automatically generate code is likely to be unmaintainable, or, at least, very difficult to maintain

    • bad approach: I assume you have a PHP Web application; in this case, I think that the automatic translation is unlikely to use Java best practices for Web application, or available frameworks

    In summary

    I would avoid automatic translation from PHP to Java, and I woudl at least consider rewriting the application from the ground up using Java. Especially if you have a Web application, choose a good Java framework for webapps, do a careful design, and proceed with an incremental implementation (one feature of your original PHP webapp at a time). With this approach, you'll end up with cleaner code that is easier to maintain and evolve ... and you may find out that the required time is not that bigger that what you'd need to clean/debug automatically generated code :)

提交回复
热议问题