1

Please tell me which option is better ?

Option 1: All these methods will be in Track module

  • getTrendingTracks
  • getMyFavoriteTracks
  • likeTrack
  • unlikeTrack
  • getMyPlayedTracks
  • playTrack
  • getArtistTracks

Option 2: These methods will be in separate modules

  1. Track module

    • getTrendingTracks
  2. Like module

    • getMyFavoriteTracks
    • likeTrack
    • unlikeTrack
  3. ListeningHistory module

    • getMyPlayedTracks
    • playTrack
  4. Artist module

    • getArtistTracks

1 Answer 1

2

It depends on the size and the future development of the application.

If the project is small and you don't expect to have a lot of new functionality option 1 is a good choice. It will keep all things close to one another and you will be able to find and modify them easily.

For projects with a lot of functionality and longer lifespans option 2 is better. This way you will be able to create smaller and more cohesive modules. These modules will depend on other modules, so you can create a module dependency map. This way you can manage the dependencies in your application better so you don't end up with spaghetti code.

When you want to add new functionality you will have to do one of several things:

  • Add a new module. This is the coolest thing in options 2. You just add a completely new thing to get new functionality.
  • Extend an already existing module. Having smaller modules makes this a lot easier.
  • Extend a small number of modules. Having smaller cohesive modules makes this a lot easier too

I highly recommend taking a look at Unreal Engine. It has a very good modular architecture. It has a huge codebase, so in order for it to be manageable, they split the Engine into modules. You can check it here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.