CHAPTER 3 IDE problems, debugging procedures, and coding standards
3.2 Use the IDE to manage the development process of the program(M3)
To be able to use a good IDE that fits our application development needs, we need to choose a language in the IDE that suits our needs. In this section, I will use a language called C# which is considered a programming language it uses to create a program. I use Visual Studio software to create and manage them.
❖ Step 1: We need to install the latest version of visual studio software to be able to use it easily. This can be considered an IDE used to develop a program or an application.
This is quite a famous application among programmers. Visual studio I have installed on my computer 2019 version is considered the latest version.
• After the installation is complete I open visual studio it will appear as shown below.
Figure 3-8 Create a new project or open project.
In this interface it will appear two main parts:
• On the left side of the interface, it will show all the projects you have worked on.
• On the right side of the interface, it has the functions of opening files in other folders and creating new files
• Open a project or solution:it is used to open a project in a previously default directory that Visual studio installed previously.
• Open a local folder:it is used to open a project that you created earlier and is saved in a certain folder.
• Create a new project: used to create a new project.
❖ Step 2: we will create a project using the "create a new project" function.
Figure 3-9 Create a new project.
• After you click "create a new project" it will appear an interface and on the left side of the interface it will appear the projects you have worked on recently.
• In the middle part of the interface will appear a table of items for you to choose from such as languages, operating systems for you to program, and areas in programming such as consoles, games, Service, web, mobile, office….
• In this part, I will choose c# as the main language to create projects on the win- dows operating system.
Console interface:
Figure 3-10: Choose project templates
Figure 3-11: Set the name of the new project and select a framework.
• After we have selected the language as the project, operating system, and programming system.
• we will enter a name for the project and choose a folder to save the project and click "create" so that the IDE will create a programming space for you.
❖ Step 3: we start working on the project we created earlier in the IDE.
Figure 3-12: Introduce workspace in Visual studio.
I'm going to write a simple project that counts the factorials from 1 to n so that it prints to
the. scree
Figure 3-13 count the factorials from 1 to n.
To run the program we press start. This is the result.
Figure 3-14 Result.
To create a new class or a new form, do the following steps:
Figure 3-15: Create a new item in Visual studio.
To create a new class or a new form, do the following steps:
Right-click and select add -> new item, or press "New item...". Then, a new window ap- pears.
Figure3-16: Create a new class.
We will select an item and give it a name. In this picture, I choose "class".
Figure3-17 Workspace of class in Visual Studio.
I will use break-point, by clicking on the left sidebar it will appear a red dot, so I can see how the program does the steps.
Figure3-18 Set breakpoint in Visual studio.
Then press <start= to know the steps in turn
Figure3-19 How to follow the program.
3.3 Evaluate the use of an IDE for development of applications contrasted with not using an IDE(D3).
Benefits of using IDE:
• Serves the environment that the majority of developers require, for example:
• It can suggest and complete commands in a single language.
• Providing a database administration system, as well as a project management system and source code.
• The IDE will automatically break and arrange the code, and it will also verify variables to make it easier for programmers to handle when working.
• The IDE offers a debugging capability that helps programmers figure out where the mistake is and what's causing it.
• In addition, IDE uses distinct colors to separate keywords, variables, and values, making it easier for programmers to notice and distinguish them while working.
❖ However, programmers will find it tough to construct and create an application if they do not use an IDE. We must write the language's rules, which makes the compilation of source code into machine language more difficult, and the task of controlling the application development process more challenging. Regardless of whether compilers, editors, or support for a programming language are available, the process of developing an application requires many more stages, and users must manually transfer data from step to step for the computer to understand.
Some popular IDEs:
Figure3-20 Some IDEs.
4.1 Explain the debugging process and explain the debugging facilities available in the IDE(P4).
Debugging: is one of the process of finding and correcting errors in a program.
Debugging often takes a lot longer than writing programs because logic-related errors are often difficult to spot. Visual Studio provides us with many intuitive tools to simplify the process of debugging, finding and fixing program errors easier and faster.
The commonly used debugging procedure is:
• Step 1:Try to run the program a few times to check the problem.
• Step 2: Detect bug.
• Step 3: Double-check what is happening that is causing the error.
• Step 4: Fix bug.
• Step 5: Run the program again to see if the error is still there.
One of the most common debugging means:
I will write a simple project that counts the factorials from 1 to n so that it prints to the screen.
I will create it and discuss common mistakes
Line 15: error with code "CS0103". we forgot to declare the variable "string" so we got anerror message.
string st = Console.ReadLine();
Need to declare library variable "string" as above I have fixed above.
Line 19: Bug has code <CS0201= The for loop is the wrong structure. We need to fix it as follows:
for int ( i = 1; i <= n; i++)
Results after debugging.
Now, it can run:
It will appear in the console image and waiting for the user to enter data.
Figure3-21 Result.
In case your program doesn't give you the desired result or cook like you know how your program works then you set the "breakpoint" by double-clicking on the red bar as shown in the picture and pressing start to get started.
Some error cases in visual:
first, I will create a window form to solve the first-degree equation enter two numbers A and B and print the result.
The source code of this form:
However, I found the textBox1_TextChanged method redundant so I removed it.
After deleting it will give an error:
The reason it gives the error is that we deleted the part we double-clicked in the form part it will create for us, when we delete a method that contains the code it generated it will make a mistake. It gets deleted and it says it doesn't understand what Form1_Load means in the source code it generates.
After we fix the method we deleted.
Now, we can see the operation of the program as we like.
Figure3-22 Result.
The next error is that we forgot to declare the library.
using System.Windows.Forms;
if we don't declare the library "using System.Windows.Forms;" then when declaring "
Application" it will get an error as shown above.
To fix that error, I will Declare the library "using System.Windows.Forms;" as shown below.
Now it's gone error.
4.2 Evaluate how the debugging process can be used to help develop more secure, robust applications(M4)
Debugging:
is one of the computer programs used to deal with errors in the program, when it produces incorrect results or cannot be run. debugging makes our program more robust, making our program more complete it needs to handle any input or event it may encounter. should be powerful and create the ability to quickly detect vulnerabilities.
prevent hackers from entering data and crashing systems, applications... So the debugger helps us a lot in our work. It can diagnose errors and sometimes also pro-vide fixes for developers. Most IDEs have debuggers to help programmers generate code faster and avoid as few errors as possible
IDE debugger:
❖ Advantages.
• The IDE's debugger may assist programmers with unscheduling or changing variables, code, or any other material of the program while it is running; moreover, when debugging, I can stop and resume when debugging error is completed.
• Debuggers provide several techniques to decrease the time and repetitive labor involved in nearly every debugging activity.
• The visual debugger is integrated into the IDE it gives us easy access to smart editing and all the other capabilities found in the IDE. In a single integrated development environment.
• Both the visual debugger and the console debugger are helpful and share similar capabilities.
❖ Disadvantages.
• In fact, sometimes when the IDE debugger finishes fixing the error, it runs and gives incorrect results.
• Sometimes the IDE can't find some errors in the library.
Example about IDE debugger.
Figure3-23 Program has error.
Figure3-24 IDE debugger find error . Errors in the
program
IDE debugging found error and debugging
Figure3-25 The program is out of error.
Handmade debugging.
This is manual debugging by our hands and eyes, do not rely on debugging software at all.
❖ Advantages:
• The program's issue has been fixed.
❖ Disadvantages:
• When you watch the program again, you will realize that there was an error.
• If you create a large program, it will take a long time to fix all the errors.
• This debugging procedure is rarely used by programmers.
The program is out of error.
Figure 3-26 The program has a line of code with the wrong keyword.
4.3 Critically evaluate why a coding standard is necessary in a team as well as for the individual(D4).
Define:
Coding conventions: are rules for a particular programming language that prescribe programming style, techniques, and procedures for each component of a program developed in that language. File organization, indentation, comments, declarations, statements, white space, naming conventions, programming techniques, and programming concepts are often covered by these conventions, Programming best practices, architectural best practices, and so on. These are criteria for the structural quality of software. These recommendations are strongly advised for software programmers to follow in order to increase the readability of their source code and make software maintenance easier. Coding rules apply solely to a software project's human maintainers and peer reviewers. Conventions can be as formal as a defined set of standards that a complete team or organization observes, or as informal as an individual's regular coding methods. Compilers do not enforce coding standards.
Figure 3-27 Symbolic of Coding standards wrong keyword
Benefit :
• Easy to maintain: If coding standards are strictly followed, the code will conform to the standard, making it simple to maintain and conserve.
• Efficiency: Developers frequently spend a significant amount of time fixing problems that they should not have considered if they had followed the coding standard since it helps avoid problems from happening.
• Reduced complexity: The more complicated the code, the more likely mistakes are to occur; coding standards will assist in removing complexity and improving program productivity.
• Error correction: If the source code is prepared in accordance with coding standards, it is easy to discover errors.
• Cost savings: The aforementioned benefits, particularly the ability for developers to reuse any code when needed, will significantly cut expenses.
The benefit of coding standard for a team or personal:
• Because one person cannot build a huge program or application, we must divide it into little sections, each of which performs a distinct function, and then combine them into one giant program. Coding standards are intended to identify each person's work, not to generate confusion or, worse, repetition. Furthermore, during the length of the project, all team members can trade and absorb code created by other team members. The second factor is how simple it is to protect and manage code inside a project or organization. Finally, boost team members' productivity.
• The coding standard improves the aesthetics of each kernel's program, making the partners more impressed with the project. Future applications will be easy to build and debug with proper care and upkeep. It significantly decreases the cost of soft- ware development as well as each individual's working time.
5.1 Outline the coding standard you have used in your code(P5).
Variable:
• Avoid using a lot of global variables, only use them when absolutely necessary.
• We will put footnotes for each section and explain each function of each variable.
• We need meaningful and understandable names.
Some notes in naming:
• Do not use the same names again (case sensitive only) Identifiers are difficult to recognize, especially when they are used in the same context and only differ by case.
• Don't establish two namespaces with the same name that just change in case letters (upper case / lower case).
• Do not build a method with parameters with the same name and only different case.
• Acronyms should not be used in IDs or parameter names. Though you must employ acronyms, utilize Camel Case spelling for acronyms with two or more characters, even if it negates the usual abbreviation of one word.
• When naming abbreviations, you can use the Pascal case or Camel case to name.
• Avoid using acronyms or parts of identifiers, such as GetWindow written to Gethin.
Naming rules:
Conventional types of capitalization:
Pascal Case: The identifier's initial letter and the first letter of each subsequent word must be capitalized. To name a name with three or more characters, use Pascal Case.
Camel Case: The first letter in an identifier is a lowercase letter and the first letter of the following hyphen must be capitalized.
Uppercase: All characters in identifiers must be capitalized. Use this rule for identifiers with 2 characters or less.
Named Assembly and DLL: Use namesthat generally describe the internal functions of Assembly.
Name the namespace:
• Use Pascal syntax to name the namespace.
• Use the prefix of company and organization names to limit the conflict of namespaces with the same name.
For example:
Name the class, struct, and interface:
• Use nouns or noun phrases to name classes, struct. Use Pascal's case.
• Name the interface an adjective phrase, or you can use a noun or a noun phrase.
• Do not use the prefix "C" for class names.
• Should end the name of the inheriting class with the name of the base class.
• Use the "I" prefix for the interface name.
For example: Name the class
• Name the interface:
• Name the method, property, and field of a type:
❖ Name the method:
• Use verb or verb phrase for method names.
❖ Name properties
• Use nouns, noun phrases or adjectives.
• Do not use "Get" prefix for attribute names.
❖ Name the field
• Use Pascal case to name the field.
• Use nouns, noun phrases or adjectives.
• Do not use prefixes for field names.
Indent:
• it makes the source code easier to learn, easier to understand it makes the source code easier to learn, easier to understand.
• Every substatement inside a block must be indented.
• The opening braces must be in a straight column with the closing brace.
• we need to avoid confusing using verbose encodings, length of functions we should keep to a minimum and easy to understand.
For example: Solve equations of degree 1:
❖ CODE
This is result
Figure3-28 For example.
Some naming ways for objects in <winform=:
Table 3-1: Some coding standard.
For example: I design a program that calculates quadratic equations, by using wiform.
❖ I designed the Form as follows:
Figure 3-29 Form Design.
CODE:
OBJECT NAME SETNAME FOR OJECT Textbox txt Button btn Label lbl CheckBox chk LinkLabel llbl TabControl tab DataView dvw
Figure 3-30 Code Form.
After finishing writing the program.
Figure 3-31 Finish form.
Test.
Figure 3-32 Test
CRITICAL EVALUATION
Regarding the aforementioned task, I believe I am completely deserving of a Certificate of Merit because I successfully met the criteria of the passing section and received a noteworthy mark in the assignment summary. I've discussed the differences between procedural, object-oriented, and event-driven programming, as well as the IDE. Using the IDE, implement fundamental algorithms in code, identify and show the debugging process, and discuss the relevance of coding standards.
CONCLUSION
After completing this report I have achieved the definition of algorithm, flowchart, application software development. In addition, I know the characteristics of procedural programming, countermeasure, and event direction. Know IDE concept and IDE problems.
Know how to debug, correct errors and the importance of coding standards