in my current project have:
module Stats
class Site
...
end
class Product
def initialize(product_id)
@product_id = product_id
end
end
class Profile
...
end
end
now in my Product
class have methods to get/set product views
(day, week, month) and methods to get/set product sales
(day, week, months)
is better to namespace like Stats::Product::Views
and Stats::Product::Sales
or simply prefix methods like sale_add
and view_add
?
example calls with namespace:
Stats::Product::Sales.add(product_id) # increment sales counter
Stats::Product::Sales.today(product_id) # get n. today sales
Stats::Product::Sales.week(product_id) # get n. week sales
Stats::Product::Views.add(product_id) #increment product page view counter
Stats::Product::Views.today(product_id) #get n. today product page views
Stats::Product::Views.week(product_id) #get n. week product page views
example with current structure:
Stats::Product(product_id).sale_add # increment sales counter
Stats::Product(product_id).sales_today # get n. today sales
Stats::Product(product_id).sales_week # get n. week sales
Stats::Product(product_id).view_add #increment product page view counter
Stats::Product(product_id).views_today #get n. today product page views
Stats::Product(product_id).views_week #get n. week product page views
Now, what you think is more elegant solution? and why?
4