Introduction:
We have a webapp in classic ASP that is becoming increasingly difficult to maintain as it grows. The complexity of the code and the numerous ASP pages required are hindering our ability to develop new features. I believe it's time we modernize the system, and I would love to hear feedback from the community on how modern webapps operate.
Question:
I understand that modern webapps typically consist of two main components: the front end (user-facing interface) and the back end (server/database). In our current ASP setup, the backend and database requests are intertwined with client-side code. I believe there should be a clear separation between these components, and JSON seems like the ideal solution.
The diagram below illustrates my proposed architecture:
I suggest having front end and back end developers collaborate by defining an "API." For instance, if the business requirement is to display a list of current customers,
Front end developer: I need to show a list of customers to the user.
Back end developer: I need to retrieve a list of customers from the database and send it to the front end developers.
This data could be represented in JSON format like this:
[
{
"fname": "John",
"lname": "Doe",
"price": "5"
},
{
"fname": "Jane",
"lname": "Deer",
"price": "5"
}
]
Implementation Plan
Front End Code:
Assumptions: Single-page app, All requests directed to one server page, JavaScript with jQuery, Knockout.js
//AJAX request for data using jQuery and GET method
$.getJSON('/index', //The endpoint for data retrieval
{"request":"customers"} //JSON indicating the requested data
, function(data) { //Callback function
//Process the retrieved data
//Integrate into MVVM (Knockout.js)
someKnockoutMappingFunction();
});
Back End Code:
Assumptions: Java
String request = req.getParameter("request");
if (request == null) {
//Handle error case
}
else if(request == "customers")
{
//Retrieve and format data from the database
someDatabaseToJSONFunction();
//Send the formatted data back to the client
someSendJSONBackFunction();
}
Conclusion
Do you think this approach is viable? Has anyone implemented a similar model and can offer insights before I proceed? Any tips on quickly transitioning from ASP?
Thank you in advance!