linq - Code duplication or not? -


here question class design , code duplication.

this scenario: have class having property called supportedflow. property read , return list of flowinfo object, each 1 representing flow (physical file sending external system) few attributes such flowtype (an object representing kind of flow, instance "customer flow" or "dossier flow").

some other classes in system building need know list of "supported flow type" , can reading property supportedflow of above object , applying simple linq query: supportedflow.select(p => p.flowtype).tolist()

some other classes need similar list, obtained applying filter on supportedflow list means of linq object extension method where, istance list of supported flows matching criteria (example: customer - related supported flows).

here question: in such scenario best design choice, adding new properties original object (such supportedflowtype or customerrelatedsupportedflows) apply proper linq query original property supportedflow, or repeating linq query every time when needed in other classes of system ?

in sense guess example of code dupplication, @ same time i'm not sure complicating original object adding new properties best option considering these linq queries quite simple , new properties won't add clarity code base.

thanks replying.

cheers

adding functionality indeed complicate original object, still better repeating functionality everywhere need it.

however, there third option: put method in util class. keeps original object simple , prevents code duplication. disadvantage need "know" there such util class/method if need it.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -