Docsity

Assignment Title Analysis and Design a solution for procedural programming problem, Assignments of Computer science

Partial preview of the text

Download Assignment Title Analysis and Design a solution for procedural programming problem and more Assignments Computer science in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

P2 P3 P4 P5 M2 M3 M4 D2 D3 D

  • User can add books with its information such as: title, author, publication date, category etc and update it

II. Chapter 2 – Explain programming paradigms

1. Procedural Programming with source code and illustrations a. Overview Of procedural programming

  • Procedural programming language is one that uses sets of functions and commands to complete actions. Many programming languages use the procedural programming paradigm, including BASIC, C and Pascal.

Figure 1: Procedural Programming

b. Key features of a procedural programming

  • Predefined function : Is a function available in a procedural programming language from a library of available functions. These functions allow a programmer to complete common tasks without creating the required code themselves.
  • Local variable : Is a programming variable that has a local scope of use. This means the variable only functions in the function in which the developer defines it.
  • Global variables : Increase functionality when local variables are insufficient. Developers can use global variables in nearly all functions.
  • Parameters passing : Are the data values that transfer from each function within a code sequence.
  • Modularity : is a structure in which a developer divides the functionality of its code into a series of smaller blocks.
  • Top-down approach : Procedural programming relies on a top-down approach to design and creation. Under this approach, a developer first defines the primary goal of the program, then assesses the components required to complete it. 2. Object-Oriented Programming with source code and illustrations a. Overview of Object-Oriented Programming - Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.

Figure 2: Object-Oriented Programming

b. Main principles of Object-Oriented Programming

  • Encapsulation: This principle states that all important information is contained inside an object and only select information is exposed. The implementation and state of each object are privately held inside a defined class. Other objects do not have access to this class or the authority to make changes. They are only able to call a list of public functions or methods. This characteristic of data hiding provides greater program security and avoids unintended data corruption.
  • Abstraction: Objects only reveal internal mechanisms that are relevant for the use of other objects, hiding any unnecessary implementation code. The derived class can have its functionality extended. This concept can help developers more easily make additional changes or additions over time.
  • Inheritance: Classes can reuse code from other classes. Relationships and subclasses between objects can be assigned, enabling developers to reuse common logic while still maintaining a unique hierarchy. This property of OOP forces a more thorough data analysis, reduces development time and ensures a higher level of accuracy.

b. Characteristic of Event-Driven Programming

  • Service-Oriented: Service-oriented is a significant aspect of event-driven programming used to develop programs for services. It does not slow down the computer since serviceoriented only uses a tiny percentage of the computer processing power and services typically operate in the operating system's background.
  • Even: Nothing will happen unless the user interacts with the software, according to this feature. Clicking buttons and entering text into text fields are examples of events.
  • Trigger Functions: According to this feature, nothing will happen until the user interacts with the software. Events include things like clicking buttons and putting text into text areas.
  • Event handlers: When an event happens, an event handler is a function or method that performs a particular action. An event handler may, for example, be a button that, when clicked, shows a message and then shuts it when the user hits the button again. 4. Conclude which paradigms will be used to develop the application with explanation
  • I used OOP and mixed with POP to build a library management program in this program. I use both of them because it's easier to manage code when a program changes and systemwide data is shared between functions in the program.
  • Instead of changing the object's source code, the programmer only needs to change some component functions.
  • Easy project expansion.
  • Help programmers can significantly save system resources.
  • OOP is highly secure and reusable

III. Chapter 3 – IDE features

1. Over view of IDE a) Introduce what is IDE -An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently. It increases developer productivity by combining capabilities such as software editing, building, testing, and packaging in an easy-to-use application. Just as writers use text editors and accountants use spreadsheets, software developers use IDEs to make their job easier.

Figure 4: Some of IDE

b) Common features of IDEText editor: Virtually every IDE will have a text editor designed to write and manipulate source code. Some tools may have visual components to drag and drop front-end components, but most have a simple interface highlighting language-specific syntax.

Debugger: Debugging tools assist users in identifying and remedying errors within source code. They often simulate real-world scenarios to test functionality and performance. Programmers and software engineers can usually test the various code segments and identify errors before the application is released.

Figure 6: Debugger in visual studio

Compiler: Compilers are components that translate programming language into a form machines can process, such as binary code. The machine code is analyzed to ensure its accuracy. The compiler then parses and optimizes the code to optimize performance.

Figure 9: Programming language support in visual studio

Integrations and plugins: With the name integrated development environment, it is no surprise that integrations need to be considered when looking at IDEs. Your IDE is your development portal, so incorporating all your other development tools will improve development workflows and productivity. Poor integrations can cause numerous issues and lead to many headaches.

2. An explanation and evaluation of the debugging process in the IDE used and how it helped with development. a) explanation Debugging processDefinition: Debugging is the process of detecting and removing of existing and potential errors (also called as ‘bugs’) in a software code that can cause it to behave unexpectedly or crash. To prevent incorrect operation of a software or system, debugging is used to find and resolve bugs or defects. (the economictimes,2023)

Description: To debug a program, user has to start with a problem, isolate the source code of the problem, and then fix it. A user of a program must know how to fix the problem as knowledge about problem analysis is expected. When the bug is fixed, then the software is ready to use. Debugging tools (called debuggers) are used to identify coding errors at various development stages. They are used to reproduce the conditions in which error has occurred, then examine the program state at that time and locate the cause. Programmers can trace the program execution step-by-step by evaluating the value of variables and stop the execution wherever required to get the value of variables or reset the program variables. Some programming language packages provide a debugger for checking the code for errors while it is being written at run time. (the economictimes,2023)

The debugging process:  Spotting an error  Finding the line of code that cause error

 Fixing the error  Test to check if the error is gone and no new error appear.

b) evaluation of the debugging process in the IDE

  • Step 1: You need to select debug on toolbar and the click on step over

Figure 10: Debug on toolbar -The more faster way is press F10 on the keyboard.

  • Step 2: The function buttons used to control the debug process  Step Over (F10): Run the commands one by one  Step Into (F11): Run the commands one by one and go in to sub-function  Step Out (Shift + F11): Swipe through the current child function to return to the previous function. You can also use it to jump to the next breakpoint.

Figure 11: buttons used to control the debug process

Figure 14: Use IDE to write code

Without using IDE: Imagine you use Microsoft Word to write a program, then you have to save the file as a fileformat according to the language you use. Then run that code again using that language'scompiler application. Just imagining it makes me feel uncomfortable. Can you memorizeall the syntax of the command to confidently program without using IDE? Moreover, it is also very difficult to avoid syntax errors in the process of writing code. And if your program is 1000 lines long, how long will it take you to find the error? Here is an exampleof using Word to write code:

Figure 15: Using word to write code

IV. Chapter 4 – Design and Implementation

1. Flowchart of the application a. FormLogin

Figure 16: FormLogin  Step 1: Input Account  Step 2: Input Password  Step 3: checking Account:  True : Next step  False: Go back to Input Account  Step 4: Checking Password:  True: Next step  False: Go back to Input Password  Step 5: login in to program

b. FormProgram

  • Add Book

Figure 18: delete book

 Step 1: Click delete:  True: Next step  False: Cancel delete  Step 2: delete book

  • Fix book information

Figure 19: Fix book information

 Step 1: Click change information of book:  True: Next step  False: Cancel changging information of book  Step 2: If (index >= 0):  Changging bookcode information  Changging bookname information  Changging author information  Changging type information  Changging prise information

  • Search book
  • Use to store Book and information
  • Book.cs
  • Exit and logout
  • Use to exit and logout program
  • Check control

-check control use to check that the information of books are correct or not

  • Add book
    • Use to add book and information of book
  • Delete book
    • Use to delete book