mercredi 4 mars 2015

Is important Repeat yourself rule for CQRS

I wonder using design principle rule that named DRY(Do not repeat yourself) on CQRS.


I have 2 type of Geometric table named WaterPipes, GasPipes.



public GasPipe{ id, Name, Length, .... }
public WaterPipe{ id, Name, Length .... }


So I am new at using CQRS. I want to create a query to get total length of them.


Database query will be similar.



Select Sum(Length) From GasPipes,
Select Sum(Length) From WaterPipes


So now can I create one Query?



public class PipeLengthQuery { }
public class PipeLengthQueryHandler {
if(water) Select Sum(Length) From WaterPipes
if(gaz) Select Sum(Length) From GasPipes
}


Or separate query types:



public class WaterPipeLengthQuery { }
public class GasPipeLengthQuery { }
public class GasPipeLengthQueryHandler { }
public class WaterPipeLengthQueryHandler { }


Which of it best?


Aucun commentaire:

Enregistrer un commentaire