מפגש 31: מחברים הכול לגרסה 1.0, עם תכנון, בדיקות והצגה.Session 31: Put it all together into version 1.0, with planning, tests and a demo.
מחברים הכול לגרסה 1.0, עם תכנון, בדיקות והצגה. בסוף המפגש מוסיפים צעד לפרויקט המלווה.Put it all together into version 1.0, with planning, tests and a demo. At the end we add a step to the companion project.
מה נעשה היוםToday's plan
תכנוןPlanning
מבנהStructure
ממשקInterface
בדיקותTests
READMEREADME
הגשהSubmit
עוברים על סדר היום ומזכירים את הפרויקט המלווה.Walk through the plan and mention the companion project.
נושאTopic 1
תכנוןPlanning
לתכנן לפני שכותביםPlan before you code
משפט אחד: מה הכלי עושהOne sentence: what the tool does
פרויקט האמצע מחבר את כל מה שלמדתם לכלי אחד: "מדף 1.0", ספרייה אישית מהטרמינל. מתחילים בתכנון: משפט אחד שמסביר מה הכלי עושה, MVP עם מינימום פקודות, ורשימה של רעיונות ל"אחר כך" כדי שהם לא יתקעו את הגרסה הראשונה. התכנון הוא קוד בפני עצמו: רשימת פקודות שאפשר לבדוק.The midterm project joins everything you've learned into one tool: "Shelf 1.0", a personal library in the terminal. Start by planning: one sentence describing what the tool does, an MVP with the fewest commands, and a "later" list so ideas don't hold up the first version. The plan is code in itself: a list of commands you can check.
אנלוגיהAnalogy
MVP הוא כמו אופניים לפני מכונית: גם האופניים לוקחים אתכם ממקום למקום, ומהם לומדים מה באמת צריך.An MVP is like a bicycle before a car: the bike also gets you from A to B, and teaches you what you really need.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 2
מבנהStructure
מבנה הפרויקטProject structure
models.py: הנתוניםmodels.py: the data
storage.py: שמירה וטעינהstorage.py: saving and loading
cli.py: המשתמש; test_shelf.py: הבדיקותcli.py: the user; test_shelf.py: the tests
הפרדת אחריות: כל קובץ יודע דבר אחד. models.py מגדיר מה זה ספר, storage.py יודע לשמור ולטעון, ו-cli.py מדבר עם המשתמש. כך אפשר להחליף את האחסון ל-SQLite (מפגש 23) בלי לגעת בממשק, או להוסיף API (מפגש 29) שמשתמש באותו מודל ואחסון. שלושת הקבצים:Separation of concerns: each file knows one thing. models.py defines what a book is, storage.py knows how to save and load, and cli.py talks to the user. That way you can swap storage for SQLite (session 23) without touching the interface, or add an API (session 29) that reuses the same model and storage. The three files:
אנלוגיהAnalogy
פרויקט מחולק לקבצים הוא כמו מטבח של מסעדה: עמדת סלטים, עמדת גריל, עמדת קינוחים. כל אחד יודע את העבודה שלו, ויחד יוצאת ארוחה.A project split into files is like a restaurant kitchen: a salad station, a grill station, a dessert station. Each knows its job, and together a meal comes out.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 3
ממשקInterface
הממשק: cli.pyThe interface: cli.py
argparse עם שלוש פקודותargparse with three commands
main(argv=None) לבדיקותmain(argv=None) for tests
קוד יציאה 1 כשספר לא נמצאExit code 1 when a book isn't found
cli.py מחבר הכול: מפרש את הפקודה (מפגש 27), טוען את המדף, משנה, ושומר. שימו לב שהלוגיקה פשוטה, כי הנתונים והשמירה כבר מחוץ לקובץ. הנה הקוד והרצה אמיתית שלו:cli.py ties it all together: parses the command (session 27), loads the shelf, changes it, and saves. Notice how simple the logic is, because data and storage already live outside this file. Here's the code and a real run:
אנלוגיהAnalogy
cli.py הוא כמו פקיד קבלה: הוא לא מבשל ולא מנקה, רק מקבל בקשות ומעביר אותן למי שאחראי.cli.py is like a receptionist: doesn't cook or clean, just takes requests and passes them to whoever is responsible.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 4
בדיקותTests
בדיקות לכל הפרויקטTests for the whole project
tmp_path: תיקייה זמנית לכל בדיקהtmp_path: a temp folder per test
לפרויקט אמיתי צריך בדיקות שמכסות כל שכבה. pytest נותן fixtures מובנים: tmp_path הוא תיקייה זמנית ריקה, monkeypatch מחליף זמנית את cli.DATA כדי שהבדיקה לא תיגע בקובץ האמיתי, ו-capsys אוסף את מה שהודפס. כאן הבדיקות רצות על הפרויקט:A real project needs tests covering every layer. pytest offers built-in fixtures: tmp_path is an empty temporary folder, monkeypatch temporarily swaps cli.DATA so the test never touches the real file, and capsys collects what was printed. Here the tests run on the project:
אנלוגיהAnalogy
monkeypatch הוא כמו להחליף את המים בבקבוק במים צבועים לניסוי: אותו בקבוק, אותה תנועה, אבל רואים בדיוק לאן הכול זורם, ובסוף מחזירים.monkeypatch is like swapping a bottle's water for dyed water in an experiment: same bottle, same flow, but you see exactly where it goes, and then put it back.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 5
READMEREADME
READMEREADME
מה, איך מתקינים, איך משתמשיםWhat, how to install, how to use
README הוא חלון הראווה של הפרויקט, והדבר הראשון שמראיין רואה ב-GitHub. שלושה חלקים מספיקים: משפט מה הכלי עושה, איך מתקינים, ואיך משתמשים (עם דוגמה אמיתית). אפשר אפילו לבדוק בקוד שלא שכחתם חלק:A README is the project's shop window, and the first thing an interviewer sees on GitHub. Three parts are enough: a sentence on what the tool does, how to install, and how to use it (with a real example). You can even check in code that you didn't forget a part:
אנלוגיהAnalogy
README הוא כמו הכריכה האחורית של ספר: בכמה שורות מבינים אם זה בשבילכם ואיך מתחילים.A README is like a book's back cover: in a few lines you know whether it's for you and how to start.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
בודקים את עצמכם לפני הגשהCheck yourself before submitting
מעלים ל-GitHub (מפגש 20)Push to GitHub (session 20)
לפני הגשה עוברים על המחוון. הנה המחוון של מדף 1.0, וקוד קטן שמחשב ציון מתוך רשימת בדיקה. התרגילים במפגש הזה הם החלקים של הפרויקט, ואת הפרויקט השלם מעלים ל-GitHub.Before submitting, go through the rubric. Here's Shelf 1.0's rubric, and a little code that computes a score from a checklist. This session's exercises are the project's parts, and the full project goes up to GitHub.
אנלוגיהAnalogy
מחוון הוא כמו רשימת ציוד לטיול: עוברים עליה לפני היציאה, ולא מגלים בשטח ששכחתם את המים.A rubric is like a hiking packing list: check it before leaving, rather than discovering on the trail that you forgot water.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
משפט אחד: מה הכלי עושהOne sentence: what the tool does