两个考试项目的目录,逐个说明The directory layout of both exam projects
哪些文件是你要改的,哪些是给好的,哪些是干扰项。Which files you are meant to edit, which are already done for you, and which are there to distract you.
这一页有什么On this page6
- 看懂两个 assessment 的完整目录结构Read the full directory layout of both exam projects
- 分清「入口文件」「配置文件」「源码」「测试」各在哪Tell apart where the entry files, the config files, the source and the tests each sit
- 知道 index.html → main.tsx → App.tsx → 组件 这条前端启动链Know the front-end start-up chain: index.html to main.tsx to App.tsx to the components
- 认出项目里的干扰项Spot the files in the project that are only there to distract you
两个考试都明确标了「EDIT THIS」和「PROVIDED」。改错文件不加分;而找不到该改的文件会直接丢分。Both exams mark files as EDIT THIS or PROVIDED. Editing the wrong file earns nothing, and failing to find the file you were meant to edit loses points directly.
react-notes-app/Q1 在 src/,Q2 在 q2/Q1 lives in src/, Q2 in q2/
react-notes-app/graphql-federation-practice/node-subgraph/ 和 java-service/ 两个服务Two services: node-subgraph/ and java-service/
graphql-federation-practice/react-notes-app 的完整结构The full layout of react-notes-app
这个项目不大,一屏能看完。下面每一行都真实存在 (node_modules 和 lockfile 省略):
要注意它有两道互不相干的题: src/ 是 Q1(React 界面),q2/ 是 Q2 (纯 TypeScript 的异步调度器,完全不涉及 React)。 很多人一开始会以为 q2 是 src 的一部分,白花时间找关联。
The project is small — it fits on one screen. Every line below really exists (node_modules and the lockfile left out):
Notice that it holds two entirely unrelated questions: src/ is Q1 (the React UI) and q2/ is Q2 (a pure TypeScript async scheduler, no React in it at all). Plenty of people assume q2 is part of src at first and burn time hunting for a connection.
前端项目的启动链:谁调用谁The start-up chain of a front-end project: what calls what
浏览器打开一个空 div,最后长出整个界面 —— 中间这几跳要看清。The browser opens an empty div and ends up with the whole interface. Follow each step in between.
npm run dev 之后,Vite 起一个服务器,浏览器请求index.html。之后是这样一条链:
index.html里有<div id="root"></div>(空的)和一行<script type="module" src="/src/main.tsx">。main.tsx找到那个 div,用ReactDOM.createRoot(...).render(<App />)把 React 应用「挂」进去。App.tsx渲染<NoteManager />。NoteManager渲染<NoteForm />和<NoteTable />,后者再渲染一堆<NoteItem />。
为什么要知道这条链?因为它决定了「state 应该放在哪」。NoteForm 和 NoteTable 是兄弟, 它们没法直接互相通话。要让「表单提交」影响「表格内容」, 数据只能放在它们共同的父亲 NoteManager 里。 这是 Q1 三道题的全部结构基础。
After npm run dev, Vite starts a server and the browser asks for index.html. From there it is one chain:
index.htmlholds a<div id="root"></div>(empty) and one line of<script type="module" src="/src/main.tsx">.main.tsxfinds that div and usesReactDOM.createRoot(...).render(<App />)to mount the React app into it.App.tsxrenders<NoteManager />.NoteManagerrenders<NoteForm />and<NoteTable />, and the latter renders a pile of<NoteItem />.
Why does the chain matter? Because it decides where the state belongs. NoteForm and NoteTable are siblings, and siblings cannot talk to each other directly. For “submit the form” to change “what the table shows”, the data has to live in their shared parent NoteManager. That is the whole structural basis of the three Q1 tasks.
react-notes-app/src/main.tsxFederation 项目:两个服务,两个语言The Federation project: two services, two languages
这个项目的 README 直接标了哪些文件要改。只有两个。其余全是 PROVIDED(给好了,别动)。
This project’s README marks outright which files you edit. There are only two. Everything else is PROVIDED (given to you, hands off).
认出干扰项Spotting the distractors
考试项目里经常有「看起来很重要但其实没用」的东西。Exam projects often contain things that look important but are never used.
java-service/orders.db—— 一个数据库文件。但pom.xml里没有任何 JDBC 或 JPA 依赖, 代码里也没有一处引用它。数据实际来自InMemoryOrderRepository(一个内存 HashMap)。 看到 .db 就去配数据源,是纯浪费时间。- schema 里的
@shareable—— 在@link(import: [...])里被引入了,但全文没用到。 InventoryDataSource.getInventoryStatus()—— 存在,但没有任何 resolver 需要它。(getProductPrice()倒是必须用,后面会讲为什么。)MetricsConfig.java—— 一个空的@Configuration类,里面什么都没有。
判断方法很朴素:顺着依赖和引用找。一个文件如果没有被 import、没有被注入、没有在配置里出现, 它就跟这次任务无关。
java-service/orders.db— a database file. Butpom.xmlhas no JDBC or JPA dependency whatsoever, and not one line of code touches it. The data actually comes fromInMemoryOrderRepository(an in-memory HashMap). Seeing a .db and going off to configure a data source is pure wasted time.@shareablein the schema — it gets pulled in inside@link(import: [...]), then never used anywhere.InventoryDataSource.getInventoryStatus()— it exists, but no resolver needs it. (getProductPrice()really is mandatory; we get to why later.)MetricsConfig.java— an empty@Configurationclass with nothing inside it.
The test for this is plain: follow the dependencies and the references. If a file is never imported, never injected and never named in config, it has nothing to do with this task.
动手做Get your hands on it
填空只是过渡。真正掌握的标准,是在没有答案的时候从头写出来 —— 所以做完 L2 之后一定要往 L3、L4 走。Filling blanks is a stepping stone. The real bar is writing it from nothing, so once L2 is comfortable, push on to L3 and L4.
Q1 要求「表单提交后,新笔记出现在表格里」。表单是NoteForm,表格是 NoteTable,两者是兄弟。 那份笔记列表数据应该存在哪个组件里?
Q1 asks that a new note appears in the table after the form is submitted. The form is NoteForm, the table is NoteTable, and the two are siblings. Which component should hold the list of notes?
Federation 项目里,下面哪个文件与你要完成的任务完全无关?
In the Federation project, which of these files has nothing at all to do with the task you have to finish?
换一道题也能用Works on other problems too
考试不会原题重考。真正能带走的是「看到这种信号 → 伸手去拿这个解法」。The exam will not reuse the same question. What you take away is the reflex: see this signal, reach for that solution.
- react-notes-app 有两道独立的题:src/ 是 React 的 Q1,q2/ 是纯 TS 的 Q2。react-notes-app holds two separate questions: src/ is the React Q1, q2/ is the plain TypeScript Q2.
- 前端启动链:index.html → main.tsx → App.tsx → NoteManager → 子组件。The front-end start-up chain: index.html, main.tsx, App.tsx, NoteManager, then the child components.
- 兄弟组件不能直接通话,所以共享数据必须放在共同父组件里。Sibling components cannot talk to each other directly, so shared data has to sit in the parent they share.
- Federation 项目只有两个文件要改:orderResolvers.js 和 OrderController.java。The Federation project has only two files to edit: orderResolvers.js and OrderController.java.
- orders.db、@shareable、getInventoryStatus、MetricsConfig 都是干扰项。orders.db, @shareable, getInventoryStatus and MetricsConfig are all distractors.