This C# version uses the MVC model.

The Model

The model represents the database. It defines the database table as well as the columns. The perameters are set in the class, and translated into SQL on the server side.

The View

The view is a web page that displays the data and is the interface between the user and the applicaiton. It uses a combination of HTML, CSS, Javasctipt and C# to display the web page.

The Controller

When the view, or web page is interacted with by the user, the controller is consulted to determine the action to be taken. In this case, the user enters data in a form, and when the button is clicked, the controller executes the appropriate action determined by the code. It communicates between the model and the view. The controller also exectues any commands on the back end database as dictated by the code. In this example, the controller recieves the data entered in the form, executes the function to reverse the string entered, communicates with the database to make the designated changes, then sends the result back to the view and displays it.

Application Website C#

Git Repo C#


This javascript version is structured in three functions.

The first thing done was to add an event listener to the button so the code will fire when the button is pressed.

The next getValue function gets the value from the text input field, then it will call on a couple of "helper" functions explained below.

The first helper function is called reverseString. This function will first check to make sure at least two characters were entered. Then it will loop through the characters entered in the text field backwards from the last character to the first, and then concatenate them into a string. The original string entered and the reversed version are compared to each other. If they match, it is a palindrome. Finally it will pass on the results to the next displayString helper function.

The next helper function is called displayString. This will take the string passed to it from the reverseString helper function and then inject it into the web page for display.

In summary the getValue function gets the value from the text field, it calls the reverseString function to reverse the text and compare it to the original string to see if it is a palindrome, then it calls the displayString function to display the results on web page.


Application Website JS

Git Repo JS