🎮 Final Project Reflection: What I Learned in JavaScript and Computer Science
Through building a game, I explored key Computer Science, JavaScript, and Object-Oriented Programming concepts. Below is a summary of the terms I learned and how I applied them in my project.
📋 Software Engineering Practices
- Planning Changes: The process of outlining intended code changes before implementation to ensure clarity and avoid bugs.
- Checklists: A list of tasks/features to track progress.
- Burndowns: A visual graph to show remaining work versus time.
- Coding with Comments: Adding notes in code for clarity and future reference.
// Move player to the left function moveLeft() { player.x -= 5; }
- Help Documentation: Written guides explaining what the code does and how to use it.
🔄 Software Development Lifecycle Practices
- Source Control: Using tools like Git to track changes in code over time.
- Forking: Creating your own copy of someone else’s repository.
- Branching: Creating separate environments to work on different features safely.
- Building: The process of converting source code into a usable application.
- Testing and Verification: Making sure the code works as expected.
- Pull Requests: Asking to merge code changes into the main codebase for review.
- Merging/Integrating: Combining code from different branches.
- Deployment: Releasing the final version of the app or game to users.
# Create a new feature branch
git checkout -b feature-score-system
🔁 Retrospective Engineering Practices
- Presentation: Explaining your project and code to an audience.
- Live Reviews: Real-time feedback sessions while demoing the project.
- Demos: Demonstrating completed features.
- Code Reviews: Having others look at your code for quality and accuracy.
- Revising Plans: Updating your roadmap based on progress or feedback.
🧠 Key Coding Concepts
📊 Data Types
- Number: Represents numeric values.
- String: Represents text.
- Boolean: Represents true or false.
- Array: A list-like data structure.
- JSON Object: Key-value pairs for storing complex data.
let score = 0; // Number
let playerName = "Knight"; // String
let isAlive = true; // Boolean
let items = ["sword", "potion"]; // Array
let player = { name: "Knight", health: 100 }; // JSON Object
➕ Operators
- String Operations: Combine text values.
let greeting = "Hello " + playerName;
- Mathematical Operations: Perform arithmetic.
score += 10;
- Boolean Expressions: Evaluate to true or false.
if (score >= 100 && isAlive) { console.log("You win!"); }
🔁 Control Structures
- Iteration: Looping through data.
for (let i = 0; i < items.length; i++) { console.log("Inventory item:", items[i]); }
- Conditions: Code that runs based on true/false logic.
- Nested Conditions: Conditions inside other conditions.
if (player.health > 0) { if (enemy.health <= 0) { console.log("Victory!"); } }
⌨️ Input/Output
- HTML5 Input: Getting user input from web forms.
<input type="text" id="username" placeholder="Enter name" />
- Validation: Making sure the input is correct or complete.
let nameInput = document.getElementById("username").value; if (nameInput.trim() === "") { alert("Please enter your name!"); }
- Key Events & DOM (Document Object Model): Reacting to keyboard input and changing webpage elements.
document.addEventListener("keydown", function(event) { if (event.key === "ArrowUp") { movePlayerUp(); } });
🧱 Classes and Object-Oriented Programming
- Writing Classes: Creating blueprints for objects.
- Creating Methods: Functions inside classes.
- Instantiating Objects: Making new instances of classes.
- Using Objects: Working with created instances.
- Calling Methods: Using object behavior.
- Parameters & Return Values: Passing/receiving data from functions.
class Enemy {
constructor(name, health) {
this.name = name;
this.health = health;
}
takeDamage(amount) {
this.health -= amount;
return this.health;
}
}
let dragon = new Enemy("Dragon", 200);
dragon.takeDamage(50); // Dragon's health is now 150
✅ Coding Practices
- SRP (Single Responsibility Principle): Each function/class should have only one job.
function calculateScore() { // Only calculates score }
- Object Literal: Defining an object using
{}
directly.const weapon = { name: "Sword", damage: 25 };
- Object Instance: An object created from a class using
new
.let boss = new Enemy("Boss", 300);
- FSMs in Game (Finite State Machines): Managing game states (menu, playing, game over). ```js let gameState = “menu”;
function updateState(input) { if (gameState === “menu” && input === “start”) { gameState = “playing”; } else if (gameState === “playing” && input === “die”) { gameState = “gameover”; } }
- **Inheritance**: When a class derives from another to reuse code.
```js
class Character {
constructor(name) {
this.name = name;
}
}
class Hero extends Character {
constructor(name, weapon) {
super(name);
this.weapon = weapon;
}
}
let hero = new Hero("Knight", "Sword");
🏁 Final Thoughts
This project not only helped me apply technical skills but also encouraged creativity, collaboration, and critical thinking. I now have a strong foundation in programming and look forward to building even more advanced games and applications in the future.