As part of an ongoing civil engineering project, the need to formulate a mobile application that would represent the findings of the research was a necessity. First a brief of the application function is described.
5.1. Defining the platform
Determining the platform to be used to serve the function intended was a challenge. ChatGPT was asked to recommend a platform to be used to create mobile applications that uses Java language.
The following shows the typical question from the developer (Q1) and response by ChatGPT (R1):
Developer: “What Platform for mobile app development do you recommend using that uses java?”
ChatGPT: “If you want to use Java for mobile app development, one of the most popular and widely used platforms is Android. Android is an open-source platform developed by Google and based on the Linux operating system. It supports Java for app development, as well as Kotlin, a newer programming language designed to be more concise and expressive than Java.
Android Studio is the official integrated development environment (IDE) for Android app development, and it is recommended for developing apps using Java. Android Studio includes a wide range of tools and features to help you build high-quality apps, including an XML layout editor, a code editor with intelligent code completion, a debugger, and a variety of testing and profiling tools.
In addition to Android Studio, there are several other tools and frameworks available for Java-based mobile app development, such as Cordova, PhoneGap, and Ionic. These platforms allow you to build cross-platform mobile apps that can run on both Android and iOS devices using a single codebase. However, they may not offer the same level of performance or integration with the device hardware as native Android apps developed using Java and Android Studio.”
From the response above, even though the question was concise, with an expected outcome of a single platform recommendation, ChatGPT provided multiple different options including, Android Studio, Cordova, PhoneGap and Ionic. According to the unit of analysis mentioned in
Table 1, the response is considered as “not immediately useful ChatGPT response”.
To further investigate the response of ChatGPT, the question (Q1) was asked again three times, with the exact same wording in the same chat. The responses (R2), (R3), and (R4) were similar with (R1). Though the third time (Q1) was asked, response (R4) was incomplete. In all responses “not immediately useful ChatGPT response’ was recorded.
Furthermore, (Q1) was asked again but in three different chats. In all three chats the responses (1R1), (2R1) and (3R1) generated were different, where the first number in (1R1), (2R1) and (3R1) refers to three different chats, and the number following the letter refers to the first response in that chat. ChatGPT recommended in the three new chats 5 new platforms:
Eclipse
IntelliJ IDEA
React Native
Xamarin
Netbeans
Even though ChatGPT recommended Android Studio as the first choice in all four chats, “not immediately useful ChatGPT response” is also recorded for the chats as the question intended was to precisely recommend a single platform that uses Java, rather than multiple platforms that uses different computer languages including Java.
To establish a trend on the responses of ChatGPT and frequency of the words used, an online word cloud was used where all the responses of ChatGPT (R1,1R1,2R1,3R1) were inserted.
Figure 1 shows the results of the word cloud.
Based on the font height of words in
Figure 1 it can be perceived that the most common words ChatGPT used were Java, Android, and app as a response to Q1.
With the aim to receive a more useful response, the question’s wording was then changed, and the following question (Q2) was asked, and response (R2) was given:
Developer : “can you recommend a single platform for mobile app development that uses Java only?”
ChatGPT: “Yes, there are several platforms for mobile app development that use Java as the programming language. One such platform is Android Studio, which is the official integrated development environment (IDE) for developing Android apps. Android Studio is based on the Java programming language and offers a range of tools and features to help developers create high-quality apps for Android devices.
Another option is the Codename One platform, which allows developers to write Java code that can be compiled to native code for multiple platforms, including iOS, Android, and Windows. Codename One also provides a range of tools and libraries to help developers build feature-rich mobile apps with Java.
Both Android Studio and Codename One are popular choices for mobile app development with Java, so it's worth considering which platform best fits your specific needs and preferences.”
Yet the response still provided two options, that is Android Studio and Codename which was not mentioned in any of the responses to (Q1). Again, a “not immediately useful ChatGPT response” was recorded. Finally, question (Q3) was changed to a command with the aim to receive a straight-forward and immediately useful response. Question (Q3) and response (R3) were as follows:
Developer: “Recommend a single platform for mobile applications that uses java!”
ChatGPT: “One platform for mobile applications that uses Java is Android. Android is a mobile operating system based on a modified version of the Linux kernel and is designed primarily for touchscreen mobile devices such as smartphones and tablets.Android applications are typically written in Java and are compiled to bytecode that runs on the Dalvik virtual machine, which is specifically designed for mobile devices. Android also provides a rich set of APIs and tools for developing applications, including an integrated development environment (IDE) called Android Studio.Android is a popular platform for mobile application development, with a large user base and a vast array of third-party libraries and tools available to developers. It also provides a flexible and customizable platform for building applications that can run on a wide range of devices.”
Note that (Q3) used the word “Recommend” at the beginning of the question rather than “Can you” resulting in a single recommendation by ChatGPT as per (R3) response. Several other variations of (Q3) were asked including a verb such as “mention” “Provide” and “Give”, all in which resulted in a single platform recommendation. This important finding indicates that users should start with a verb in the question without the need of etiquette in asking, since this is a machine, it does not distinguish between asking kindly or not. Starting with “can you?” resulted in multiple platform recommendations. The results are that all responses for Q3 were recorded as a “immediately useful ChatGPT response”.
Although responses generated by ChatGPT that mentioned more than one platform and provided an extended description and reasoning behind the recommendations were considered as not immediately useful ChatGPT responses, it still provided insights and further understanding of the software available in the market.
To validate the recommendation of ChatGPT, G2, a website used for reviewing software [
24], was checked.
Table 2 shows the ratings of the software platforms.
According to [
24], and based on the ratings of users only, the results show that Ionic is the best platform for mobile apps, followed by Eclipse, IntelliJ IDEA and React Native, almost on the same level as Android Studio. An important finding to document is PhoneGap, a platform that was also mentioned by ChatGPT, is outdated and is no longer being used. This corresponds to the first physical artefact referred to in
Table 1 as a “wrong result generation”. Also, Ionic and Cordova only received 139 and 52 reviews respectively in [
24], whereas Eclipse and IntelliJ IDEA received more than 2000 reviews, making Android Studio the most suitable platform as it received more than 500 reviews. The findings based on [
24] are in line with ChatGPT most generated response, that is, Android Studio.
The choice of moving forward with Android Studio was made and the software was then installed.
The previous dialogue can be summarized as follows. When asking the same question with the exact same wordings in the same chat, ChatGPT generated the same response three times and once incomplete. On the other hand, asking the same question in different chats generated different responses all three times. Rewording the question to a command, rather than a question, resulted in more concise and direct responses aligned with the needs of the developer.
5.2. Creating the application
Initially, some YouTube videos [
25,
26,
27] were reviewed by the developer to familiarize himself with the platform user interface which seemed overwhelming to begin with, how to add a logo and how to change the icon of the application. The YouTube videos involved identifying the main features of the platform, understanding what layouts are, how to add images, where to place the code of the main activity and setting up the emulator to test the code.
Following watching the videos, a description of the intended app function was sent to ChatGPT requesting a code that can be used.
The following shows the request by the developer (Q4) and the response by ChatGPT (R4):
Developer: “I want to prepare a script for a smartphone application in Android Studio. The script shall describe how to program a material reusability calculator. The application should start with the title "Material Calculator". Then it should show the logo of the "University". It should have a drop-down menu with Disclaimer, Calculator and copyright. Clicking on the Disclaimer should present: "Disclaimer message" Clicking on Calculator shall open a dialogue asking for the following input: input 1, input 2 and input 3. input 2 shall be entered in kg/m3. Based on the following equation, the number of uses U shall be displayed based on a formula that uses the three inputs . The result of U shall follow the statement "Estimated max. number of uses:" If any input field was not filled, the following statement shall be displayed: "Input missing" Clicking on copyright shall display "Copyright: University "”.
ChatGPT: “Here is a possible script for a material reusability calculator Android application in Android Studio:”
Notice that the first response (R4) by ChatGPT was incomplete, corresponding to a wrong result generation. The question (Q4) was then asked three more times in three different chats, resulting in responses (1R4), (2R4) and (3R4), as an attempt to generate a complete code for the required purpose. (1R4) and (2R4) were also incomplete while testing (3R4) resulted in an immediate error message.
In (Q4) a query like follow up question on the reason why ChatGPT did not complete the code, was asked rather than a question starting with a command to assess if ChatGPT would admit its mistake:
Developer : “Why did you stop?”
ChatGPT: “Apologies, it seems that my response got cut off. Here is the rest of the script for the Material Calculator:”
The script provided by ChatGPT in respone to Q4 follow up, R4 follow up can be found in
Appendix A,
Table A2.
ChatGPT response continues beyond the code stating the follow “You will need to create a new Android Studio project and replace the MainActivity.java file with this script. The script defines the UI elements (EditText, Spinner, Button, TextView) and sets up the calculate Button to perform the necessary calculations based on the inputs provided by the user. Please note that the formula used to calculate the estimated max. number of uses is just an example, and you may need to adjust it based on your specific requirements. Additionally, you will need to create the UI layout (XML) file for the activity, which should include the necessary UI elements and the "Material Calculator" title, "University" logo, and drop-down menu with "Disclaimer", "Calculator", and "Copyright" options.”
What is interesting is that ChatGPT replied with an apology, admitting the mistake it had made. When testing the code in Android Studio, it revealed errors, and the application did not run. Since the developer is only a novice programmer, the first impression was that the code is completely correct, and the main issue revolves around placing the code in the software. However, all responses R4,1R4,2R4,3R4 were not useful. The approach of requesting the complete code all at once seemed not convenient, neither for the developer nor for ChatGPT.
As a result, a different approach was applied in a new chat, requesting ChatGPT (Q5) to provide a step-by-step guide (R5) on how to insert the code mentioned previously.
Developer: “Provide a step-by-step guide for a novice developer to prepare a mobile application on Android Studio. The script shall describe how to program a material reusability calculator. The application should start with the title "Material Calculator". Then it should show the logo of the "University". It should have a drop-down menu with Disclaimer, Calculator and copyright. Clicking on the Disclaimer should present: "Disclaimer message" Clicking on Calculator shall open a dialogue asking for the following input: input 1, input 2 and input 3. input 2 shall be entered in kg/m3. Based on the following equation, the number of uses U shall be displayed based on a formula that uses the three inputs . The result of U shall follow the statement "Estimated max. number of uses:" If any input field was not filled, the following statement shall be displayed: "Input missing" Clicking on copyright shall display "Copyright: University ".”
ChatGPT: “Sure, here's a step-by-step guide to creating a Material Reusability Calculator mobile application on Android Studio:
Open Android Studio and create a new project.
Select "Empty Activity" as the project template.
Give your project a name and package name.
Click "Finish" to create the project.
Open the activity_main.xml file, located in the res/layout folder.
Add the following code to create the layout for the application:”
Step 6 in ChatGPT response included the code to create the layout for the application. The complete code can be found in
Appendix A,
Table A3.
Question (Q5) was then asked two more times in two different chats (1R5), (2R5) to ensure consistency and validity of the code generated by ChatGPT before testing it in Android Studio. Interestingly (1R5) provided five steps rather than seven which was seen in (R5). Also, the code in (1R5) was different from what was generated in (R5). As for (2R5) that is, the second response of ChatGPT of question 5 in a different chat, the response generated was on a high, generic level and did not provide any specific codes.
From the three different responses generated, the developer was able to gain more insights on the steps towards successful app development. For example, steps like creating an empty activity, preparing the layout, uploading logos were all new to the developer.
Even with the steps provided by ChatGPT, it was still difficult for the developer to complete the code. Therefore, several follow up questions referred to iterations followed the response generated in R5. Steps one to four were simple steps that did not require any follow-up and was directly and successfully completed. Step five was followed with a single iteration to be completed. Step six was completed in three iterations.
Table 3 shows the steps generated by ChatGPT in response to Q5, the number of iterations, and if the step was successfully completed or not.
Steps one to five were relatively easy and were easily comprehended by the developer and considered as immediately useful. As for step six, the developer required three follow up questions requesting where and how to place the code.
As result, the following was concluded from all the trials above:
ChatGPT, when given a very long description, can generate wrong or incomplete codes.
A step-by-step guide can enhance the developer’s understanding of the workflow used by Android Studio but does not necessarily allow for successful app development. Though simple steps in the early process of the app development can be successfully completed through a step-by-step request.
Several follow-up questions must be asked by the developer to complete specific steps based on the complexity.
None of the physical “artefacts”, were considered useful and required varying number of iterations.
As a result, a third approach was applied. Instead of asking for a step-by-step guide, the developer broke down the application furthermore, to breaking it down into specific functions rather than the whole application to avoid incomplete or wrong codes.
One of the main parts of the app is to prepare a drop-down menu with multiple options. The following section shows the approach used.
5.2.1. Creating the spinner
The developer asked ChatGPT (Q6) on how to prepare a dropdown menu using Android Studio. The question was prepared based on the lessons learned from previous responses. The input should be a command (rather than a question) and include a request for a step-by-step guide. The word “detailed” following “step-by-step” was added as an attempt to improve the description generated by ChatGPT. The following R6 shows the response:
Developer : “Provide a step-by-step detailed guide on how to prepare a dropdown menu using Android Studio”
ChatGPT: “Sure, I can provide a step-by-step guide on how to prepare a dropdown menu using Android Studio.
Step 1: Create a new project in Android Studio Launch Android Studio, and create a new project by selecting "Empty Activity" and clicking "Next." Give your project a name and choose the appropriate package name, then click "Finish" to create the project.
step 2: Design the layout In the layout XML file, add a spinner view. The spinner view is the drop-down menu that we'll be creating”
ChatGPT then continues “Here we're using an "entries" attribute to define the options for the spinner. We'll create an array of countries in the next step.
Step 3: Define the options Create a new XML file in the "res/values" directory named "strings.xml". Add an array of countries to this file:”
ChatGPT further continues to step 4, “Step 4: Populate the Spinner In your Java code, create an ArrayAdapter to populate the spinner with the options defined in the "countries" array:”
Similarly, the scrip for the specific step is found in
Appendix B,
Table B1. ChatGPT response continues explaining thoroughly what each step and code represents.
“Here we're setting the adapter for the spinner using the "setAdapter" method. We're also setting the layout resource for the drop-down list using "setDropDownViewResource".
Step 5: Add a Listener If you want to perform an action when the user selects an item from the dropdown menu, you can add a listener to the spinner. Here's an example:”
Step 5 codes found in
Appendix B,
Table B1. ChatGPT follows up by stating the following “That's it! Your dropdown menu should now be working in your Android Studio project”.
Steps one and two were successfully completed without any follow-up questions as they were similar to the responses in R5. Steps three and four were attempted without any follow-up question but were unsuccessful. Some errors occurred not allowing the app to run. These errors were then sent to ChatGPT requesting to solve the problem. Question (Q6a) and Response (R6a) represent the first iteration concerning step three and four:
Developer: “I received this error:
C:\Users\miyad\AndroidStudioProjects\research3\app\src\main\java\com\research\research3\MainActivity.java:17: error: class, interface, or enum expected Spinner spinner = findViewById(R.id.spinner);”
ChatGPT: “This error message typically occurs when there is a syntax error or misplaced code in your Java file. It seems like the code snippet you provided may be incomplete or not placed within a class or method.
Here's an example of how you could define a class with a spinner in your MainActivity.java file:”. The response of ChatGPT can be found in
Appendix B,
Table B2. ChatGPT follows by stating the following, “Make sure that your code is placed inside the class definition for MainActivity, and that you have imported the necessary packages. Also, ensure that you have properly defined the layout file with the ID "spinner" in your activity_main.xml file.”
The code was then tested again, and a spinner was successfully created. Though, it is important to note that some extra steps, such as importing class that were shown as solutions by Android Studio due to errors generated. Android Studio usually marks a red line under classes that requires to be imported. The steps were done by the developer inspite of it being mentioned by ChatGPT. The options in the spinner, the disclaimer and copy right messages were then modified based on the needs of the developer and was also successful.
For a spinner, a single follow up question was enough to help the developer complete the simple task.
The next part of the application was that upon selecting one of the options, a specific action must be taken.
5.2.2. Setting up the functionality of dropdown menu
As described in the Application function section, each option in the dropdown requires a specific action to be taken by the application. A new chat was created and (Q7) was asked to ChatGPT and the following response was recorded (R7):
Developer: “Provide a step-by-step detailed guide on how to prepare a dropdown menu using Android Studio. The drop-down menu shall have three options. The first is a disclaimer message, the second is the material calculator and the third is the copyright. Selecting the disclaimer message opens up the message. selecting the calculator opens a new layout requesting user to put in three inputs. selecting the copyright shows the copy right message.”
ChatGPT: “Sure, here's a step-by-step guide on how to create a dropdown menu with three options in Android Studio:
Step 1: Create a new project in Android Studio
First, create a new project in Android Studio. Choose a project name and package name, and select your desired minimum SDK version.
Step 2: Create a new layout for the dropdown menu
Create a new layout file for the dropdown menu by right-clicking on the "res" folder in the project view and selecting "New" > "Layout resource file". Name the file "dropdown_menu.xml".
Step 3: Add a Spinner to the layout
In the new "dropdown_menu.xml" layout file, add a Spinner view to the layout. The Spinner will be used to display the dropdown menu options. Here's an example code snippet:”. The code snippet is found in
Appendix C Table C1.
Chat GPT continues “Step 4: Create an array of dropdown menu options
Create an array of strings to hold the three dropdown menu options. You can do this in the "strings.xml" file in the "values" folder. Here's an example code snippet:”. The code is found in
Table C1,
Appendix C. The response then follows “ Step 5: Set the dropdown menu options in the Spinner
In the activity or fragment that will use the dropdown menu, create a reference to the Spinner view and set the dropdown menu options in the Spinner using an ArrayAdapter. Here's an example code snippet:” Refer to
Appendix C,
Table C1 for the code snippet.
Step 6, the final step generated by ChatGPT included the following, “ Step 6: Handle Spinner item selection
Finally, handle the Spinner item selection to perform the appropriate action when an item is selected. You can do this using a setOnItemSelectedListener. Here's an example code snippet:”. For the code snippet of step 6, refer to
Appendix C,
Table C1. ChatGPT further elabores on step 6 metionining the following, “The case where "Material Calculator" is selected, you would need to create a new activity and layout file for the calculator interface. You can do this by right-clicking on the project folder, selecting "New" > "Activity" > "Empty Activity". Name the new activity "CalculatorActivity". Then create a new layout file for the calculator interface by right-clicking on the "res" folder in the project view and selecting "New" > "Layout resource file". Name the file "calculator_layout.xml". In the "CalculatorActivity.java" file, set the content view to the new layout file in the onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.calculator_layout);
}
Then add EditText views for the three inputs you require for the calculator, and handle the button click to perform the calculation.”
A similar approach was proposed by ChatGPT in R6 (Step one to five) regarding the spinner. Step six was the extra step that handled the selection options. Once again, the code was tested directly without any iterations but unsuccessful. The developer then asked follow-up questions in the same chat. The first question (Q7a) was to further explain steps one to four. Once again, one iteration for the steps was enough to get those done with. Step five required three iterations for the developer to understand how to complete it. Though, step six, which is what the application is supposed to do once the user selects a specific option, took more than 72 follow up questions to complete the code and get it working, this shows an exponential increase in the number of iterations due to the increase in complexity when compared with earlier steps. The conversation was like a one-on-one specific tutorial session. Questions on where to place the code, why did you use this function and how to implement it were asked. Follow up questions based on the errors received on Android Studio were also part of the conversion. The follow up questions resulted in corrective actions by ChatGPT. Specific questions related to what each option must do when selected were asked which furthermore increased the complexity of the code and the answers generated.
The back-and-forth conversation resulted in an application that was working perfectly fine. It is important to note that it took an average of 20 hours to complete the mobile application. An article written by [
28] mentioned that it would take around 3-4 months to develop an application using Android Studio. Another article [
29] divided applications based on the complexity level. According to [
29] a simple application would require a duration of 2-4 months to complete.
Figure 2 shows how the application looked using a Pixel 6 API 30 emulator when selecting different functions.
Once the main code of the application was developed, complexity and difficulty in handling modifications in the application was substantially reduced for both, ChatGPT and the developer. New chats were created where the complete code was pasted first, and then several follow-up questions were asked to add extra functions such as adding a reset button and setting up ranges for the accepted input. Even though “artefacts” received errors when applied in Android Studio, through several iterations, a novice developer can manage to overcome the issues and solve the problem, most of the added options when the code was fed to ChatGPT first, required an average of five iterations until the code ran error-free.
The insertion of the code first substantially reduced the number of iterations to achieve the results. For example, a reset button was required in the material calculator that could reset all the inputs provided by the user. The code was first inserted and then the question was asked. To get the reset button working, seven iterations were required, which is considerably lower than the number of iterations required in the previous requests. It is important to explain to ChatGPT prior to sending the code not to comment on script unless you ask a question. The reason behind this is that ChatGPT is programmed to automatically respond to any input provided by the user. A response to the code gives a description of what the code is intended to do.