លំហសិក្សាកម្ពុជា លំហសិក្សាកម្ពុជា V1.0
ចូល ចុះឈ្មោះ

ADVANCED OOP II Summary(Homework)

អ្នកចូលរួម
គ្រូដឹកនាំ: សេក សុជាតិ
មូលសង្ខេប / Abstract

This is OOP Homework ( ZIP ARE BEGIN UPLOAD ACCORDING TO EACH LESSON).

OOP II Homework

Pou Chhiangheng CSM1

1. What is an Application Factory?

It's a function, usually create_app(), that builds and returns the Flask app instead of creating the app at the top of the file. The app only gets created when you call the function.

2. Why use create_app()?

So you can create the app with different configs, like one for testing and one for production, and avoid circular imports since everything is wired up inside the function.

3. What role does the Composition Root play?

It's the one place where all the pieces (db, extensions, blueprints) get created and connected. In Flask that's usually inside create_app().

4. What does a Blueprint help with?

It lets you split routes into separate modules instead of dumping everything in one file, then register them onto the main app.

5. Should a Route contain a lot of Business Logic?

No. Routes should just handle the request/response and call a service to do the actual work. Keeps things easier to test and reuse.

6. How are Authentication and Authorization different?

Authentication checks who you are (login). Authorization checks what you're allowed to do once you're logged in.

7. How are User, Role, and Permission related in RBAC?

A User gets assigned one or more Roles, and each Role has a set of Permissions. So instead of giving permissions to users directly, you give them a role and the role carries the permissions.

8. Why should a Plain Password not be stored?

Because if the database ever gets leaked, every password is exposed as-is. Passwords should be hashed so even a leaked database doesn't reveal the real password.

9. How are login_required and permission_required different?

login_required just checks if you're logged in. permission_required checks if you're logged in AND have the specific permission needed for that route.

10. How are 401 and 403 different?

401 means you're not logged in / not authenticated. 403 means you're logged in but you don't have permission to do that action.

ចែករំលែក
រក្សាទុក
ការផ្សព្វផ្សាយ
ការផ្សព្វផ្សាយ
មតិយោបល់ 0
ចូលគណនី ដើម្បីបញ្ចេញមតិ