2

So I'm building my first application, in Python, and some issues have cropped up because of the lack of interfaces (I.e. explicit type declaration)

My design involves several homebrew packages, and I've been taught to reduce coupling by using a controller class for package access. Here's an incomplete class diagram - some of the controllers haven't been made yet, but the intention is to associate all classes through their respective controllers.

The problem is that this reduces cohesion, with the controller interface replacing the services provided by the classes. Now my dilemma is:

  • Should all concerned classes from other packages be coupled with the controller, or the internal classes? A mix of both, or exclusively the controller?
  • Wouldn't other classes have access to a great deal of behaviours that it shouldn't?

I was thinking of using a factory class, behind some of the controller's methods, to return instances internal to the package - but this would increase coupling.

user309290
  • 21
  • 3
  • 1
    How are these packages coupled with the controller? Different methods will produce differing amounts of coupling surface area; which is what you should want to minimize, but obviously some coupling will have to exist, this is the engineering trade off you will have to make! – esoterik Jun 30 '18 at 00:20
  • @esoterik I've updated my post with a link to a class diagram. It's incomplete (no controllers). It should give you an idea on how individual classes "want" to communicate. Thanks. – user309290 Jun 30 '18 at 01:08
  • 1
    `I've been taught to reduce coupling` what coupling? Coupling between your API and consumers? Or internal (among API classes)? – Laiv Jul 05 '18 at 04:36
  • Couple things: 1) Please don't use bit.ly links, it would be best to just use the full, non-shortened link. 2) If this is an image, typically the SE network uses stack.imgur.com, which you can upload to using [this button](https://i.stack.imgur.com/QLZuX.png), though that might not be available until your reputation gets higher. – jrh Jul 14 '18 at 17:26
  • @Laiv Internal amongst my own classes. I was thinking of partitioning them base on their function. – user309290 Jul 15 '18 at 01:45

0 Answers0