ozayezerceli
commited on
Commit
•
a6ac51b
1
Parent(s):
37257fd
Delete pages
Browse files- pages/cohesion.py +0 -80
- pages/coupling.py +0 -73
- pages/monolithic.py +0 -73
pages/cohesion.py
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from utils.code_examples import cohesion_examples
|
3 |
-
from utils.quiz import cohesion_quiz
|
4 |
-
|
5 |
-
st.title("Cohesion in Software Architecture")
|
6 |
-
|
7 |
-
st.write("""
|
8 |
-
Cohesion refers to the degree to which the elements within a module belong together.
|
9 |
-
High cohesion is generally associated with good software design.
|
10 |
-
""")
|
11 |
-
|
12 |
-
st.subheader("Types of Cohesion")
|
13 |
-
st.write("""
|
14 |
-
1. **Functional Cohesion**: All elements of the module are related to the performance of a single function.
|
15 |
-
2. **Sequential Cohesion**: Elements of a module are involved in activities where output from one element serves as input to another.
|
16 |
-
3. **Communicational Cohesion**: Elements of a module operate on the same data.
|
17 |
-
4. **Procedural Cohesion**: Elements of a module are involved in different and possibly unrelated actions that must be performed in a specific order.
|
18 |
-
5. **Temporal Cohesion**: Elements are related by the fact that they are processed at a particular time in program execution.
|
19 |
-
6. **Logical Cohesion**: Elements perform similar operations, but these operations are unrelated.
|
20 |
-
7. **Coincidental Cohesion**: Elements have no meaningful relationship to one another.
|
21 |
-
""")
|
22 |
-
|
23 |
-
st.subheader("Examples of Cohesion")
|
24 |
-
|
25 |
-
for i, (title, description, code) in enumerate(cohesion_examples, 1):
|
26 |
-
st.markdown(f"### Example {i}: {title}")
|
27 |
-
st.write(description)
|
28 |
-
st.code(code, language="python")
|
29 |
-
|
30 |
-
st.subheader("Interactive Exercise: Identify Cohesion Types")
|
31 |
-
st.write("Analyze the following code snippets and identify the type of cohesion present.")
|
32 |
-
|
33 |
-
code1 = """
|
34 |
-
class UserManager:
|
35 |
-
def create_user(self, username, email):
|
36 |
-
# logic to create user
|
37 |
-
pass
|
38 |
-
|
39 |
-
def delete_user(self, user_id):
|
40 |
-
# logic to delete user
|
41 |
-
pass
|
42 |
-
|
43 |
-
def update_user(self, user_id, new_data):
|
44 |
-
# logic to update user
|
45 |
-
pass
|
46 |
-
"""
|
47 |
-
|
48 |
-
code2 = """
|
49 |
-
class ReportGenerator:
|
50 |
-
def generate_sales_report(self):
|
51 |
-
# logic for sales report
|
52 |
-
pass
|
53 |
-
|
54 |
-
def generate_inventory_report(self):
|
55 |
-
# logic for inventory report
|
56 |
-
pass
|
57 |
-
|
58 |
-
def send_email(self, report):
|
59 |
-
# logic to send email
|
60 |
-
pass
|
61 |
-
"""
|
62 |
-
|
63 |
-
st.code(code1, language="python")
|
64 |
-
user_answer1 = st.selectbox("What type of cohesion is present in the first example?",
|
65 |
-
("Functional", "Sequential", "Communicational", "Procedural", "Temporal", "Logical", "Coincidental"))
|
66 |
-
|
67 |
-
st.code(code2, language="python")
|
68 |
-
user_answer2 = st.selectbox("What type of cohesion is present in the second example?",
|
69 |
-
("Functional", "Sequential", "Communicational", "Procedural", "Temporal", "Logical", "Coincidental"))
|
70 |
-
|
71 |
-
if st.button("Check Answers"):
|
72 |
-
if user_answer1 == "Functional" and user_answer2 == "Logical":
|
73 |
-
st.success("Correct! The UserManager class shows functional cohesion, while the ReportGenerator class shows logical cohesion.")
|
74 |
-
else:
|
75 |
-
st.error("Not quite. Try again!")
|
76 |
-
|
77 |
-
st.markdown("---")
|
78 |
-
|
79 |
-
st.subheader("Quiz: Cohesion Concepts")
|
80 |
-
cohesion_quiz()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/coupling.py
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from utils.code_examples import coupling_examples
|
3 |
-
from utils.quiz import coupling_quiz
|
4 |
-
|
5 |
-
st.title("Coupling in Software Architecture")
|
6 |
-
|
7 |
-
st.write("""
|
8 |
-
Coupling refers to the degree of interdependence between software modules.
|
9 |
-
Low coupling is typically a sign of a well-structured computer system and a good design.
|
10 |
-
""")
|
11 |
-
|
12 |
-
st.subheader("Types of Coupling")
|
13 |
-
st.write("""
|
14 |
-
1. **Tight Coupling**: Modules are highly dependent on each other.
|
15 |
-
2. **Loose Coupling**: Modules are relatively independent of each other.
|
16 |
-
""")
|
17 |
-
|
18 |
-
st.subheader("Examples of Coupling")
|
19 |
-
|
20 |
-
for i, (title, description, code) in enumerate(coupling_examples, 1):
|
21 |
-
st.markdown(f"### Example {i}: {title}")
|
22 |
-
st.write(description)
|
23 |
-
st.code(code, language="python")
|
24 |
-
|
25 |
-
st.subheader("Interactive Exercise: Identify Coupling Issues")
|
26 |
-
st.write("Analyze the following code snippets and identify the type of coupling present.")
|
27 |
-
|
28 |
-
code1 = """
|
29 |
-
class Database:
|
30 |
-
def get_user(self, user_id):
|
31 |
-
# database logic here
|
32 |
-
pass
|
33 |
-
|
34 |
-
class UserService:
|
35 |
-
def __init__(self):
|
36 |
-
self.db = Database()
|
37 |
-
|
38 |
-
def get_user_info(self, user_id):
|
39 |
-
return self.db.get_user(user_id)
|
40 |
-
"""
|
41 |
-
|
42 |
-
code2 = """
|
43 |
-
class Database:
|
44 |
-
def get_user(self, user_id):
|
45 |
-
# database logic here
|
46 |
-
pass
|
47 |
-
|
48 |
-
class UserService:
|
49 |
-
def __init__(self, database):
|
50 |
-
self.db = database
|
51 |
-
|
52 |
-
def get_user_info(self, user_id):
|
53 |
-
return self.db.get_user(user_id)
|
54 |
-
"""
|
55 |
-
|
56 |
-
st.code(code1, language="python")
|
57 |
-
user_answer1 = st.radio("What type of coupling is present in the first example?",
|
58 |
-
("Tight Coupling", "Loose Coupling"))
|
59 |
-
|
60 |
-
st.code(code2, language="python")
|
61 |
-
user_answer2 = st.radio("What type of coupling is present in the second example?",
|
62 |
-
("Tight Coupling", "Loose Coupling"))
|
63 |
-
|
64 |
-
if st.button("Check Answers"):
|
65 |
-
if user_answer1 == "Tight Coupling" and user_answer2 == "Loose Coupling":
|
66 |
-
st.success("Correct! The first example shows tight coupling, while the second shows loose coupling.")
|
67 |
-
else:
|
68 |
-
st.error("Not quite. Try again!")
|
69 |
-
|
70 |
-
st.markdown("---")
|
71 |
-
|
72 |
-
st.subheader("Quiz: Coupling Concepts")
|
73 |
-
coupling_quiz()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/monolithic.py
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from utils.code_examples import monolithic_example
|
3 |
-
from utils.quiz import monolithic_quiz
|
4 |
-
|
5 |
-
st.title("Monolithic Architecture")
|
6 |
-
|
7 |
-
st.write("""
|
8 |
-
Monolithic architecture is a traditional unified model for designing software programs.
|
9 |
-
In this architecture, all components of the application are interconnected and interdependent,
|
10 |
-
forming a single, indivisible unit.
|
11 |
-
""")
|
12 |
-
|
13 |
-
st.subheader("Characteristics of Monolithic Architecture")
|
14 |
-
st.write("""
|
15 |
-
1. **Single Codebase**: The entire application is contained within a single codebase.
|
16 |
-
2. **Shared Database**: All modules typically share a single database.
|
17 |
-
3. **Tightly Coupled**: Components are interconnected and interdependent.
|
18 |
-
4. **Single Deployment Unit**: The entire application is deployed as a single unit.
|
19 |
-
""")
|
20 |
-
|
21 |
-
st.subheader("Advantages and Disadvantages")
|
22 |
-
col1, col2 = st.columns(2)
|
23 |
-
|
24 |
-
with col1:
|
25 |
-
st.markdown("**Advantages**")
|
26 |
-
st.write("""
|
27 |
-
- Simple to develop
|
28 |
-
- Easy to deploy
|
29 |
-
- Good performance (no network latency between components)
|
30 |
-
""")
|
31 |
-
|
32 |
-
with col2:
|
33 |
-
st.markdown("**Disadvantages**")
|
34 |
-
st.write("""
|
35 |
-
- Can become complex as the application grows
|
36 |
-
- Difficult to scale individual components
|
37 |
-
- Technology stack is shared across the entire application
|
38 |
-
- Changes can affect the entire system
|
39 |
-
""")
|
40 |
-
|
41 |
-
st.subheader("Example of a Monolithic Architecture")
|
42 |
-
|
43 |
-
st.write("Here's a simplified example of a monolithic e-commerce application with a product recommendation system:")
|
44 |
-
st.code(monolithic_example, language="python")
|
45 |
-
|
46 |
-
st.write("""
|
47 |
-
In this example, all the main functionalities of the e-commerce application
|
48 |
-
(user management, product management, order processing, payment handling, and product recommendations)
|
49 |
-
are contained within a single application. They share the same data structures and are
|
50 |
-
tightly coupled.
|
51 |
-
""")
|
52 |
-
|
53 |
-
st.subheader("Interactive Exercise: Exploring the Monolithic Architecture")
|
54 |
-
|
55 |
-
st.write("Let's modify the monolithic application to enhance the product recommendation system.")
|
56 |
-
|
57 |
-
new_feature = st.text_area("Add a new method to the EcommerceApp class to implement a more advanced product recommendation system:",
|
58 |
-
height=200)
|
59 |
-
|
60 |
-
if new_feature:
|
61 |
-
updated_code = monolithic_example.replace("def recommend_products(self, user, num_recommendations=3):", new_feature)
|
62 |
-
st.code(updated_code, language="python")
|
63 |
-
st.write("""
|
64 |
-
Now that you've enhanced the product recommendation system, consider the following:
|
65 |
-
1. How does this new feature interact with the existing components of the application?
|
66 |
-
2. What challenges might you face if you want to scale just the recommendation system?
|
67 |
-
3. How would you handle updates or maintenance for this feature in a monolithic architecture?
|
68 |
-
""")
|
69 |
-
|
70 |
-
st.markdown("---")
|
71 |
-
|
72 |
-
st.subheader("Quiz: Monolithic Architecture Concepts")
|
73 |
-
monolithic_quiz()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|