








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Subject Programming Year 2025 Course Computing BTEC Level 3
Typology: Study Guides, Projects, Research
1 / 14
This page cannot be seen from the preview
Don't miss anything!
size = input("Enter Size: ") colour = input("Enter Colour: ") factory = input("Enter Factory: ") self.inventory_list.append({ "ID": inventory_id, "Type": item_type, "Name": name, "Size": size, "Colour": colour, "Factory": factory }) print(f"\nInventory {name} registered successfully with ID: {inventory_id}\n")
3. Sorting The sorting algorithm helps organize the inventory in alphabetical order. The show_sorted_inventory code does this by sorting the items by name. This makes it easier to find specific items efficiently, especially when there’s a large amount of inventory. The sorted list is neat and easy to browse through. Example: def show_sorted_inventory(self): if not self.inventory_list: print("\nNo inventory to display.") return sorted_inventory = sorted(self.inventory_list, key=lambda x: x['Name']) print("\n--- Inventory List (Sorted by Name) ---") for item in sorted_inventory: print(f"ID: {item['ID']}, Name: {item['Name']}") 4. Updating the Inventory The change algorithm allows users to update the inventory. This includes changing the position of an item. The change_inventory_position code allows users to select a new position for an item. If the user enters an identifier that does not exist, the system displays an error message. This feature helps keep the inventory up to date and accurate. If def change_inventory_position(self): inventory_id = input("\nEnter Inventory ID to change position: ") for item in self.inventory_list: if item['ID'] == inventory_id: print("\nAvailable Positions:") for pos in self.positions: print(f"{pos['ID']} - {pos['name']}") new_position = input("Enter new Position ID: ") item['Position_ID'] = new_position print("Position updated successfully!\n") return print("Inventory ID not found!")
5. Managing Data The data handling algorithm is the feature of the application where user can load and save data from JSON files. The data inputted are all stored in a JSON file. In order to use the code, the load_json_file code scans the JSON file to check if it exists and uses its content to the program. If the file is not found, the system reports this to the user without crashing the program. This keeps the system stable and easy to use, even when file issues occur. The example below is one of the example of this technique with the positions feature. Example: def show_positions(self): if not self.positions: print("\nNo positions available.") return print("\n--- Available Positions ---") for pos in self.positions: print(f"ID: {pos['ID']}, Name: {pos['name']}") B. THE STEPS TAKEN TO CREATE THE INVENTORY MANAGEMENT APPLICATION 1. Key Feature Planning Firstly, the main features needed to be laid out. The final main features consist of user login, adding new inventory items, modifying items, and sorting items. Defining these features clearly is essential because it helps create a plan for application development, making the following steps to be executed easier. 2. Choosing How to Store Data The next step is to decide how to store important information, such as user accounts, inventory details, and supplier data. JSON files were chosen to be used because they use simple syntax and does not special tags. This makes storing data easier and faster. Additionally, since JSON allows the code to be placed in a separate, it is easier to store and load the data, while the application is running. For instance, the JSON file for user stores the information of the username and password in a separate JSON file, but it still affects the main program. This action is executed with a specific which will be explained further with the next step. 3. Creating the Codes To keep the code neat and reusable, the InventorySystem class is used. This class handles login, adding inventory, and managing data features. By organizing code into definitions for specific tasks, it
However, there were unexpected challenges faced during the process. Firstly, figuring out the proper algorithm needed to excecute a task was difficult. A feature that was one of the most hassle was the creating the User ID, making sure that the users can have its own ID. Furthermore, minor mistakes such as accidently writing the wrong figures were frequently made which caused a whole part of the program to not run properly. D. EVALUATION ON THE IMPLEMENTATION AND RELATIONSHIP BETWEEN THE ALGORITHM AND THE CODE FOR THE INVENTORY MANAGEMENT APPLICATION After planning out the task of the algorithms, writing the lines of codes in order to for the program to function was the next step. Each method in the InventorySystem class corresponds to a specific step in the algorithm. The algorithm provides a clear framework, while the code translates it into a functional application. This corellation between the algorithm and the code is vital to achieving a well-designed and efficient inventory management system.
Procedural programming is a set of instructions to create a function. Functions essentially mean to complete a task to get from a point to another point. This means that lines of codes are written to step through these procedures in order to reach the final goal of a task. Example: python Copy Edit def show_sorted_inventory(self): if not self.inventory_list: print("\nNo inventory to display.") return sorted_inventory = sorted(self.inventory_list, key=lambda x: x['Name']) print("\n--- Inventory List (Sorted by Name) ---") for item in sorted_inventory: print(f"ID: {item['ID']}, Name: {item['Name']}") The example above is from the inventory Management Application that shows how the lines of codes from functions are written such as register_inventory, show_inventory_details, and change_inventory_position. Each function performs a specific task which is part of a larger sequence of activities. Another example is the show_sorted_inventory function which checks if the inventory list is not empty before proceeding to sort the list items alphabetically by name and then displaying them. The manner in which tasks are separated and organized into functions is a characteristic of procedural programming, which segments a problem into
logically consecutive steps. This is needed for accomplishing tasks where data is used to being processed by a function. However, the lack of proper encapsulation, for example self.register_inventory and self.inventory_list, suggests that there is no suitable binding between the data which makes it very complicated as the project grows. While a procedural approach is advantageous for comprehension and construction of a “small” system, it is ineffective and unsafe in large scale projects that require complex and valuable data. OBJECT-ORIENTED PROGRAMMING (OOP) OOP organizes programs into objects that combines functions and variables into a group. OOP has many characteristics including encapsulation which groups related variables and functions into one unit. Next, inheritance allows classes with common properties and behaviours to reuse the same code. This prevents redundant codes. Next OOP allows codes to be simpler while achieving the same results as the complex code. This is called abstraction. Moving on, polymorphism allows the same code to be used in different ways. Example: class InventorySystem: def init(self, users_file, positions_file, suppliers_file): self.users = self.load_json_file(users_file) self.positions = self.load_json_file(positions_file) self.suppliers = self.load_json_file(suppliers_file) self.inventory_list = [] The code effectively applies object-oriented programming by combining both data and behavior within the InventorySystem class. The attributes self.inventory_list, self.users, and self.positions hold data, while the methods register_inventory and generate_unique_id work with this information. The modular approach promotes better organization of the code as well as its reuse, thus improving system manageability. For instance, load_json_file could be used in different places in the class to fetch data from JSON files, which eliminates redundancy. Nonetheless, the implementation does not contain sophisticated OOP concepts such as inheritance and polymorphism, which would make it more scalable. For example, defining sub-classes for specific types of inventories, like VehicleInventory or ClothingInventory, would give more specific behavior while allowing reuse. In addition, encapsulation is not properly practiced since some attributes, like inventory_list, are public, which can lead to unwanted changes. By following more OOP principles, the code could provide better abstraction and flexibility. EVENT-DRIVEN PROGRAMMING Event-Driven Programming (EDP) is where the flow of the program is controlled by events. Event in this context acts as a trigger to execute a specific action. It is done by sending a signal to a code to start. The signals can vary from many factors such as the user clicking a mouse will cause an action to happen. Example: def main_menu(self): while True: print("\n--- Main Menu ---") print("1. Register New Inventory")
3. Event-Driven Programming In event-driven programming, application logic is executed in response to events, resulting in a highly interactive user experience. Events can be user actions, system notifications, or external stimuli, and these events trigger specific responses in the application. This architecture allows for efficient handling of multiple events simultaneously, and also allows developers to create highly responsive applications. However, event-driven programming can be challenging to debug due to its asynchronous nature. Because events occur independently and potentially at different times, it becomes difficult to trace the flow of execution through the application logic. Additionally, there is often a high level of complexity when working with multiple events in an event-driven application. Developers must carefully consider the flow of events and deal with potential competing conditions that can arise from asynchronous execution.
Integrated Development Environment (IDE) is a software that consists of various coding tools to assist programmers in writing their codes more efficiently. IDEs generally consist a debugger, a compiler, automation tools, and code editor. These features allow for developing the inventory management application faster and more efficient. The IDE used in creating the inventory management application is Visual Studio Code (VS Code). VS Code has code completion which can detect errors, automatic syntax completion, and highlighting necessary lines of codes. This allows programmers to focus less on fixing errors and more to the coding. Other than that, VS Code supports a variety of programming languages including C++, C#, CSS, Dart, Dockerfile, F#, Go, HTML, Java, JavaScript, JSON, Julia, Less, Markdown, PHP, PowerShell, Python, R, Ruby, Rust, SCSS, T-SQL, and TypeScript. This inclusivity of languages allows projects to run on different programming languages. For instance, the inventory management application works on both Python and JSON files. Additionally, the design of Visual Studio Code is neat, organized, and beginner-friendly. The layout makes it simple to navigate and code. Not only is it simple, it has advanced features that is inclusive for experienced professionals so they are able to work effectively as well. Overall, the versatility of Visual Studio Code is effective and useful for projects like inventory management applications.
As mentioned earlier, VS Code has a feature to assist in coding syntaxes. It is called the Code Intelligence (IntelliSense) which essentially assists in coding through contextual suggestions, highlights code errors, and provides auto completions. VS Code provides IntelliSense for CSS, JavaScript, Java, JSON, SASS, LESS, HTML, and TypeScript. Other languages can also be supported through extensions. This feature reduced manual errors and sped up the development process while working on algorithms like generate_unique_id or register_inventory.
Figure 1 IntelliSense Figure 2 Terminal Port As for the integrated debugging tool in Visual Studio Code, it is flexible as it accommodates various languages through extensions in the Extensions Market Place (Figure 3). Extensions for languages that does not have built in debuggers are provided making it easier for multiple languages used in the application such as Python and JSON to be used. Moving on, VS Code debugger is quick and smooth even with multiple plugins downloaded. The platform is quick to the debug the code, almost real time, allowing the testing process of the application fast. Additionally, the terminal of VS Code seen in Figure 2 has an organized and simple layout with complete features such as breakpoints. Figure 3 Extension Market Place VS Code’s Git Integration is another feature that makes tracking and managing code changes simpler. While improving algorithms, users were able to add checkpoints for certain versions which helped in rolling back changes if they had unwanted changes. In conclusion, VS Code is an IDE that is Lightweight and Fast. The responsive interface and fast load times of the software ensured that there was no lag when testing and refining algorithms. This seamless experience has made it easier for to work with the software. These features proved that VS Code is an effective primary tool for developing the inventory management application.
runtime errors and exceptions in detail, aiding the developer with relevant information to diagnose issues effectively. With effective debugging procedures in place, an application becomes easier to secure and robust. Edge cases, as well as invalid inputs, are properly handled in order to minimize the chances of a crash or other unexpected errors. Debugging allows the application to reveal vulnerabilities such as unauthorized access attempts – and it gives the opportunity to implement security measures. This attention to detail in foreseeing risks and troubleshooting is what makes the application secure, reliable, and operable in a variety of conditions. B. EXPLAIN THE CODING STANDARDS THAT YOU USED IN YOUR CODE AND EVALUATE WHY CODING STANDARDS ARE VERY IMPORTANT The project strives to maintain order and coherence by following strict coding standards. Functions and variables are made easy to identify as they are renamed to more illustrative names such as self.users and inventory_id. In addition, modular coding with functions such as register_inventory and load_json_file increase reusability while simplifying the debugging and testing processes. These coding standards help preserve the codebase’s well-structured state. In general, coding standards put in place provisions on how a project should be done which helps with its understanding and maintainability. With proper naming conventions such as self.users or inventory_id, it is easy to understand what each variable or function does. With these measures in place, the project can be understood even by a newcomer. The greater focus for developers is understanding the project, which in turn leads to efficient maintenance or fixing of all future issues. In team projects, coding standards helps with collaboration greatly. When everyone in a team abides by the standard controls for naming or structuring the code, there are minimal errors and ambiguities. These patterns allow team members to collaborate much better and mitigate any issues of contention when it comes to merging their pieces of work.
Finally, coding standards aids in ensuring the project is scalable. The use of constraining mechanisms such as writeable modular functions like load_json_file allows newer features or modifications to outdated ones to be added with minimal features. Ensuring standards and good organization of the code guarantees that the project easily adapts and grows over time to meet development needs.