Skip to content

Commit bce98e5

Browse files
committed
Initial commit
0 parents  commit bce98e5

File tree

233 files changed

+10311
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+10311
-0
lines changed

.gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
5+
# IDE
6+
.vscode/
7+
.idea/
8+
*.iml
9+
*.ipr
10+
*.iws
11+
/out/
12+
/oo-design.iml
13+
14+
# Java
15+
*.class
16+
*.jar
17+
*.war
18+
*.ear
19+
*.zip
20+
*.tar.gz
21+
*.rar
22+
hs_err_pid*
23+
replay_pid*
24+
25+
!gradle/wrapper/gradle-wrapper.jar
26+
!gradle/wrapper/gradle-wrapper.properties
27+
28+
# OS
29+
.DS_Store
30+
.DS_Store?
31+
._*
32+
.Spotlight-V100
33+
.Trashes
34+
ehthumbs.db
35+
Thumbs.db
36+
37+
# Logs
38+
*.log
39+
40+
# Temporary files
41+
*.tmp
42+
*.temp
43+
*~
44+
45+
# Maven (if any projects use it)
46+
target/
47+
pom.xml.tag
48+
pom.xml.releaseBackup
49+
pom.xml.versionsBackup
50+
pom.xml.next
51+
release.properties
52+
dependency-reduced-pom.xml
53+
buildNumber.properties
54+
.mvn/timing.properties
55+
.mvn/wrapper/maven-wrapper.jar
56+
57+
# JUnit
58+
TEST-*.xml
59+
60+
# Virtual machine crash logs
61+
hs_err_pid*
62+
replay_pid*

MIGRATION_GUIDE.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Migration Guide: Manual Build → Modern Gradle
2+
3+
Complete guide for migrating Object-Oriented Design projects from manual builds to modern Gradle with VS Code integration.
4+
5+
## Key Improvements
6+
7+
**In-place migration** - No separate directories
8+
**Preserve original structure** - Keep existing files as reference
9+
**Simple directory mapping** - Direct project directory mapping
10+
**Clean multi-project setup** - All projects in one workspace
11+
12+
## Migration Process
13+
14+
### Step 1: Set Up Multi-Project Structure
15+
16+
Create root-level Gradle files:
17+
18+
**settings.gradle**
19+
```gradle
20+
rootProject.name = 'oo-design'
21+
22+
include 'vendingmachine'
23+
include 'atm'
24+
// ... other projects
25+
26+
// Map to actual directories
27+
project(':vendingmachine').projectDir = file('Vending_Machine_Code')
28+
project(':atm').projectDir = file('ATM_Code')
29+
// ... other mappings
30+
```
31+
32+
**build.gradle** (root)
33+
```gradle
34+
subprojects {
35+
apply plugin: 'java'
36+
37+
repositories {
38+
mavenCentral()
39+
}
40+
41+
dependencies {
42+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0'
43+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
44+
}
45+
46+
java {
47+
toolchain { languageVersion = JavaLanguageVersion.of(17) }
48+
sourceCompatibility = JavaVersion.VERSION_17
49+
targetCompatibility = JavaVersion.VERSION_17
50+
}
51+
52+
tasks.named('test') { useJUnitPlatform() }
53+
}
54+
```
55+
56+
### Step 2: Migrate Individual Project
57+
58+
For each project directory (e.g., `Vending_Machine_Code/`):
59+
60+
1. **Update the original README**:
61+
```bash
62+
cd Vending_Machine_Code/vendingmachine
63+
# Update existing README.md to include:
64+
# - Gradle build instructions
65+
# - All valuable original content (features, classes, test coverage)
66+
# - Remove references to manual builds (readers have no context)
67+
68+
# All source files stay exactly as-is
69+
```
70+
71+
2. **Create project build.gradle with custom source paths**:
72+
```gradle
73+
plugins {
74+
id 'java'
75+
}
76+
77+
// Configure source directories to use original paths
78+
sourceSets {
79+
main {
80+
java {
81+
srcDir 'vendingmachine'
82+
exclude '**/*Test.java' // Exclude test files from main
83+
}
84+
}
85+
test {
86+
java {
87+
srcDir 'vendingmachine'
88+
include '**/*Test.java' // Include only test files
89+
}
90+
}
91+
}
92+
```
93+
94+
95+
### Step 3: Test Migration
96+
97+
```bash
98+
# From root directory
99+
./gradlew :vendingmachine:build
100+
./gradlew :vendingmachine:test
101+
```
102+
103+
### Step 4: Verify Multi-Project Setup
104+
105+
```bash
106+
./gradlew projects # Should show all projects
107+
./gradlew buildAll # Build everything
108+
```
109+
110+
## Directory Structure After Migration
111+
112+
```
113+
oo-design/
114+
├── build.gradle # Root build configuration
115+
├── settings.gradle # Multi-project setup
116+
├── gradlew, gradlew.bat # Gradle wrapper
117+
├── gradle/ # Wrapper files
118+
├── .vscode/ # VS Code configuration
119+
120+
├── Vending_Machine_Code/ # Original directory (migrated)
121+
│ ├── build.gradle # Project-specific config (only new file!)
122+
│ └── vendingmachine/ # Original directory completely unchanged
123+
│ ├── README.md # Updated with Gradle instructions
124+
│ ├── *.java # All source and test files
125+
│ └── combined.plantuml # UML diagrams in original location
126+
127+
├── ATM_Code/ # Next project to migrate
128+
├── Blackjack_Code/ # Next project to migrate
129+
└── ...
130+
```
131+
132+
## Benefits of In-Place Migration
133+
134+
### Before
135+
```bash
136+
# Each project had separate build process
137+
cd Vending_Machine_Code/vendingmachine
138+
mkdir lib
139+
curl -L <url> -o lib/junit.jar
140+
javac -cp lib/junit.jar *.java
141+
java -jar lib/junit-platform.jar --scan-classpath
142+
```
143+
144+
### After
145+
```bash
146+
# From root directory
147+
./gradlew :vendingmachine:test
148+
./gradlew :atm:test
149+
./gradlew :blackjack:test
150+
```
151+
152+
## VS Code Integration
153+
154+
Opening the root folder provides:
155+
- **All projects in one workspace**
156+
- **Gradle tasks for each project**
157+
- **Unified debugging and testing**
158+
- **No context switching between projects**
159+
160+
## Migration Checklist
161+
162+
For each project:
163+
164+
- [ ] Create project `build.gradle` with custom source paths
165+
- [ ] Update original README with Gradle instructions
166+
- [ ] Test: `./gradlew :project:build test`
167+
- [ ] Update root README with project status
168+
- [ ] Configure test output visibility (optional but recommended):
169+
```gradle
170+
tasks.named('test') {
171+
useJUnitPlatform()
172+
testLogging {
173+
showStandardStreams = true
174+
}
175+
outputs.upToDateWhen { false } // Always run tests, never cache
176+
}
177+
```
178+
179+
## Key Advantages
180+
181+
1. **Preserves History**: Original files remain intact
182+
2. **No Confusion**: Single source of truth per project
183+
3. **Easy Navigation**: All projects accessible from root
184+
4. **Professional Structure**: Industry-standard Gradle layout
185+
5. **IDE Friendly**: Full VS Code integration
186+
6. **Reader Friendly**: One command to run any project
187+
188+
This approach transforms the repository into a professional, cohesive development environment while preserving the original educational structure.

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Object-Oriented Design Examples
2+
3+
Companion code repository for "Object-Oriented Design Interview" by ByteByteGo.
4+
5+
## Quick Start
6+
7+
```bash
8+
git clone <repo-url>
9+
cd oo-design
10+
11+
# Build all projects
12+
./gradlew buildAll
13+
14+
# Test a specific project
15+
./gradlew :vendingmachine:test
16+
./gradlew :blackjack:test
17+
./gradlew :tictactoe:test
18+
```
19+
20+
## Available Projects
21+
22+
| Project | Command |
23+
|---------|---------|
24+
| ATM System | `./gradlew :atm:test` |
25+
| Blackjack | `./gradlew :blackjack:test` |
26+
| Elevator System | `./gradlew :elevator:test` |
27+
| File Search | `./gradlew :filesearch:test` |
28+
| Grocery Store | `./gradlew :grocerystore:test` |
29+
| Movie Ticket | `./gradlew :movieticket:test` |
30+
| Parking Lot | `./gradlew :parkinglot:test` |
31+
| Restaurant | `./gradlew :restaurant:test` |
32+
| Shipping Locker | `./gradlew :shippinglocker:test` |
33+
| Tic-Tac-Toe | `./gradlew :tictactoe:test` |
34+
| Vending Machine | `./gradlew :vendingmachine:test` |
35+
36+
## Requirements
37+
38+
- **Java 17+** (Java 21 LTS recommended)
39+
40+
## Project Commands
41+
42+
```bash
43+
# List all available projects
44+
./gradlew projects
45+
46+
# Build specific project
47+
./gradlew :vendingmachine:build
48+
49+
# Test specific project
50+
./gradlew :vendingmachine:test
51+
52+
# Build everything
53+
./gradlew buildAll
54+
55+
# Test everything
56+
./gradlew runAllTests
57+
```
58+
59+
## Running Tests
60+
61+
Tests are configured to always show output (stdout/stderr) and run every time (no caching). This makes it easier to see test results and debug issues.
62+
63+
```bash
64+
# Run tests for a specific project
65+
./gradlew :vendingmachine:test
66+
67+
# If you need to force re-run cached tests in other projects
68+
./gradlew :projectname:cleanTest :projectname:test
69+
```

0 commit comments

Comments
 (0)