מפגש 36: תכנון, בנייה, בדיקות, פרסום והצגה.Session 36: Planning, building, testing, publishing and presenting.
תכנון, בנייה, בדיקות, פרסום והצגה. בסוף המפגש מוסיפים צעד לפרויקט המלווה.Planning, building, testing, publishing and presenting. At the end we add a step to the companion project.
מה נעשה היוםToday's plan
היקףScope
חבילהPackage
שירותService
CICI
גרסהRelease
הצגהDemo
עוברים על סדר היום ומזכירים את הפרויקט המלווה.Walk through the plan and mention the companion project.
נושאTopic 1
היקףScope
מה זה מדף 2.0What Shelf 2.0 is
שכבות: models → storage → service → cli/apiLayers: models → storage → service → cli/api
כל מה שבניתם לאורך הקורסEverything you built through the course
לבחור 1–2 תוספות, לא הכולPick 1–2 extras, not everything
פרויקט הגמר מאחד את המדף לגרסה מקצועית: חבילה אחת שיש לה ממשק שורת פקודה (מפגש 27), API (29), מסד נתונים (23), סטטיסטיקה וגרף (24–25), ובדיקות (19). מעליהן אפשר לבחור תוספת אחת או שתיים: המלצות ממודל שפה (33), ייבוא מ-Open Library (22), או גיבוי יומי (28). הנה המבנה, כמפה של שכבות:The final project turns the shelf into a professional version: one package with a command-line interface (session 27), an API (29), a database (23), stats and a chart (24–25), and tests (19). On top, pick one or two extras: language-model recommendations (33), importing from Open Library (22), or a daily backup (28). Here's the structure, as a map of layers:
אנלוגיהAnalogy
פרויקט גמר הוא כמו מבחן מעשי בבישול: לא מבשלים כל מנה שלמדתם, אלא ארוחה אחת שלמה ומדויקת שמראה את כל המיומנויות.A final project is like a practical cooking exam: you don't cook every dish you learned, but one complete, precise meal that shows all the skills.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 2
חבילהPackage
חבילה ו-pyproject.tomlA package and pyproject.toml
תיקיית shelf/ עם __init__.pyA shelf/ folder with __init__.py
pip install -e . = התקנה לפיתוחpip install -e . = install for development
חבילה היא תיקייה עם __init__.py, וכך from shelf.models import Book עובד מכל מקום. הקובץ `pyproject.toml` מתאר את הפרויקט: שם, גרסה, תלויות, ואפילו פקודה בשם shelf שתעבוד בטרמינל אחרי התקנה. pip install -e . מתקין את הפרויקט במצב פיתוח: שינוי בקוד נכנס לתוקף מיד.A package is a folder with __init__.py, so from shelf.models import Book works from anywhere. The `pyproject.toml` file describes the project: name, version, dependencies, and even a shelf command that works in the terminal after installing. pip install -e . installs the project in development mode: code changes take effect at once.
אנלוגיהAnalogy
pyproject.toml הוא כמו תווית על אריזת מוצר: מה בפנים, מה צריך כדי להשתמש בו, ואיך מפעילים.pyproject.toml is like the label on a product's box: what's inside, what you need to use it, and how to switch it on.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
טעות נפוצהCommon mistake
cli.py
from .models import Book
מה Python עונהWhat Python says
ImportError: attempted relative import with no known parent package
ImportError: attempted relative import with no known parent package: ייבוא עם נקודה עובד רק בתוך חבילה. מריצים כ-python -m shelf.cli (או מתקינים עם pip install -e .).ImportError: attempted relative import with no known parent package: a dotted import works only inside a package. Run as python -m shelf.cli (or install with pip install -e .).
שוכחים את __init__.py ומייבאים עם נקודה מהמקום הלא נכון.Using a relative import from the wrong place.
נושאTopic 3
שירותService
שכבת השירותThe service layer
כל החוקים במקום אחדAll the rules in one place
CLI ו-API קוראים לאותן פונקציותThe CLI and API call the same functions
קל לבדוק בלי ממשקEasy to test without an interface
שכבת השירות היא הלב: היא יודעת את החוקים (לא לקרוא יותר מהספר, כותרת לא ריקה, סטטיסטיקה), ומשתמשת באחסון כדי לשמור. גם ה-CLI וגם ה-API רק מתרגמים בקשות לקריאות לשירות. הנה שירות עם אחסון SQLite בזיכרון, ושני "ממשקים" זעירים שמשתמשים בו:The service layer is the heart: it knows the rules (don't read past the book, no empty title, stats), and uses storage to save. Both the CLI and the API just translate requests into calls to the service. Here's a service with in-memory SQLite storage, and two tiny "interfaces" using it:
אנלוגיהAnalogy
שכבת השירות היא כמו המטבח במסעדה עם משלוחים: מי שהזמין באפליקציה ומי שישב בשולחן מקבלים אותה מנה מאותו מטבח.The service layer is like a restaurant kitchen that also delivers: whoever ordered by app and whoever sat at a table get the same dish from the same kitchen.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 4
CICI
CI: בדיקות בכל pushCI: tests on every push
קובץ .github/workflows/tests.ymlA .github/workflows/tests.yml file
GitHub מריץ pytest בכל pushGitHub runs pytest on every push
סימן ירוק/אדום ליד כל commitA green/red mark next to every commit
CI הוא שומר אוטומטי: בכל push, GitHub Actions מקים מחשב נקי, מתקין את הפרויקט ומריץ את הבדיקות. אם משהו נשבר, רואים סימן אדום ליד ה-commit, עוד לפני שמישהו השתמש בקוד. ההגדרה היא קובץ YAML קצר בתיקייה .github/workflows. כאן אפשר גם לבדוק שהקובץ תקין:CI is an automatic guard: on every push, GitHub Actions spins up a clean machine, installs the project and runs the tests. If something breaks, you see a red mark next to the commit, before anyone used the code. The setup is a short YAML file in .github/workflows. You can check the file here too:
אנלוגיהAnalogy
CI הוא כמו גלאי מתכות בכניסה לבניין: כל אחד עובר, כל פעם, בלי יוצא מן הכלל, ולכן אף אחד לא צריך לזכור לבדוק.CI is like a metal detector at a building's entrance: everyone walks through, every time, no exceptions, so nobody has to remember to check.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 5
גרסהRelease
גרסה, יומן שינויים ופרסוםVersion, changelog and release
git tag v2.0.0 ו-Release ב-GitHubgit tag v2.0.0 and a GitHub Release
כשהפרויקט מוכן, נותנים לו גרסה. מדף 1.0 היה הגרסה הראשונה; הוספת API ומסד היא שינוי גדול, ולכן 2.0.0. יומן השינויים מסביר למשתמשים מה חדש. בקוד אפשר אפילו לחשב את הגרסה הבאה לפי סוג השינוי:When the project is ready, give it a version. Shelf 1.0 was the first; adding an API and a database is a big change, so 2.0.0. The changelog tells users what's new. In code you can even compute the next version from the kind of change:
אנלוגיהAnalogy
גרסה סמנטית היא כמו מספר מהדורה של ספר: מהדורה חדשה לגמרי, פרק חדש, או תיקון שגיאות דפוס. הקורא יודע מה לצפות.Semantic versioning is like a book's edition number: an all-new edition, a new chapter, or typo fixes. Readers know what to expect.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
נושאTopic 6
הצגהDemo
יום ההצגה ומה הלאהDemo day and what's next
הדגמה חיה של 3 דקות (מפגש 35)A 3-minute live demo (session 35)
תוכנית ב': צילומי מסך אם משהו נופלPlan B: screenshots if something fails
המשך: Pygame, תרומה לקוד פתוח, פרויקט שניNext: Pygame, open source, a second project
ביום ההצגה מציגים את מדף 2.0 בשלוש דקות: הבעיה, הדגמה חיה, ואתגר אחד. מכינים תוכנית ב' (צילומי מסך) כי הדגמות חיות אוהבות להישבר. ומה אחרי? החלק השביעי של הקורס בונה משחקים עם Pygame, ואפשר להתחיל לתרום לפרויקטים פתוחים ב-GitHub. רשימת בדיקה אחרונה:On demo day, present Shelf 2.0 in three minutes: the problem, a live demo, and one challenge. Prepare a plan B (screenshots) because live demos love to break. And then? The course's seventh part builds games with Pygame, and you can start contributing to open-source projects on GitHub. A final checklist:
אנלוגיהAnalogy
יום ההצגה הוא כמו הופעת סיום בחוג מוזיקה: אף אחד לא מצפה לשלמות, אלא לראות כמה התקדמתם ושאתם נהנים לנגן.Demo day is like a music class's end-of-year concert: nobody expects perfection, just to see how far you've come and that you enjoy playing.
שואלים אם מישהו מכיר דוגמה נוספת מהחיים.Ask for another real-life example.
שכבות: models → storage → service → cli/apiLayers: models → storage → service → cli/api
מה זה מדף 2.0What Shelf 2.0 is
כל מה שבניתם לאורך הקורסEverything you built through the course
מה זה מדף 2.0What Shelf 2.0 is
לבחור 1–2 תוספות, לא הכולPick 1–2 extras, not everything
מה זה מדף 2.0What Shelf 2.0 is
תיקיית shelf/ עם __init__.pyA shelf/ folder with __init__.py
חבילה ו-pyproject.tomlA package and pyproject.toml