Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I break down some methods in the spring service layer
    primarykey
    data
    text
    <p>I'm doing some maintenance/evolution on a multi-layered spring 3.0 project. The client is a heavy RCP application invoking some spring beans methods from the service layer (Managers) on a RMI based server. I have several huge method in the Managers, some of them are doing more than 250 lines.Here is an example : (I've omitted code for clarity)</p> <pre><code> @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public Declaration saveOrUpdateOrDelete(Declaration decla, List&lt;Declaration&gt; toDeleteList ...){ if (decla.isNew()){ // create from scratch and apply business rules for a creation manager1.compute(decla); dao1.save(decla); ... }else if (decla.isCopy() { // Copy from an other Declaration and apply business rules for a copy ... }else { // update Declaration ... } if (toDeleteList!=null){ // Delete declarations and apply business rules for a mass delete ... } </code></pre> <p>The first 3 branches are mutually exclusive and represent a unit of work. The last branch (delete) can happen simultaneously with other branches.</p> <p>Isn't it better to divide this method in something more 'CRUDy' for the sake of clarity and maintainability ? I've been thinking of dividing this behemoth into other manager methods like :</p> <pre><code>public Declaration create(Declaration decla ...){... public Declaration update(Declaration decla ...){... public Declaration copyFrom(Declaration decla ...){... public void delete(List&lt;Declaration&gt; declaList ...){... </code></pre> <p>But my colleagues say it will transfer complexity and business rules to the client that I will loose the benefit of atomicity etc.. Who is right here ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload