Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This is a generic question about class names and ORMs, but for context; I'm working on a Flask web app in Python using SQLalchemy.

I'm struggling with naming a new class that will contain the business logic to process reminders. In the database there is a table named "reminders" that contains data I need. The ORM has created a class 'Reminders' to access it.

Of course, for the business-logic class, the only good name I can think of is also "Reminders", but as I said, there already is a class with that name in my models. I was thinking this could potentially lead to confusion.

My question is; is this still the way to go, two different classes with the same name (but with a different path), or is there a better way/convention to tackle this?

PS: There is one limitation on what I can do; the database is legacy and used by other software, so renaming the table would be 'problematic' at best.

share|improve this question

2 Answers 2

Calling your business logic class the same thing as your domain entity is kind of confusion. If the business logic class is about Reminders then why not call it ReminderRules or ReminderLogic or, my favourite, ReminderBusinessRules.

The last one is my favourite because it makes it clear that the class represents domain logic, and not just formatting, or internal logic.

share|improve this answer

In general, there is nothing wrong in reusing the same name, while putting it in a different namespace to avoid confusion and name collisions.

I don't know Python, but from I've seen right now from Google, there are modules and namespaces, given that your data access layer would probably be a module.

share|improve this answer
    
yes, there are namespaces in Python, so it's possible. But are there conventions that dictate class names to prevent duplicates, or is the proper way just to use a duplicate class names and use the namespaces to differentiate? –  Rico Suave Apr 29 '13 at 8:04
    
IMO, keep the names the same. But MetaFight suggestion is valid too, unless you end up with names like ReminderBusinessRulesFactoriesCollectionDataAccessInitialization. –  MainMa Apr 29 '13 at 8:57
1  
If the namespace makes it clear what the class is for, then I see no problem in keeping the class names the same either. After all, then end goal is that the code be readable and self-documenting. –  MetaFight Apr 29 '13 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.