{"assignment":{"_schema_version":2,"course_id":37,"date_created":"2025-08-17T17:30:52.685621+00:00","date_modified":"2025-09-09T21:50:04.428823+00:00","extra_instructor_files":"","extra_starting_files":"","forked_id":null,"forked_version":null,"hidden":false,"id":2463,"instructions":"## Large Programs\n\n-   1-10 Lines: Simple programs with a few lines of code.\n-   10-100 Lines: Medium programs that may have multiple functions and some complexity.\n-   100-1000 Lines: Large programs that need careful management and structure.\n-   1000+ Lines: Very large programs that require advanced techniques for organization and maintenance.\n\nSo far, our programs have been relatively small and simple.\nOften, we have you only define a single function.\nBut the reality is that most interesting programs are much larger and more complex.\n\nLines of code is not a good measure of program complexity, but it is still a relevant factor to consider.\nHumans can only keep so many things in their mind at once.\nAs we develop larger programs, we need to find ways to manage that complexity.\nFunctions will become more important as a way to break down and organize our code.\n\nOur goal by the end of this curriculum is to be comfortable with programs that are hundreds of lines long. In the future, you will learn more advanced techniques for dealing with thousands and even millions of lines of code.\nHowever, ultimately there is no substitute for time and experience when it comes to learning how to manage complexity in large codebases.\nSo in this unit, we will get some experience working with larger codebases and learn strategies for managing complexity.\n\n## Word Guessing Game\n\n-   <https://drafter-edu.github.io/examples/guess_word/>\n\nAs a running example, we are going to read and analyze the code for a word guessing game.\nBefore you do anything else, take a few minutes to click the link shown and try the game.\n\n**Seriously, try running the program.**\n\nThe rules of this game are simple. You are shown 4 blanks and need to figure out what the word is. You can guess one letter at a time, and the game will tell you if your letter is in the word or not. You cannot guess the same letter twice, and you can only guess lowercase letters (no digits or symbols). If you guess all the letters in the word before running out of turns, you win!\nWhether you win or lose, you will progress to the next level. At the end, you will see your score.\n\n## Should I Run this Program?\n\n-   Can you trust the origin of the code?\n-   Do you have access to the source code?\n-   Can you understand what the code is doing?\n\nIn general, running a program is a good first step to seeing what it does.\nHowever, it's not always necessary or possible to run a program in order to understand it.\n\nSometimes, you can gain insights by simply reading the code and thinking about what it does. This is especially true for smaller programs or for specific functions within a larger program. In these cases, you can often understand the program's behavior without actually running it.\n\nAnother important consideration is whether you can trust the code. If you're working with code from an unknown source, it's a good idea to read through it carefully and make sure you understand what it does before running it. This can help you avoid potential security risks or unintended consequences.\nYou are always responsible for code that you choose to execute, regardless of the source.\nIf the code deletes your entire hard drive, you can be upset that someone tricked you into running malicious code, but that doesn't change that all your data is gone (hope you kept backups!).\n\nIf the code is safely sandboxed (i.e., has limited access to the system and cannot harm it), then it may be safer to run it without extensive review.\nRunning code in a browser is usually safe, since modern browsers have built-in security features that help protect your system from malicious code.\nBlockPy is unable to execute code that can do serious harm to your computer, for instance.\n\n## Understanding the Purpose\n\n-   What problem is this program trying to solve?\n-   What is the overall goal of the program?\n-   What are the main features or functionalities?\n-   Who is the intended user or audience?\n-   What are the inputs and outputs?\n-   What are the important parts of the state?\n-   Are there any errors or issues with the program?\n\nAs you start to analyze a program, you need to understand its purpose. What problem is it trying to solve? What is the goal of the program? What are the main features and functionalities? Who is the intended user or audience? What are the inputs and outputs? This understanding will help you make sense of the code and how it works.\n\nThink critically to yourself about the Word Guessing Game program, and try to answer these questions. It is okay if you are struggling to do so.\nFirst, not every question is directly applicable to every program.\nFor example, games are not usually thought of as solving a specific problem, but rather as providing entertainment or a challenge (although Computer Scientists do have ways to describe the goals and mechanics of games in terms of solving a problem).\n\nYou might also struggle to understand the inputs and outputs of the program, as they may not be immediately obvious from the user experience.\nConsider what the user sees when they interact with the program. What information do they need to provide? What feedback do they receive? This can help you identify the inputs and outputs more clearly.\n\n## Analyzing the Guessing Game\n\n-   Goal: Have the user guess a hidden word by suggesting letters within a certain number of guesses.\n-   Main Features:\n    -   User can input letters to guess the word.\n    -   The program provides feedback on whether the guessed letter is in the word.\n    -   The user has a limited number of incorrect guesses before losing.\n-   Intended User: Anyone who enjoys word games or wants to improve their vocabulary.\n\nThe Word Guessing Game is designed to be engaging and educational, helping users expand their vocabulary while having fun.\nWe have identified a number of key components that contribute to the game's functionality and user experience, like inputting the letters, providing feedback, and keeping track of the number of incorrect guesses and the score.\nThese questions are usually straightforward, but if you cannot answer them then you do not understand the game.\n\n## Inputs, Outputs, and State\n\n-   Inputs: User's letter guesses and their choices at each menu. Also the list of secret words.\n-   Outputs: Feedback on guessed letters and the current state of the word being guessed.\n-   State: The secret word, the revealed letters, the letters that have been guessed, current score, the current level\n\nA much more complicated activity is figuring out the inputs, outputs, and state of the program.\nHowever, since programs are fundamentally about transforming inputs to outputs, it is critical to figure out what the inputs and outputs look like.\nThe same goes for the state: we need to understand what information is being stored and how it changes over time.\n\nJust because we identified the important parts of the state doesn't mean we fully understand how they work together, or that they will all be in a `State` object.\nAnd of course, as we start developing an application, we often realize that we need to refactor our code and reorganize our state management to better suit our needs.\nIt's a great idea to try and predict what state will look like, but you don't need to fill committed to whatever you initially come up with.\n\nIn this game, we know that the players have to be able to enter their letters, and will also need to click buttons to submit their guesses. There also has to be a list of words somewhere.\nAs the game progresses, the player is shown screens of information about the guessed letters, the current state of the word, and their progress in the game.\nThis feedback correlates strongly with the current state, allowing the player to make informed decisions about their next guesses.\nSome of the state might not need to be displayed to the player at all times, such as their current overall score or the actual secret word.\n\n## Errors and Issues\n\n-   Are there any errors or issues with the program?\n\nAnother thing to consider as you start looking at the code is whether there are any issues or obvious errors.\nIn this case, we have shown you a working game. But we will soon be looking at an implementation of the game that has some bugs and issues for us to find and fix.\nIt is still worth your time to try inputs and clicks that might break the game.\nYour goal, as we will see, is adversarial - you want to find ways to make the game fail.\nComputer Scientists must be very strict with their own code, to make sure that it works.\nThere is nothing shameful about finding and fixing bugs.\nIndeed, such practices are essential for maintaining code quality and ensuring a smooth user experience, and you should celebrate every time you find and fix a bug.\n\nSome aspects of the user interface might be considered to have issues.\nFor instance, the level is initially displayed as \"Level -1\", which is confusing for players, and then the actual first level is \"Level 0\".\nAlso, the debug information is being displayed at the bottom of the screen, which might be distracting for players.\nThese are issues that could be addressed to improve the user experience, but might not be considered errors in the code itself.\nThese issues are absolutely critically important, and addressing them is an entire field of Computer Science called Human Computer Interaction (in particular, the study of how people interact with computers and how to design user interfaces that are effective and enjoyable to use).\nFor now, we will set aside how aesthetically pleasing the user experience is, and focus on the functional aspects of the game.\n\n## Summary\n\n-   When you first encounter a program, decide if you can safely run the program to try it out.\n    -   Can you trust the origin of the code?\n    -   Do you have access to the source code?\n    -   Can you understand what the code is doing?\n-   As you try a program, critically think about the following questions:\n    -   What problem is this program trying to solve?\n    -   What is the overall goal of the program?\n    -   What are the main features or functionalities?\n    -   Who is the intended user or audience?\n    -   What are the inputs and outputs?\n    -   What are the important parts of the state?\n    -   Are there any errors or issues with the program?\n","ip_ranges":"","name":"5A1) Large Programs","on_change":"","on_eval":"","on_run":"","owner_id":1,"owner_id__email":"acbart@udel.edu","points":1,"public":true,"reviewed":false,"sample_submissions":[],"settings":"{\n  \"small_layout\": true,\n  \"header\": \"Large Programs\"\n}","starting_code":"","subordinate":false,"tags":[],"type":"reading","url":"bakery_projects_large_program_read","version":4},"ip":"216.73.216.157","submission":{"_schema_version":3,"assignment_id":2463,"assignment_version":4,"attempts":0,"code":"","correct":false,"course_id":37,"date_created":"2026-05-20T12:38:52.145663+00:00","date_due":"","date_graded":"","date_locked":"","date_modified":"2026-05-20T12:38:52.145663+00:00","date_started":"","date_submitted":"","endpoint":"","extra_files":"","feedback":"","grading_status":"NotReady","id":2036726,"score":0.0,"submission_status":"Started","time_limit":"","url":"submission_url-b3a67854-9fca-4eb6-ae55-640670f4d113","user_id":2044658,"user_id__email":"","version":0},"success":true}
