2

I have application with the following dlls:

Web project - MVC web application

Wcf Services - services that the web application uses.

Model - Entity framework code first entities and DbContext object.

Now when I need to change something lets say function in the wcf services so I change the function but the web also affected and I need to make add service reference again and change the code that uses the wcf service and also the model sometimes changes...

As the CCP states: package should not have more than one reason to change. If change were to happen in an application dependent on a number of packages, ideally we only want changes to occur in one package, rather than in a number of them. This helps us determine classes that are likely to change and package them together for the same reasons. If the classes are tightly coupled, put them in the same package.

So in my design I violates this principle? If someone can explain better design I will be glad.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
ilay zeidman
  • 2,654
  • 5
  • 23
  • 45
  • 3
    that is a common solution structure and yes it would violate this principle. The alternative is to back each concern (let's say managing users) together - this would include models, repositories, controllers, ... but I think in .net the "layer"-model you did is still the most-common one so stick with it IMO – Random Dev Aug 19 '14 at 07:43
  • Obviously, whenever you change an interface, you will have to both change its implementation and the way it's being used by its callers. – vgru Aug 19 '14 at 09:16
  • you right and this is violation of CCP because change in one dll cause changes in other dlls...that was my question is there is better design and if not in what cases we need to use CPP principle? – ilay zeidman Aug 19 '14 at 09:19
  • The CCP principle refers to *horizontal* package cohesion, not vertical one, i.e. splitting common functionality into multiple separate packages used by the same caller. If your package depends on **more than one package**, then you should only have to change a single one, providing that you're changing a single functionality. If you need to add a new functionality which involves new data schema, new business logic and new presentation, of course you will have changes all around the app. – vgru Aug 19 '14 at 09:33

1 Answers1

0

WCF Services contain WSDL definition which is the contract for using its functions and also defines the entities for it. One possible reason that you need to add your reference again is that you are changing this contract. For more information check here: http://msdn.microsoft.com/en-us/library/aa738723(v=vs.110).aspx

Georgi Bilyukov
  • 645
  • 4
  • 11
  • yes I know that what I meant if you change the wcf interface it effets other dlls and violates the CCP principle... – ilay zeidman Aug 19 '14 at 09:17
  • You can use two separate solutions: one for the mvc project and all related assemblies to it and one for the service part. Using this design will help you in your case. – Georgi Bilyukov Aug 19 '14 at 12:47