As a result, I''''ll create a WinForm application utilizing Microsoft Visual Studio''''s C# programming language.. The local variable can only be used in the method in which it is defined; if
Introduction to the program
Scenario and Requirement Analysis
Design Phase
In this article, I use List as a list of objects It can be accessed by index It is located in the System.Collections.Generic namespace Where this list can be used to create a set of different variables like: Integer, string, And I use List with 2 objects It is used for the list of books in the library (aList) and the list of students borrowing books (bList).
- Book: This section contains a list that is used to hold the library's list of books; each new book will have the same data type and properties.
- Borrow: This feature includes a list that stores the loan list's text; each individual added will have the same data type and properties.
String booknameString datebString dater
Figure 9 Flowchart of Borrow Book
Key Features of Procedural Programming: (Sagar Bhatia, 2021).
+ Predefined functions: A preset function is usually an instruction with a name attached to it Predefined functions are usually included in higher-level programming languages, however they are drawn from a library or registry rather than a program 'charAt()' is an example of a pre-defined function that looks for a character location in a string.
+ Local Variable: A local variable is a variable that is defined in the method's main structure and is only valid inside the scope of the method The local variable can only be used in the method in which it is defined; if it is used outside of that function, the code will fail.
+ Global Variable: A global variable is one that is declared outside of every other function in the program As a result, unlike local variables, global variables can be utilized in any function.
+ Modularity: When two distinct systems are given two separate tasks to complete, they are grouped together to complete a bigger job first The tasks of each set of systems would subsequently be completed one by one until all tasks were completed.
+ Parameter Passing: A system for passing parameters to functions, subroutines, and procedures is known as parameter passing 'Pass by value', 'pass by reference', 'pass by result', 'pass by value-result', and 'pass by the name' are all methods for passing parameters.
Therefore, in my program, there are 7 main procedural paradigms used, which are:
+ Editing existing books in DataGridView of library.
+ Deleting a book in DataGridView of library.
+ Search book in DataGridView of library (Following Name, Author or Category).
+ Borrow book in DataGridView of library.
+ Return book in DataGridView of book borrowers.
+ Search book in DataGridView of book borrowers (Following Name or Book).
Object-oriented programming (OOP) is a programming paradigm that organizes software design around data, rather than functions and logic An object is a data field with its own set of properties and behavior (Alexander S Gillis, 2021). Structure: (Alexander S Gillis, 2021).
+ Classes: are data types that are created by the user and serve as the blueprint for individual objects, properties, and actions.
+ Objects: are instances of a class that have been constructed with specified data Real-world items or abstract entities can be represented by objects The description is the sole object defined when a class is created for the first time.
+ Methods: are functions that describe an object's behavior and are specified within a class In class declarations, each method begins with a reference to an instance object In addition, instance methods refer to the subroutines that make up an object Methods are used by programmers to ensure reusability and to keep functionality contained to a single object at a time.
+ Attributes: describe the status of an object and are defined in the class template Data will be saved in the attributes field of objects The class's characteristics are the class's own.
Object programming characteristics: (Alexander S Gillis, 2021).
+ Encapsulation: This concept asserts that an object contains all relevant information and only selective information is revealed Each object's implementation and state are kept private within a specified class This class is not accessible to other objects, and they do not have the ability to modify it Only a list of public functions or methods are available to them. This data masking feature improves application security and avoids data corruption that isn't intended.
+ Polymorphism: Objects merely show the internal mechanisms that let them to interact with other objects, concealing any extraneous implementation code The functionality of the derived class can be expanded Developers may find it easier to make adjustments or additions over time if they use this notion.
+ Abstraction: Code from other classes can be reused by classes Developers may establish relationships and subclasses between items, allowing them to reuse similar logic while preserving a distinct hierarchy OOP's virtue of forcing more extensive data analysis reduces development time and ensures greater correctness.
+ Inheritance: Objects are created to communicate behaviors and come in a variety of shapes and sizes The program determines what meaning or usage is required for each execution of a superclass object, avoiding the requirement for duplication of code Then a subclass is developed that extends the parent class's functionality Different sorts of objects can flow via the same interface thanks to polymorphism.
Popular pure OOP languages include:
Programming languages designed primarily for OOP include:
Other programming languages that pair with OOP include:
Event-driven programming is a programming paradigm in which the control flow of a program is determined by the occurrence of events This sort of software is made to detect events as they happen and respond with an appropriate event-handling technique, which is usually a callback function or method (ukessays, 2021).
Key features and characteristics of event-driven programming: (ukessays, 2021).
Explain some of programming paradigms
OOP paradigm
Object-oriented programming (OOP) is a programming paradigm that organizes software design around data, rather than functions and logic An object is a data field with its own set of properties and behavior (Alexander S Gillis, 2021). Structure: (Alexander S Gillis, 2021).
+ Classes: are data types that are created by the user and serve as the blueprint for individual objects, properties, and actions.
+ Objects: are instances of a class that have been constructed with specified data Real-world items or abstract entities can be represented by objects The description is the sole object defined when a class is created for the first time.
+ Methods: are functions that describe an object's behavior and are specified within a class In class declarations, each method begins with a reference to an instance object In addition, instance methods refer to the subroutines that make up an object Methods are used by programmers to ensure reusability and to keep functionality contained to a single object at a time.
+ Attributes: describe the status of an object and are defined in the class template Data will be saved in the attributes field of objects The class's characteristics are the class's own.
Object programming characteristics: (Alexander S Gillis, 2021).
+ Encapsulation: This concept asserts that an object contains all relevant information and only selective information is revealed Each object's implementation and state are kept private within a specified class This class is not accessible to other objects, and they do not have the ability to modify it Only a list of public functions or methods are available to them. This data masking feature improves application security and avoids data corruption that isn't intended.
+ Polymorphism: Objects merely show the internal mechanisms that let them to interact with other objects, concealing any extraneous implementation code The functionality of the derived class can be expanded Developers may find it easier to make adjustments or additions over time if they use this notion.
+ Abstraction: Code from other classes can be reused by classes Developers may establish relationships and subclasses between items, allowing them to reuse similar logic while preserving a distinct hierarchy OOP's virtue of forcing more extensive data analysis reduces development time and ensures greater correctness.
+ Inheritance: Objects are created to communicate behaviors and come in a variety of shapes and sizes The program determines what meaning or usage is required for each execution of a superclass object, avoiding the requirement for duplication of code Then a subclass is developed that extends the parent class's functionality Different sorts of objects can flow via the same interface thanks to polymorphism.
Popular pure OOP languages include:
Programming languages designed primarily for OOP include:
Other programming languages that pair with OOP include:
Event-Driven paradigm
Event-driven programming is a programming paradigm in which the control flow of a program is determined by the occurrence of events This sort of software is made to detect events as they happen and respond with an appropriate event-handling technique, which is usually a callback function or method (ukessays, 2021).
Key features and characteristics of event-driven programming: (ukessays, 2021).
+ Service Oriented: Service oriented programming is a crucial component of event-driven programming that is used to develop programs for services It does not slow down the computer since service oriented programming uses very little processing power and normally runs in the background of the operating system.
+ Time Driven: Time driven programming is a paradigm in event driven programming; it's code that runs on a time trigger
Time driven programming can be a specific code that runs on a specified time, such as once an hour, once a week, or once a month; it's a pre-set to do activity Windows Update, for example, is a time-driven system in which the user may specify when to update or when to look for and download updates.
+ Event Handlers: When a certain event is triggered, event handlers are a sort of function or method that performs a specified action For example, an event handler may be a button that displays a message when the user clicks it and closes the message when the user clicks the button again.
+ Trigger Functions: In event-driven programming, trigger functions are functions that determine what code to execute when a given event happens They are also used to determine which event handler to use when a specific event occurs.
+ Events: Mouse, keyboard, and user interface events must be triggered in the program for them to occur, which means the user must interact with an item in the program, such as clicking a button with a mouse, selecting a button with the keyboard, and so on.
Here are some examples of possible events:
+ Click the button on the screen.
+ Press the key on the keyboard.
+ Receive the output signal of the sensor.
+ Receive messages from other programs or threads.
Explain the common features of an IDE
Definition
Integrated development environments (IDEs) are programs that make it easier to create other programs One of the key advantages of an IDE, which is designed to integrate all programming jobs in one application, is that it provides a central interface with all the tools a developer requires, including: (Veracode, 2019).
+ Code editor: These editors differ from text editors in that they seek to either simplify or enhance the process of creating and modifying code for developers.
+ Compiler: Compilers convert source code written in a human-readable/writable language into a computer-executable format.
+ Debugger: During testing, debuggers are used to assist developers in debugging their application applications. + Build automation tools: These may be used to automate typical development processes in order to save time.
This is how the Source Editor and Debugger look like in Microsoft Visual Studio 2021
Figure 23 Visual studio interface (Article, 2021).
Common features of IDE
I use Visual Studio 2021 with C# Winform for this design, so I'll go over some of its main features. g , g
When we open Visual Studio, we will see the window screen of Microsoft Visual Studio Here, we can easily choose different functions such as: Open a project or folder or can create a new project Besides, we can also easily track back old projects in Open Recent.
Figure 24 Start Window of Microsoft Visual Studio
We will select Create a new project, then find Windows Forms App (.Net Framework) for C# Then fill in the information and we will have a Windows forms as shown below.
In it, Visual Studio has supported us with the toolbox It has all the necessary features for us to use for example:Button, Check Box, Label, etc Thanks to that, form design will be easier and more efficient for programmers.
With the proposal completed, it saves your time a lot It will suggest you the passages that you use the most And in some cases when you forget the name of the properties or method of an object, it can help you easily.
2.2.3 Generate getter/setter, constructor automatically.
To shorten the time, when creating a class for an object, we need to build a getter/setter for each part of it With the shortcut "propfull" we can quickly create a function, then we just need to press "Tap".
After we have finished the code, we will run the program Visoul Studio gives us 2 options: with and without debugging.
Figure 30 Start with and without Debugging
Debugging process
Debugging is the process of using debugging tools to assist developers find and fix flaws, problems, and anomalies in computer programs that impact how they function and what they produce Debugging allows the software to function properly and effectively by checking, detecting, and correcting flaws or defects (ee, n.d.)
Almost all IDEs, such as Eclipse, Visual Studio, Android Studio, Net Beans, and others, have debugging facilities The stages to debugging are usually determined by the sort of fault you're seeking to solve I'll go through two different sorts of debugging procedures.
They're comparable in certain ways:
If you're stuck with DevideByZeroException, for example, you may set a breakpoint in this method and run it in debug mode to observe it execute step by step and investigate how your code acquires a variable with a value of zero Run-time Error is the name for this sort of error DevideByZeroExceptions are discovered during the execution of the program.
Logical errors are difficult to detect since they are not always obvious A logical mistake is a flaw in a software that causes it to run regularly but not abnormally (or crash like Run-time error) This mistake causes an unexpected error or other behavior, which you may not notice right away You build a C# function to calculate the sum of two integers, for example.
This code contains a logic error It is missing parentheses in the calculation, so when code execution, it doesn’t give you an expected result.
3.2 Debugging facilities available in the IDE:
Let me give you an example of the features accessible in the IDE Because most IDEs contain similar debugging capabilities, I'll use Microsoft Visual Studio 2021.
To debug, open your application and set one or more breakpoints that you want to test, then launch the debugger.
In line 362, set a breakpoint by clicking the left margin of the first line or clicking on line 362 and press F9.
Press F5 (Debug/Start Debugging) to execute the code in debug mode and the debugger runs to the line where you set the breakpoint.
Press F10 to Step Over which means to execute the code line by line.
You can hover over the variable to view the current value in a data tip
STEP INTO: this is like Step Over (F10), if the current yellow highlighted section is a method calls, the debugger will go inside the method.
Figure 34 Result of Step Over in Visual Studio tip
When you're troubleshooting a method and need to return to the main code Within the current method, press Shift – F11 to execute and complete the method, then pause at the line where it was called.
RUN TO CURSOR: This step will start debugging and sets a temporary breakpoint on the current line of code Chose Stop Debugging or press Shift – F5 In line 395, right-click and chose Run to Cursor or press Ctrl + F10.
Run to Click: In the debugger, hover over a line of code until the Run to Click button appears Visual Studio Debugger's Run to Click button in action Node indicates that the line represented by node will be executed on the left-hand side To begin, click the Run to button The debugger jumps to the specified line of code.
The Locals: this window displays variables that appear in the local scope.
Watch: You can also use the Watch (Debug/ Windows/ Watch/ Watch (1,2,3,4)) and QuickWatch (right-click on variable / Debug/ QuickWatch) to inspect the variables.
Debugging is the art of diagnosing errors in program and then you will know how to correct them I find it is very important to learn how to debug a program so you can make an application that is more secure and more effective No discussion of debugging helps you to prevent bugs It doesn’t matter how well you write code, if you write a wrong program, it won’t help anyone If you write a correct program, but the user cannot use it, so it would count as you haven’t written the code So a good debugger will let them know where the problem is.
In short, I will show some basic debugging steps:
+ Recognize if the bug appears.
+ Determine how to fix the bug.
In this section, I have shown you how to use debug tools in Visual Studio 2021 and their debugging facilities in details,they are very powerful feature and there are close step of debugging In conclusion, debugging will help programmer to develop a program more secure, robust applications
Use of an IDE for development of applications contrasted with not using an IDE
Figure 40 Using visual studio to code
The IDE gives the programmer a variety of features and tools to help them build software It assists them in increasing their production, reducing debugging time, and solving difficulties IDE is useful for the following tasks:
1 Easy text entry without having to bother about namespaces, classes, or projects.
2 Display view files, errors/warnings, console/unit tests, and code source on the same screen in an efficient manner.
3 Type-as-you-warn (Some problems, for example, don't even necessitate a compilation cycle.).
4 Hover over an item to receive helpful hints.
5 Organize imports (in Java, add relevant imports automatically; in C#, use directives).
8 When you can't recall the name of a function or method, use autocomplete (With key: Tab).
9 Unit tests may be easily executed from the same window.
10 Integrated debugging is number ten.
11 Source control that is integrated.
However, there are several disadvantages to utilizing IDE, in my opinion:
1 We'll have to rely on them.
2 IDEs are sophisticated tools It will require time and patience to maximize their benefits. p q p
3 Is uninterested in fixing code, bad practices, or terrible designs: IDEs are similar to paintbrushes in that they assist you in auto-correcting your code design, thus you rely on them In summary, you must use your abilities to construct a masterpiece and make a decision.
4.2 Not using an IDE (text editor):
1 There are no more distractions
2 Save your code in a text editor and execute it from the command prompt It will provide you with a realistic understanding of the programming and execution process.
3 You will learn and teach yourself what to put on the following line of code because there is no autocomplete option.
4 You can encounter a code syntax or logic error when you execute the application Analyzing and resolving these issues can help you improve your debugging abilities.
1 Not for beginners: building a website needs a basic understanding of HTML tags for visitors.
2 Adding a certain style and formality may take longer.
Coding standards
Coding standards in my code
- Pascal case: Recognizes that all words begin with an uppercase letter and all other characters begin with a lowercase letter Use for naming classes and methods.
- Camel case: Similar to Pascal case, but the first letter is lowercased Variables and method arguments are also included.
Curly brackets: these symbols must be placed under the if, for, while, etc.
Inter-term: Put a space after comma and semicolon, around operators.
Comments: Comments should be as brief as possible, and they should never repeat code.
Lines at the same level of nesting should stand out.
Figure 44 Make lines at the samee level
Var: is used for various variables that are designed to have a shorter duration (as opposed to int, string, and so on);nevertheless, I only use it in one place in my sample project to validate client decisions.
Blank line: All relevant lines of code should be grouped together in a single block A blank line should be used to separated two code sections.
- Never distinguish the methods by number.
- There are no special characters in the variable name, which is an associative string of characters (no spaces).
- Accents cannot be added to variable names in Vietnamese.
- Numbers cannot be used as the first character in a name.
- Variable names must be unique.
- The name of a variable cannot be the same as a keyword.
Figure 47 Keyword in C (Dotnet Concepts, 2011)
Coding standard is necessary in a team as well as for the individual
Following J.Delta (2020), consider your product and how you want to build it You will add new features every month You'll go through bugs in reports every quarter Coding standards will assist you in understanding what you're doing and what is happening with their code As a result, finding and correcting errors will be easier, and programmers will save more time.
Different coding standards will also have an impact on the team's effectiveness and morale When your organization recruits new employees, it will take some time for them to adjust to your team's coding style They may get acclimated to it quickly and avoid making the same mistakes over and again if they adopt Coding Standards Not only that, but debugging and testing will be considerably more difficult if everyone utilizes different code.
Instead of recommending a corporate solution, I suggest considering the following alternatives.
Things to think about while developing coding standards:
- Emphasize decision-making values: Principles can help a developer approach code in a more systematic way.
For instance, putting a focus on working closely with a company might help you organize your day-to-day coding tasks.
- Long-term priority: An encryption standard based on principles should be able to withstand modifications for at least two or three years.
Procedural approach: all-inclusive coding standards:
- Decide on a focal language: JavaScript, C#, and PHP are all options for your firm It's possible that include all of this in your coding standards isn't feasible.
- Strike a balance between theory and practice: State concepts and show instances of effective code to benefit procedures.
Example: Write remarks in plain English with little slang.
- Establish a time limit: Even if the document is valid, a standard document of 200 pages discourages developers from opening it.
- Variable names must be unique.
- If you adopt a procedural approach to cryptography standards, designate someone to own and manage them Otherwise, you risk having an out-of-date document with minimal value.
- Make some decisions about what makes sense for your organization based on those alternatives Try to strike a balance between your personal preferences and what your customers value Customers in the military industry, for example, place great importance on security and internal controls Start incorporating such features into your product if that's what your consumers want.
Sagar Bhatia (2021) “Procedural Programming” [online].
Available at: https://hackr.io/blog/procedural-programming [Accessed 6 Jan 2022].
Alexander S Gillis (2021) “object-oriented programming (OOP)” [online].
Available at: https://searchapparchitecture.techtarget.com/definition/object-oriented-programming-OOP. ukessays (2021) “Event-Driven Programming Features” [online].
Available at: https://www.ukessays.com/essays/computer-science/eventdriven-programming-features-6167.php ee (n.d.) Retrieved from ee: http://www.ee.ncu.edu.tw/~jfli/soc/lecture/Lab_02.pdf
III Veracode (2019) “What Is an Integrated Development Environment (IDE)?” [online].
Available at: https://www.veracode.com/security/integrated-development-environment
J.Delta (2020) “Coding Standards Và Cách Viết Code C++ Chuẩn Đẹp” [online].
Available at: https://codelearn.io/sharing/coding-standards-va-cach-viet-code-cpp [Accessed 6 Jan 2022]. Dotnet Concept (2011) “c# Reserved Keywords” [online].
Available at: http://dotnetconceptsall.blogspot.com/2011/09/c-reserved-keywords.html [Accessed 6 Jan 2022].Article (2019) “Welcome to the Visual Studio IDE | C#” [online].