Architecture, many methods compared to long lists of parameters

We try to do everything as clear and clean as possible in three-level architecture.

But the complexity of our system leaves us confused as to the best way to continue.

If we use many chains of functions passing through the service level, with smaller lists of parameters, this seems clear from the point of view of what is being done, but it seems that many functions are repeated through these methods.

However, if we use fewer methods and have large lists of parameters to change the functionality in the methods, this seems to get out of hand.

Our choice at the moment has more functions, since it is easiest to manage than monolithic functions with a large number of logical flows inside them. This obviously means smaller pieces of more managed code.

It’s just that we hear a lot about SUSHA, so it’s like repeating within methods. But he looks more flexible.

+5
source share
5 answers

Most people prefer smaller method signatures over larger ones. This makes it easier to reason about methods (not to mention testing them!), However you should not use this to justify violations of DRY principles.

Are there any reasons why you cannot have small method signatures and crowd out common, replicated code into internal helper methods?

+1

, , . :

  • .
  • /, .
  • DI \.
  • , OO.

- , .

1. .

3. DI \.

, -, , DI . , , .

2. /, . DCI http://alexsmail.blogspot.com/2012/09/dci.html .

4. , OO. , Java , . , . , () .

+2

, , , , . , , , , , , . DRY, , , .

" " " Driven Desing" ( ) " " (Robert C. Martin).

+1

, " " , , , - .

apporach , , GridBagLayout GridBagConstraints. , bean "" , , ( " X → X- " ) .

0

. A B, , .

A great way to reduce communication is to introduce domain events. For example, when a user is created, you will create a domain event called UserCreatedwhen it is signed by a class SendWelcomeEmailand NotifyAdminsOfNewUserorSendIntroductionaryOffer

The fact is that any person can act on an event that effectively reduces complexity, since you no longer need to strongly bind your code.

0
source

All Articles