#Is it bad practice to import the same model in several modules?

1 messages · Page 1 of 1 (latest)

quasi crag
#

Hi I have a database model that would make sense to import both in its dedicated module and an extra module, this extra module being an advanced logic about a sub-document of the model.

I know I could make a dedicated service in the original module, but because the original module is already quite large and the extra service will need a few extra files it would be cleaner to be in its own module.

I think I've read somewhere that it was technically an issue but I can't find it anymore. Thanks for your answers.

marble coral
#

A good rule of thumb I live by is maintaining separation of concerns.

#

Do this as much as possible.

#

With that taken in to account how "tight" is the coupling between the model and it's enhanced version?

#

Are you using inheritance or anything yet?

quasi crag
#

The logics aren't really tied

#

But the question is more about is it technically a problem to do so

marble coral
#

I'd keep your models interactions as close as possible.

#

Unless you have resource constraints.

#

Which is a slim chance given the average nest application footprint and todays average available resources 😉

#

You'll have to trade off between engineering time maintaining a single source of truth vs. multiple.

quasi crag
#

From a structural or logical point it's already well covered

#

Just that I think I've read somewhere that importing the same model from two modules could trigger technical issues so I'm looking for a confirmation

marble coral
#

Nah

quasi crag
#

Anyone on this ?

dapper quartz
#

The only issue I can think of is when you're registering the same Provider (service) in multiple modules' providers: [] array. That's often done by mistake, when Nest tells you it can't find a provider and you pop it in the providers array instead of import: []ing the Module where the provider actually is.