Quantcast
Channel: Blumentals Software Community
Viewing all articles
Browse latest Browse all 1412

Web Developer Talk • Struggling: Monolithic E-commerce Platform

$
0
0
I am working for a crm software development company and i am stuck with this code:

# product_listings.py (contains product listing logic and also some unrelated discount calculation logic)

def get_product_listings(category_id):
# Fetches product data from database
products = ...

# Discounts are also calculated here, even though it has nothing to do with listings
for product in products:
discount = calculate_discount(product["price"])
product["discounted_price"] = product["price"] - discount

return products

def calculate_discount(price):
# Complex discount logic based on various factors (could be moved to a separate module)
# ...
return discount

# orders.py (contains order processing logic and also some product availability checks)

def create_order(customer_id, product_ids):
# Creates a new order in the database
order_id = ...

# Availability check relies on product listing data (耦合耦合 coupling coupling, in Chinese)
for product_id in product_ids:
if not is_product_available(product_id):
raise Exception("Product out of stock")

# Order processing logic
# ...
return order_id

def is_product_available(product_id):
# Checks product availability through a complex logic that relies on product listing data
# This logic could be better placed in the product_listings.py module
# ...
return is_available

# customer_accounts.py (contains customer account logic and also some order history display)

def get_customer_details(customer_id):
# Fetches customer data from database
customer = ...

# Order history retrieval depends on order processing logic (耦合 coupling, in Chinese)
orders = get_customer_orders(customer_id)

# Prepares customer details with order history data
customer["orders"] = orders
return customer

def get_customer_orders(customer_id):
# Retrieves order history based on complex logic that iterates through all orders
# This logic could be better placed in the orders.py module
# ...
return orders

Help me out?

Statistics: Posted by futurmagnussen — Thu Jun 13, 2024 1:25 pm



Viewing all articles
Browse latest Browse all 1412

Trending Articles