Repository navigation
Fold wiki DI/factory lesson content into core-programming patterns - #15
Merged
Merged
Conversation
The curriculum sequence now routes students from Command Groups into these two pages instead of duplicating the wiki lessons, so they need to cover what those lessons taught. dependency-injection.md: - new "Real hardware vs. mocks" section: RobotComponent vs SimulationComponent, Robot.createDaggerComponent() choosing between them, and the MockDevicesModule @BINDS that swaps the motor controller factory. The page had no mention of simulation or mocks at all, which is the whole reason DI matters to a student running unit tests on a laptop. - explains how tests pull objects out of Dagger via getInjectorComponent(), and why BaseRobotComponent needs a line per directly-requestable type - names constructor injection - fixes "public class ShooterSubsystem() {" - a class declaration cannot take parentheses, so the sample would not compile providers-factories.md: - new "What's a Factory?" opener with the Car/CarFactory analogy and the DriveSubsystem motorControllerFactory call students already wrote in Tank Drive. The page previously opened at Dagger level, which is a steep start for someone arriving from the challenges. - adds XGyroFactory and XSolenoidFactory to the factory table All class and factory names verified against the current SeriouslyCommonLib and XbotEdu sources. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #14. The curriculum sequence now sends students from Command Groups into these two pages instead of duplicating the wiki's Factories / Power of Injection / DI with Dagger lessons — so these pages need to actually cover what those lessons taught. They didn't.
dependency-injection.md
The missing half: simulation and mocks. The page explained Component, Module and
@Inject, but never mentionedSimulationComponentorMockDevicesModule— which is the whole reason DI matters to a student whose unit tests run on a laptop with no robot. New "Real hardware vs. mocks" section covers:RobotComponent(real devices) vsSimulationComponent(mock devices), both extendingBaseRobotComponentRobot.createDaggerComponent()choosing between them viaBaseRobot.isReal()MockDevicesModule@Bindsthat swapsXCANMotorControllerFactoryfor the mock implementationDriveSubsystemasks for a factory and never learns which kind it got, so there is noif (testMode)anywhere in subsystem codeHow tests reach into Dagger. Adds the
getInjectorComponent().tankDriveWithJoysticksCommand()pattern students see inTankDriveTest, and explains whyBaseRobotComponentneeds one abstract method per directly-requestable type — while most classes need nothing, since an@Injectconstructor is enough.Smaller fixes: names constructor injection, and fixes
public class ShooterSubsystem() {— a class declaration can't take parentheses, so that sample wouldn't compile. (Same bug the wiki version had; fixed there earlier.)providers-factories.md
A gentler way in. The page opened with "Dagger can inject dependencies, but what if you need objects with runtime values?" — reasonable for someone who already knows Dagger, steep for someone arriving straight from Command Groups. New "What's a Factory?" opener uses the wiki's Car/CarFactory analogy, then connects it to code the student has already written:
The existing Dagger-level material follows unchanged.
Also: adds
XGyro.XGyroFactoryandXSolenoid.XSolenoidFactoryto the factory table.Verification
pnpm docs:buildpasses.🤖 Generated with Claude Code