If you're a Launch School student already familiar with the PEDAC process, feel free to skip this lesson. If you're new to PEDAC, don't worry – we'll explain everything.
PEDAC is a structured approach to solving programming problems. It helps you avoid common pitfalls that can arise when coding without a clear plan. Here's what the acronym stands for:
First, you need to understand the problem. This involves identifying the problem's inputs and desired outputs, and understanding how to get from the input to the output. The problem statement may also contain instructions for handling edge cases or definitions to clarify the task.
Next, examine all provided examples or test cases. Ensure they align with your understanding of the problem. They can reveal edge cases or gaps in your understanding.
Then, identify data structures you might use in your solution. At this point in your learning, this would typically be a list, dictionary, or set.
After that, outline your algorithm. This should provide step-by-step instructions in plain English for solving the problem. Aim for a level of detail that someone with no coding knowledge could understand, and strive for language-agnosticism so the solution can be implemented in any language.
Finally, translate your well-defined algorithm into working code.
You might wonder if it's faster to skip this structured approach and code directly. It's a fair question, and the answer depends on your experience level and the problem's complexity.
For most problems, taking the time to apply PEDAC can save you time and help you solve complex problems more efficiently. For simple tasks, a detailed algorithm might be unnecessary. But for challenging problems, PEDAC becomes essential for finding a solution within a reasonable timeframe.
For beginners, a structured approach like PEDAC addresses the "Two-Layer Problem." Learning to program requires two distinct skills: logical problem-solving and mastering programming language syntax. These skills are different, and trying to learn both simultaneously can be overwhelming. PEDAC allows you to separate these processes, focusing on understanding and solving the problem before translating the solution into code. This not only makes the process less cumbersome, but also saves time.
In this book, we'll prioritize the "Understand the Problem" and "Data Structure/Algorithm" steps of PEDAC. While we'll touch on "Examples and Test Cases," our main goal is to help you grasp the problem and develop a suitable algorithm. This is often where students struggle most, even if they have strong coding skills.
We cover the PEDAC process in much more depth in our Core Curriculum.
In the next assignment, we'll tackle the "Palindrome Substrings" problem using the PEDAC approach.