Note that there are some explanatory texts on larger screens.

plurals
  1. POC# & Design Patterns - need an elegant solution for a common issue
    primarykey
    data
    text
    <p>I have 2 projects : The first project is a structure project which i read from an xml file.<br> This project is used in other solutions The second project(1 of the other solutions) work on the structure project with foreach running on components list:</p> <pre><code>namespace FriendProject.Workers { public class Worker { static void Main(string[] args) { foreach (Component component in ComponentList) { DoWork(component); } } } } </code></pre> <p>Today the DoWork method does the following: </p> <pre><code>public void DoWork(Component component) { // Doing work on component properties // Zip component files with open source Zipper if (component is DBComponent) { // work on DBComponent properties } } </code></pre> <p>Now if you are familiar with design patterns then you can see that there is an injection point here and the following should be done : </p> <pre><code>public class Component { public virtual void DoWork() { // Do work } } public class DBComponent : Component { public override void DoWork() { base.DoWork(); // injection point - work on DBComponent properties } } public class Operator { static void Main(string[] args) { foreach (Component component in ComponentList) { component.DoWork(); } } } </code></pre> <p>The problem is that the project which holds the Component and DBComponent is a structure project which is used in other solutions and with other projects and I need to add the open source Zip dll to the project and it becomes more tightly coupled to the current project("FriendProject") and less usable. Not to talk about that the other projects will never use these methods(DoWork in Component and DBComponent) </p> <p>Is there a better solution without changing much the design? Should I add an adpater?<br> If so please provide and example.<br> Thanks to all </p> <p><strong>Edit: Short Question</strong><br> 2 projects :<br> One is a manager project which acts on the second project.<br> Second is a structure project(read data from xml) which is reused with other projects.<br> I want to add methods and refernces(since of polymorphism) in the structure project(second project). However it feels wrong since the other projects that uses it will never use those methods and the added references.<br> Is there a better solution for how to do it? </p> <p><strong>Edit :</strong><br> Removed the structure project code the shorten the question. this code was irrelavent since its classes(Component and DBComponent) appear next.</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.
 

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