Bài này này giới thiệu cho sinh viên các khái niệm cốt lõi của lập trình cùng với phần giới thiệu về các thuật toán và đặc điểm của mô hình lập trình. Trong số các chủ đề trong phần này bao gồm: giới thiệu về thuật toán, lập trình hướng đối tượng và hướng sự kiện, các cân nhắc về bảo mật, môi trường phát triển tích hợp và quy trình gỡ lỗi.
STATE SIMPLE BUSINESS PROBLEMS
INTRODUCTION
Invited to interview for a software development trainee position, I demonstrated problem-solving skills and basic programming abilities.
This report details algorithmic problem-solving in business, illustrating solutions to straightforward issues and outlining software development procedures Fundamental programming constructs (input/output, assignment, loops, conditionals) will be used, with problem analysis, design, and presentation via flowcharts and modules The report will also clarify the proposed software concept.
ALGORITHM
An algorithm is a finite set of rules or instructions for solving a problem, often involving recursive operations, used in calculations and other problem-solving processes.
Algorithms are step-by-step procedures for solving problems or performing computations, acting as precise instructions in hardware or software.
Algorithms are essential procedures in IT, mathematics, and computer science, solving recurring problems and specifying data processing in automated systems.
Figure 2 Characteristics of an algorithm Clear and Unambiguous:
The algorithm should be clear and unambiguous Each of its steps should be clear in all aspects and must lead to only one meaning
If an algorithm says to take inputs, it should be well-defined inputs It may or may not take input Well-Defined Outputs:
The algorithm must clearly define what output will be yielded and it should be well-defined as well It should produce at least 1 output
The algorithm must be finite, i.e it should terminate after a finite time
The algorithm must be simple, generic, and practical, such that it can be executed with the available resources It must not contain some future technology or anything
This algorithm's design prioritizes language independence, ensuring its instructions are universally implementable for consistent output regardless of programming language.
It should terminate after a finite time
It should produce at least one output
It should take zero or more input
It should be deterministic means giving the same output for the same input case
Every step in the algorithm must be effective i.e every step should do some work
There are several types of algorithms available Some important algorithms are:
1 Brute Force Algorithm: It is the simplest approach for a problem A brute force algorithm is the first approach that comes to finding when we see a problem
2 Recursive Algorithm: A recursive algorithm is based on recursion In this case, a problem is broken into several sub-parts and called the same function again and again
3 Backtracking Algorithm: The backtracking algorithm basically builds the solution by searching among all possible solutions Using this algorithm, we keep on building the solution following criteria Whenever a solution fails we trace back to the failure point and build on the next solution and continue this process till we find the solution or all possible solutions are looked after
4 Searching Algorithm: Searching algorithms are the ones that are used for searching elements or groups of elements from a particular data structure They can be of different types based on their approach or the data structure in which the element should be found
5 Sorting Algorithm: Sorting is arranging a group of data in a particular manner according to the requirement The algorithms which help in performing this function are called sorting algorithms Generally sorting algorithms are used to sort groups of data in an increasing or decreasing manner
6 Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm But they contain an index with a key ID In hashing, a key is assigned to specific data
7 Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems, solves a single sub-problem and merges the solutions together to get the final solution It consists of the following three steps:
8 Greedy Algorithm: In this type of algorithm the solution is built part by part The solution of the next part is built based on the immediate benefit of the next part The one solution giving the most benefit will be chosen as the solution for the next part
9 Dynamic Programming Algorithm: This algorithm uses the concept of using the already found solution to avoid repetitive calculation of the same part of the problem It divides the problem into smaller overlapping subproblems and solves them
10.Randomized Algorithm: In the randomized algorithm we use a random number so it gives immediate benefit The random number helps in deciding the expected outcome
Real-life examples that define the use of algorithms:
Sorting personal or office files demonstrates algorithmic thinking: a set of tasks achieving a specific outcome This simple process highlights algorithms' versatility, allowing sorting by criteria like alphabetical order, word count, or date, ultimately simplifying organization.
Traffic signal programming uses real-time traffic data to group similar movements, such as straight-through and right-turn traffic, into coordinated phases.
Smart traffic light algorithms optimize intersection safety by precisely timing traffic phases based on real-time traffic volume, ensuring efficient vehicle flow.
“Algorithm to print all books in library”
Step 1: Start Step 2: Declare new class “Book”
4 String PublicationDate Step 3: Declare new List Step 4: Set all books’ information Step 5: Create first loop to print
1 If true, print info of every single books
2 if false, end the command
Step 6: Create second loop to print the book’s status
1 If true, print the person borrowing book
2 if false, print this book is available
Figure 3 Flowchart of printing all books in library
REPRESENT PROBLEM
Efficient library management is crucial due to the exponential growth of book and client data A well-designed application, featuring book entry (title, author, category, publication date), comprehensive printing functionalities (books and clients), and other advanced features, significantly improves librarian productivity and reduces wasted time Further application details are discussed in Chapter 2.
For Example, there are many algorithms for arranging a sequence of random numbers but still giving the same output
1 The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning
2 Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order This algorithm is not suitable for large data sets as its average and worst-case time complexity is quite high
3 Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands The array is virtually split into a sorted and an unsorted part Values from the unsorted part are picked and placed at the correct position in the sorted part
1 Linear Search is defined as a sequential search algorithm that starts at one end and goes through each element of a list until the desired element is found, otherwise the search continues till the end of the data set It is the easiest searching algorithm
2 Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O (Log n)
ANALYSE PROBLEM AND DESIGN SOLUTIONS
ANALYSE BUSINESS PROBLEM
Continue from previous session as I mentioned in “Represent problem”
This C# program, leveraging procedural programming techniques, addresses library management needs using variables, expressions, loops, and conditional statements to process input and deliver desired outputs.
Input: information of books to enter such as book's title, author, category, and publication date, and the information's client
Output: Includes information on imported books, information's clients with their books borrowed
In the above project, it is necessary to use libraries to meet the need to solve the algorithm That is:
Contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions
Contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non- generic strongly typed collections
In the project above, I used 3 data types including integer, string, double
Here are declared data for the properties that I will use in this program to solve the problem
String Title, Author, Category, PublicationDate
USE-CASE DIAGRAM
FLOWCHART
Step 1: Start Step 2: Declare variable option Step 3: Display menu
1 Show all books in library
6 Close library Step 4: Input a option Step 5: Check option is 6 or not
+ If it is 6, the program will be end
+ if it is not 6, the program goes into the case and then back to display menu
Figure 9 Flowchart of the choices
2 Function of showing all books
Step 1: Start Step 2: Declare new class “Book”
4 String PublicationDate Step 3: Declare new List Step 4: Set all books’ information Step 5: Create first loop to print
1 If true, print info of every single books
2 if false, end the command
Step 6: Create second loop to print the book’s status
1 If true, print the person borrowing book
2 if false, print this book is available
3 Function of importing a new book
Step 2: Enter Title and save it to new variable title
Step 3: Enter Author and save it to new variable author
Step 4: Enter Category and save it to new variable category
Step 5: Enter PublicationDate and save it to new variable publicationDate Step 6: Declare a newBook in class Book
Step 7: Assign all new variables to properties in class Book
Step 8: Add them to a listOfBooks Step 9: End
If choice == 5, end the program
If false, come to the next loop
If true, Enter the title you want to search
The title entered will be compared to the title of all books and print if it true
If false run the next command
If true, Enter the author you want to search
The author entered will be compared to the author of all books and print if it true
If false, run the next command
If true, Enter the category you want to search
The title entered will be compared to the category of all books and print if it true
If false run the next command
Enter the day, month, or year you want to search
Split PublicationDate in ListOfBook and compare it to the thing you entered
Step 1: Enter name and save it to variable name
Step 2: Enter phone number and save it to varible phoneNumber
Step 3: Enter title and save it to variable title
Step 4: Enter dueDate and save it to variable duaDate
Step 5: Create a new varible named newClient to Step 6: Assign
1 name to Name in newClient
2 phoneNumber to PhoneNumber in newClient
3 title to Title in newClient
2 dueDate to DueDate in newClient Step 7: Add newClient to ListOfClients Step 8: End
6 Function of showing all clients
Step 2: Run the loop to print client in ListOfClients
If true, print the information of client
If false, end the program
Step 3: Run the loop to print book in ListOfBooks
If true, come to the next step
If false, come to the step 2 Step 3: Compare client.Title to book.title
If true, print the information of book and DueDate
If false, come the step 3 Step 4: End
DEMONSTRATE AND RUNNING A PROGRAM
CODING STANDARD
Case 1: The function fulfills the request of option 1 That is to display all the information of all books saved in the list such as Title, Author, Category, and PublicationDate
First, the function setInforBook() will be used to save four information of 3 books to the
In this choice, we do not use the function enterNewBook(), so I will mention it in the next choice
Then, the function showListOfBook() will be used to print all the books’ information.
Case 2: The function fulfills the request of option 2 That is to save the information of books just updated
The function enterNewBook() will be used to save the information of books and add them to a list in order to store them.
Case 3: These functions fulfill the request of option 3 That is to search the information of books such as title, author,
The `searchBooks()` function facilitates date-based searches (day, month, year) `showTitle()`, `showAuthor()`, and `showCategory()` then display the corresponding search results.
Searching by day, month, and year (string data types) presents the greatest challenge A separate date-time class was implemented to parse the string, extracting day, month, and year components for comparison with user input.
Case 4: The function fulfills the request of option 4 That is to save the information of client borrowing a book
Because, I cannot pass properties from other class, so I decided to create the similar property in client and book, they are TitleOfBookBorrowed and Title When I print the book,
TitleOfBookBorrowed and Title will be used to print the book with the information of client corresponding.
Case 5: The function fulfills the request of option 5 That is to print all the books and the client borrowing that book
Book printing uses the provided title to match the borrowed book title, ensuring the correct book is printed for the client.
RESULTS OF PROGRAM
III SOLFWARE DEVELOPMENT LIFE CYCLE (SDLC)
Software Development Life Cycle is the application of standard business practices to building software applications It’s typically divided into six to eight steps: Planning, Requirements, Design, Build,
Document, Test, Deploy, Maintain Some project managers will combine, split, or omit steps, depending on the project’s scope These are the core components recommended for all software development projects
Software Development Life Cycle (SDLC) methodologies optimize software development, enabling fine-grained analysis of each process stage for maximized efficiency Increased computing demands necessitate faster, cost-effective software delivery exceeding customer needs; SDLC achieves this by identifying and rectifying inefficiencies.
Figure 15 Seven phases of SDLC
Project planning involves cost estimation (labor and materials), scheduling with milestones, and team/leadership structure definition.
Involve stakeholders—potential customers, developers, subject matter experts, and sales representatives—in the planning process to gather valuable feedback.
Software application planning defines scope and purpose, guiding development and preventing scope creep by setting clear boundaries This ensures efficient team execution and achieves the original project goals.
Defining application requirements is crucial for planning A social media app needs friend-connection features; an inventory program requires a search function.
Requirements also include defining the resources needed to build the project For example, a team might develop software to control a custom manufacturing machine The machine is a requirement in the process
The Design phase models the way a software application will work Some aspects of the design include:
Architecture – Specifies programming language, industry practices, overall design, and use of any templates or boilerplate
User Interface – Defines the ways customers interact with the software, and how the software responds to input
Platforms – Defines the platforms on which the software will run, such as Apple, Android, Windows version, Linux, or even gaming consoles
Programming – Not just the programming language, but including methods of solving problems and performing tasks in the application
Communications – Defines the methods that the application can communicate with other assets, such as a central server or other instances of the application
Security – Defines the measures taken to secure the application, and may include SSL traffic encryption, password protection, and secure storage of user credentials
Prototyping, a crucial part of the iterative software development design phase, creates early, demonstrable versions of an application This allows for stakeholder feedback and cost-effective iterative improvements before costly code changes in later development stages.
Software development projects range in size from solo endeavors to large-scale team efforts Access control and source code management are crucial for all projects, regardless of scale.
Version control systems are crucial for managing application development, tracking code changes, ensuring cross-team compatibility, and meeting project goals.
Software development encompasses diverse tasks beyond coding, including skill enhancement, teamwork, debugging, and managing delays inherent in testing and compilation Strategic SDLC planning mitigates these delays, optimizing developer workflow.
Clear documentation, whether formal (user guides) or informal (code comments), is crucial for software developers, improving understanding and usability even in intuitive applications.
Application documentation encompasses quick start guides, video tutorials for advanced features, and written resources such as user guides, troubleshooting FAQs, providing comprehensive support for users.
Thorough application testing before release is crucial, encompassing automated security checks and simulated production environments for complex deployments Testing verifies individual function correctness and seamless integration between application components, including performance testing to optimize speed This process minimizes bugs, enhances user satisfaction, and improves usage rates.
Application deployment makes the application accessible to users Many companies automate this process, ranging from simple website downloads to mobile app installations However, integrating upgrades into existing systems can be complex and time-consuming.
Post-development, application field use reveals previously undetected bugs, necessitating ongoing operation, maintenance, and potential iterative development cycles.
In addition to bug fixes, models like Iterative development plan additional features in future releases For each new release, a new Development Cycle can be launched.
SOFTWARE DEVELOPMENT LIFE CYCLE (SDLC)
Test number What is being tested? Expected outcome Actual outcome Pass or fail
1 Select choice 1 form the menu Display all books on the screen
The books have been displayed on the screen and asks for the option user want to do pass
2 Select choice 2 form the menu
Require user to enter the information such as title and author, then save that book to the list
The book has been saved into listOfBook pass
3 Select choice 3 form the menu
Display all the choice regarding to the information of book Then, it requires user to enter the name to find and print all the books having the same information
A screen displays a menu; users select an option, print results, and then enter their desired action.
4 Select choice 4 form the menu
Require user to enter the information such as name and phone number, then choose a book to borrow
Finally, save that client’s information
The client has been saved to the listOfClient pass
5 Select choice 5 form the menu
Display all the clients’ information with that book they borrowed
All the information needed have been showed pass
EVALUATION
TEST CASE
Test number What is being tested? Expected outcome Actual outcome Pass or fail
1 Select choice 1 form the menu Display all books on the screen
The books have been displayed on the screen and asks for the option user want to do pass
2 Select choice 2 form the menu
Require user to enter the information such as title and author, then save that book to the list
The book has been saved into listOfBook pass
3 Select choice 3 form the menu
Display all the choice regarding to the information of book Then, it requires user to enter the name to find and print all the books having the same information
A screen displays a menu prompting users to select and print results User input determines subsequent actions.
4 Select choice 4 form the menu
Require user to enter the information such as name and phone number, then choose a book to borrow
Finally, save that client’s information
The client has been saved to the listOfClient pass
5 Select choice 5 form the menu
Display all the clients’ information with that book they borrowed
All the information needed have been showed pass
6 Select choice 6 form the menu End the program Program ended with the message pass
Time such as Day, Month or Year
When user enters day and enters the day he wants to search, all the books with that day will be displayed
All the books with that day have been showed on the screen pass
EVALUATION
With the information I've provided above, the C# software I wrote should be able to address the user's library management issue
This project leveraged the popular C# language to develop functional library management software Despite encountering minor development challenges, the final product successfully met user requirements.
Additionally, I covered SDLC and algorithms in this project; both of these ideas are crucial to the learning process.