A programming assignment can be much more intimidating than it seems to be.
When you open the program and read the prompt for the assignment, a flood of text inundates you with terminology that you may not understand. Furthermore, when you open your code editor of choice, you are faced with a blank screen and cursor that seems to mock you at this moment for having no idea what to type in your editor to complete the assignment.
All of this is normal when you are just beginning to build your foundation in computer science.
The most common trap that students fall into is that of too quickly starting to code. Many will skim the brief once to get an idea of the task, but then jump right into their code. When errors begin to appear, they tend to randomly begin changing code to fix the errors without understanding the reason for their emergence in the first place.
The better strategy is to slow down initially when faced with any project, regardless of the language (Java, C++, SQL, etc.) or task (projects, coursework, queries, tasks). Each project follows the same general framework for success.
Step 1: Start With the Assignment Brief, Not the Code Editor
Read the brief from start to finish. Read it once to get an overview of the task, then read it a second time to highlight the important elements.
Consider the following typical assignment guide brief:
Write a program that takes exam marks for five subjects, calculates the average mark for the student, and displays the overall grade that the student received.
A beginner coder might begin to write statements to take input from the user immediately. But before you start to write code, write down the operational requirements of the program:
- What are the boundaries for each grade?
- What should be done with out-of-bounds numbers?
- Are there any requirements with the code?
- Is there a specific way that the code should be documented?
Even if a program compiles and returns 0 errors, it can still fail the requirements if it does not follow the instructions in the assignment.
Step 2: Breaking the Problem into Four Basic Modules
A great way to approach a problem is to break it down into four basic components:
- Input (Data Acquisition): Get five numeric scores from the user or file.
- Processing (Computation): Calculate the average of the five scores.
- Rules (Business Logic): Determine the letter grade associated with the average score.
- Output (Presentation): Print the average and its associated grade.
Applying This Framework Across Different Domains
- Database management (SQL) systems take the input of a search query from a user, process that query to retrieve records based on foreign keys, and rule-based logic determines which records satisfy the query and are output on the screen.
- In the world of e-commerce, the system takes the item that the user wants to purchase and the quantity of those items as an input. Processing that input calculates the user’s order subtotal. Additionally, rules determine the discounts for purchases of specific quantities of items and output the total order amount with any applicable discount tiers.
Step 3: Identify Key Imperative Keywords
Another way to determine the type of programming constructs that will be required for your programs is to analyze the actual programming brief itself. Look for the keywords that indicate which types of programming constructs will be necessary:
- Keywords like “calculate” or “compute” indicate that you will need to use your program to perform mathematical operations and define variables.
- Keywords like “display” or “render” indicate that you will need to use your program to define statements that will output information from your program or to define GUI components of your program.
- Keywords like “store” or “collect” indicate that you will need to use data structures within your program.
- Keywords like “sort” or “search” indicate that you will need to use algorithms within your program or objects like built-in search utilities.
- Keywords like “validate” indicate that you will need to use conditional statements (like if/else statements) within your program.
- Keywords like “repeat” or “for each” indicate that you will need to use loops within your program.
For instance, a programming brief of “read 10 numbers and find the maximum value” indicates that the program will need to incorporate components that read from the user, a data structure (or loop) to store the 10 numbers, and a conditional statement to determine which number is the maximum of the group of 10 numbers.
Step 4: Check Language and Department Restrictions
Check the constraints of the environment you are working in before deciding on your implementation.
Your instructor may place specific restrictions on the types of implementations you may use. For instance, your instructor may say:
“Implement the array sorting routine. Do not use the libraries for sorting that are included with the system.”
Using a library like Arrays.sort() in Java or std::sort in C++ will result in the correct output for your program, but you will be deducted points for using it.
Ensure that your instructor does not require you to use specific implementations, such as:
- Using a linked list instead of a dynamic array
- Explicit recursion instead of iterative loops
- Object-Oriented design patterns like classes and interfaces
- Specific database schemas or query formats
Step 5: Break Large Projects Into Sequential Milestones
Trying to build a complex project with multiple features at once will only result in developers getting frustrated trying to debug their projects. Instead, break the project into multiple modules that contain the necessary functions to accomplish the project’s goal, and build each of those modules one at a time.
Consider a project that creates a system with six main features: adding a student, displaying all students, searching for students, updating students, deleting students, and exporting student data.
Incremental Development Steps
- Construct the data container and determine how to add data to it.
- Build the display logic to print that record to the console.
- Add the search capability to retrieve a specific record.
- Implement update and delete routines.
By isolating features, you can immediately see which newly added module is causing the error messages during runtime.
Step 6: Write Language-Agnostic Pseudocode
Pseudocode allows you to write your algorithms without having to worry about syntax and the specific language you will eventually code in.
Here is an example of language-agnostic pseudocode for finding the largest number in a list:
Plaintext
SET max_value = first element in list
FOR EACH number IN list
IF number > max_value THEN
SET max_value = number
END IF
END FOR
PRINT max_value
END FindMaximum
You can see how the Java, C++, C#, and JavaScript languages could easily be used to implement this algorithm. Solving the logic of the problem first makes for an easier translation into the target languages.
Sign in to leave a comment.