Applicability of Single Responsibility PrincipleDo you leverage the benefits of the open-closed principle?Single Responsibility Principle ImplementationSomething confusing about Single Responsibility PrincipleSingle Responsibility Principle: Responsibility unknownIdentifying Domain Services & Application Services when doing DDDApplication of Single Responsibility Principle on a ButtonWhen using the Single Responsibility Principle, what constitutes a “responsibility?”Single Responsibility Principle Violation?Does Template pattern violate Single Responsibility principle?Single responsibility principle - importer

Student evaluations of teaching assistants

voltage of sounds of mp3files

Can somebody explain Brexit in a few child-proof sentences?

What is the oldest known work of fiction?

Bash method for viewing beginning and end of file

Failed to fetch jessie backports repository

Is there an Impartial Brexit Deal comparison site?

Greatest common substring

Cynical novel that describes an America ruled by the media, arms manufacturers, and ethnic figureheads

What's a natural way to say that someone works somewhere (for a job)?

Will it be accepted, if there is no ''Main Character" stereotype?

Finding all intervals that match predicate in vector

How to be diplomatic in refusing to write code that breaches the privacy of our users

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

There is only s̶i̶x̶t̶y one place he can be

Lay out the Carpet

Should my PhD thesis be submitted under my legal name?

What are the ramifications of creating a homebrew world without an Astral Plane?

Your magic is very sketchy

What to do with wrong results in talks?

Modify casing of marked letters

Why "be dealt cards" rather than "be dealing cards"?

Why does John Bercow say “unlock” after reading out the results of a vote?

How was Earth single-handedly capable of creating 3 of the 4 gods of chaos?



Applicability of Single Responsibility Principle


Do you leverage the benefits of the open-closed principle?Single Responsibility Principle ImplementationSomething confusing about Single Responsibility PrincipleSingle Responsibility Principle: Responsibility unknownIdentifying Domain Services & Application Services when doing DDDApplication of Single Responsibility Principle on a ButtonWhen using the Single Responsibility Principle, what constitutes a “responsibility?”Single Responsibility Principle Violation?Does Template pattern violate Single Responsibility principle?Single responsibility principle - importer













12















I recently came by a seemingly trivial architectural problem. I had a simple repository in my code that was called like this (code is in C#):



var user = /* create user somehow */;
_userRepository.Add(user);
/* do some other stuff*/
_userRepository.SaveChanges();


SaveChanges was a simple wrapper that commits changes to database:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);



Then, after some time, I needed to implement new logic that would send email notifications every time a user was created in the system. Since there were many calls to _userRepository.Add() and SaveChanges around the system, I decided to update SaveChanges like this:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);
foreach (var newUser in dataContext.GetAddedUsers())

_eventService.RaiseEvent(new UserCreatedEvent(newUser ))




This way, external code could subscribe to UserCreatedEvent and handle the needed business logic that would send notifications.



But it was pointed out to me that my modification of SaveChanges violated the Single Responsibility principle, and that SaveChanges should just save and not fire any events.



Is this a valid point? It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function. And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.









share

















  • 3





    Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

    – Robert Harvey
    6 hours ago






  • 7





    My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

    – Robert Harvey
    6 hours ago











  • I think your coworker is right, but your question is valid and useful, so upvoted!

    – Andres F.
    4 hours ago






  • 3





    There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

    – Dunk
    2 hours ago















12















I recently came by a seemingly trivial architectural problem. I had a simple repository in my code that was called like this (code is in C#):



var user = /* create user somehow */;
_userRepository.Add(user);
/* do some other stuff*/
_userRepository.SaveChanges();


SaveChanges was a simple wrapper that commits changes to database:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);



Then, after some time, I needed to implement new logic that would send email notifications every time a user was created in the system. Since there were many calls to _userRepository.Add() and SaveChanges around the system, I decided to update SaveChanges like this:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);
foreach (var newUser in dataContext.GetAddedUsers())

_eventService.RaiseEvent(new UserCreatedEvent(newUser ))




This way, external code could subscribe to UserCreatedEvent and handle the needed business logic that would send notifications.



But it was pointed out to me that my modification of SaveChanges violated the Single Responsibility principle, and that SaveChanges should just save and not fire any events.



Is this a valid point? It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function. And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.









share

















  • 3





    Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

    – Robert Harvey
    6 hours ago






  • 7





    My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

    – Robert Harvey
    6 hours ago











  • I think your coworker is right, but your question is valid and useful, so upvoted!

    – Andres F.
    4 hours ago






  • 3





    There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

    – Dunk
    2 hours ago













12












12








12








I recently came by a seemingly trivial architectural problem. I had a simple repository in my code that was called like this (code is in C#):



var user = /* create user somehow */;
_userRepository.Add(user);
/* do some other stuff*/
_userRepository.SaveChanges();


SaveChanges was a simple wrapper that commits changes to database:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);



Then, after some time, I needed to implement new logic that would send email notifications every time a user was created in the system. Since there were many calls to _userRepository.Add() and SaveChanges around the system, I decided to update SaveChanges like this:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);
foreach (var newUser in dataContext.GetAddedUsers())

_eventService.RaiseEvent(new UserCreatedEvent(newUser ))




This way, external code could subscribe to UserCreatedEvent and handle the needed business logic that would send notifications.



But it was pointed out to me that my modification of SaveChanges violated the Single Responsibility principle, and that SaveChanges should just save and not fire any events.



Is this a valid point? It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function. And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.









share














I recently came by a seemingly trivial architectural problem. I had a simple repository in my code that was called like this (code is in C#):



var user = /* create user somehow */;
_userRepository.Add(user);
/* do some other stuff*/
_userRepository.SaveChanges();


SaveChanges was a simple wrapper that commits changes to database:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);



Then, after some time, I needed to implement new logic that would send email notifications every time a user was created in the system. Since there were many calls to _userRepository.Add() and SaveChanges around the system, I decided to update SaveChanges like this:



void SaveChanges()

_dataContext.SaveChanges();
_logger.Log("User DB updated: " + someImportantInfo);
foreach (var newUser in dataContext.GetAddedUsers())

_eventService.RaiseEvent(new UserCreatedEvent(newUser ))




This way, external code could subscribe to UserCreatedEvent and handle the needed business logic that would send notifications.



But it was pointed out to me that my modification of SaveChanges violated the Single Responsibility principle, and that SaveChanges should just save and not fire any events.



Is this a valid point? It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function. And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.







architecture single-responsibility





share












share










share



share










asked 7 hours ago









Andre BorgesAndre Borges

6541812




6541812







  • 3





    Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

    – Robert Harvey
    6 hours ago






  • 7





    My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

    – Robert Harvey
    6 hours ago











  • I think your coworker is right, but your question is valid and useful, so upvoted!

    – Andres F.
    4 hours ago






  • 3





    There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

    – Dunk
    2 hours ago












  • 3





    Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

    – Robert Harvey
    6 hours ago






  • 7





    My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

    – Robert Harvey
    6 hours ago











  • I think your coworker is right, but your question is valid and useful, so upvoted!

    – Andres F.
    4 hours ago






  • 3





    There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

    – Dunk
    2 hours ago







3




3





Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

– Robert Harvey
6 hours ago





Your retort is: "OK, so how would you write it so that it doesn't violate SRP but still allows a single point of modification?"

– Robert Harvey
6 hours ago




7




7





My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

– Robert Harvey
6 hours ago





My observation is that raising an event does not add an additional responsibility. In fact, quite the opposite: it delegates the responsibility somewhere else.

– Robert Harvey
6 hours ago













I think your coworker is right, but your question is valid and useful, so upvoted!

– Andres F.
4 hours ago





I think your coworker is right, but your question is valid and useful, so upvoted!

– Andres F.
4 hours ago




3




3





There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

– Dunk
2 hours ago





There's no such thing as a definitive definition of a Single Responsibility. The person pointing out that it violates SRP is correct using their personal definition and you are correct using your definition. I think your design is perfectly fine with the caveat that this event isn't a one-off whereby other similar functionality is done in different ways. Consistency is far, far, far more important to pay attention to than some vague guideline like SRP which carried to the extreme ends up with tons of very easy to understand classes that nobody knows how to make work in a system.

– Dunk
2 hours ago










5 Answers
5






active

oldest

votes


















6














Yes it is a violation of the single responsibility principle and a valid point.



A better design would be to have a separate process retrieve 'new users' from the repository and send the emails. Keeping track of which users have been sent an email, failures, resends etc etc.



This way you can handle errors, crashes and the like as well as avoiding your repository grabbing every requirement which has the idea that events happen "when something is committed to the database"



The repository doesn't know that a user you add is a new user. It's responsibility is simply storing the user.






share|improve this answer




















  • 3





    The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

    – Andre Borges
    1 hour ago











  • I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

    – Alexander
    27 secs ago


















2















Is this a valid point?




Yes it is, although it depends a lot on the structure of your code. I don't have the full context so I will try to talk in general.




It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function.




It absolutely isn't. Logging is not part of the business flow, it can be disabled, it shouldn't cause (business) side effects and should not influence the state and heath of your application in any way, even if you were for some reason not able to log anything anymore. Now compare that with the logic you added.




And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.




SRP works in tandem with ISP (S and I in SOLID). You end up with many classes and methods that do very specific things and nothing else. They are very focused, very easy to update or replace, and in general easy(er) to test. Of course in practice you'll also have a few bigger classes that deal with the orchestration: they will have a number of dependencies, and they will focus not on atomised actions, but on business actions, which may require multiple steps. As long as the business context is clear, they can too be called single responsibility, but as you correctly said, as the code grows, you may want to abstract some of it into new classes / interfaces.



Now back to your particular example. If you absolutely must send a notification whenever a user is created and maybe even perform other more specialised actions, then you could create a separate service that encapsulates this requirement, something like UserCreationService, which exposes one method, Add(user), which handles both the storage (the call to your repository) and the notification as a single business action. Or do it in your original snippet, after _userRepository.SaveChanges();






share|improve this answer























  • Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

    – Andre Borges
    1 hour ago


















1














Be careful with premature event launching, because its side effects are hard (if possible) to undo.



That said, consider the next premise. Creating users is one thing, it's persistence a different one.



Creating users is a business-specific rule. A business concern. It might or might not involve persistence. It might involve more business operations, involving at the same time more database/network operations. Operations the persistence layer knows nothing about (and should not).



It's not even true that _dataContext.SaveChanges(); has persisted the user successfully. It will depend on the db' transaction span. It could be true for databases like Mongodb, which transactions are atomic, but It could not for traditional RDBS implementing ACID transactions.



There's a reason why transaction management happens at the business or service level. These are levels closer to the semantics of the business. They usually describe what user creation means, what to do when everything goes ok and what to do when not.




It seems to me that the raising an event here is essentially the same
thing as logging




Note even close. Logging has no side effects. At least not the ones application events could have.




it just says that such logic should be encapsulated in other classes,
and it is OK for a repository to call these other classes




Not true. SRP is not a class-specific concern. It also operates at higher-levels of abstractions, like layers, components, systems! It's about cohesion, keeping together what changes for the same reasons. If the user creation (use case) changes it's likely the moment and the reasons for the event to happen also changes.






share|improve this answer

























  • +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

    – Andres F.
    4 hours ago






  • 1





    Exactly. Events denote certainity. Something happened but it's over.

    – Laiv
    4 hours ago












  • @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

    – Robert Harvey
    3 hours ago











  • Hmm. I have never seen this sort of events. Would you mind sharing some references?

    – Laiv
    3 hours ago


















1














SRP is, theoretically, about people. The correct question is:



Which "stakeholder" added the "send emails" requirement?



If that stakeholder is also in charge of data persistence (unlikely but possible) then this does not violate SRP. Otherwise, it does.






share|improve this answer
































    0














    Sending a notification that the persistent data store changed seems like a sensible thing to do when saving.



    Of course you shouldn't treat Add as a special case - you'd have to fire events for Modify and Delete as well. It's the special treatment of the "Add" case that smells, forces the reader to explain why it smells, and ultimately leads to the simple (in my humble opinion false) conclusion that it violates SRP.



    A "notifying" repository that can be queried, changed, and fires events on changes is a perfectly normal object. You can expect to find multiple variations thereof in pretty much every decently sized project.




    But is a "notifying" repository actually what you need? You mentioned C#: Many people would agree that using a System.Collections.ObjectModel.ObservableCollection<> instead of System.Collections.Generic.List<> when the latter is all you need is all kinds of bad and wrong, but few would immediately point to SRP.



    What you are doing now is swapping your UserList _userRepository with an ObservableUserCollection _userRepository. If that's the best course of action or not depends on the application. But while it unquestionably makes the _userRepository considerably less lightweight, it doesn't violate SRP.






    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "131"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsoftwareengineering.stackexchange.com%2fquestions%2f389237%2fapplicability-of-single-responsibility-principle%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6














      Yes it is a violation of the single responsibility principle and a valid point.



      A better design would be to have a separate process retrieve 'new users' from the repository and send the emails. Keeping track of which users have been sent an email, failures, resends etc etc.



      This way you can handle errors, crashes and the like as well as avoiding your repository grabbing every requirement which has the idea that events happen "when something is committed to the database"



      The repository doesn't know that a user you add is a new user. It's responsibility is simply storing the user.






      share|improve this answer




















      • 3





        The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

        – Andre Borges
        1 hour ago











      • I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

        – Alexander
        27 secs ago















      6














      Yes it is a violation of the single responsibility principle and a valid point.



      A better design would be to have a separate process retrieve 'new users' from the repository and send the emails. Keeping track of which users have been sent an email, failures, resends etc etc.



      This way you can handle errors, crashes and the like as well as avoiding your repository grabbing every requirement which has the idea that events happen "when something is committed to the database"



      The repository doesn't know that a user you add is a new user. It's responsibility is simply storing the user.






      share|improve this answer




















      • 3





        The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

        – Andre Borges
        1 hour ago











      • I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

        – Alexander
        27 secs ago













      6












      6








      6







      Yes it is a violation of the single responsibility principle and a valid point.



      A better design would be to have a separate process retrieve 'new users' from the repository and send the emails. Keeping track of which users have been sent an email, failures, resends etc etc.



      This way you can handle errors, crashes and the like as well as avoiding your repository grabbing every requirement which has the idea that events happen "when something is committed to the database"



      The repository doesn't know that a user you add is a new user. It's responsibility is simply storing the user.






      share|improve this answer















      Yes it is a violation of the single responsibility principle and a valid point.



      A better design would be to have a separate process retrieve 'new users' from the repository and send the emails. Keeping track of which users have been sent an email, failures, resends etc etc.



      This way you can handle errors, crashes and the like as well as avoiding your repository grabbing every requirement which has the idea that events happen "when something is committed to the database"



      The repository doesn't know that a user you add is a new user. It's responsibility is simply storing the user.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 6 hours ago

























      answered 6 hours ago









      EwanEwan

      42.2k33593




      42.2k33593







      • 3





        The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

        – Andre Borges
        1 hour ago











      • I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

        – Alexander
        27 secs ago












      • 3





        The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

        – Andre Borges
        1 hour ago











      • I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

        – Alexander
        27 secs ago







      3




      3





      The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

      – Andre Borges
      1 hour ago





      The repository doesn't know that a user you add is a new user - yes it does, it has a method called Add. Its semantics implies that all added users are new users. Combine all the arguments passed to Add before calling Save - and you get all new users.

      – Andre Borges
      1 hour ago













      I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

      – Alexander
      27 secs ago





      I like this suggestion. However, pragmatism prevails over purity. Depending on the circumstances, adding an entirely new architectural layer to an existing application can be difficult to justify if all you need to do is literally send a single email when a user is added.

      – Alexander
      27 secs ago













      2















      Is this a valid point?




      Yes it is, although it depends a lot on the structure of your code. I don't have the full context so I will try to talk in general.




      It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function.




      It absolutely isn't. Logging is not part of the business flow, it can be disabled, it shouldn't cause (business) side effects and should not influence the state and heath of your application in any way, even if you were for some reason not able to log anything anymore. Now compare that with the logic you added.




      And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.




      SRP works in tandem with ISP (S and I in SOLID). You end up with many classes and methods that do very specific things and nothing else. They are very focused, very easy to update or replace, and in general easy(er) to test. Of course in practice you'll also have a few bigger classes that deal with the orchestration: they will have a number of dependencies, and they will focus not on atomised actions, but on business actions, which may require multiple steps. As long as the business context is clear, they can too be called single responsibility, but as you correctly said, as the code grows, you may want to abstract some of it into new classes / interfaces.



      Now back to your particular example. If you absolutely must send a notification whenever a user is created and maybe even perform other more specialised actions, then you could create a separate service that encapsulates this requirement, something like UserCreationService, which exposes one method, Add(user), which handles both the storage (the call to your repository) and the notification as a single business action. Or do it in your original snippet, after _userRepository.SaveChanges();






      share|improve this answer























      • Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

        – Andre Borges
        1 hour ago















      2















      Is this a valid point?




      Yes it is, although it depends a lot on the structure of your code. I don't have the full context so I will try to talk in general.




      It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function.




      It absolutely isn't. Logging is not part of the business flow, it can be disabled, it shouldn't cause (business) side effects and should not influence the state and heath of your application in any way, even if you were for some reason not able to log anything anymore. Now compare that with the logic you added.




      And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.




      SRP works in tandem with ISP (S and I in SOLID). You end up with many classes and methods that do very specific things and nothing else. They are very focused, very easy to update or replace, and in general easy(er) to test. Of course in practice you'll also have a few bigger classes that deal with the orchestration: they will have a number of dependencies, and they will focus not on atomised actions, but on business actions, which may require multiple steps. As long as the business context is clear, they can too be called single responsibility, but as you correctly said, as the code grows, you may want to abstract some of it into new classes / interfaces.



      Now back to your particular example. If you absolutely must send a notification whenever a user is created and maybe even perform other more specialised actions, then you could create a separate service that encapsulates this requirement, something like UserCreationService, which exposes one method, Add(user), which handles both the storage (the call to your repository) and the notification as a single business action. Or do it in your original snippet, after _userRepository.SaveChanges();






      share|improve this answer























      • Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

        – Andre Borges
        1 hour ago













      2












      2








      2








      Is this a valid point?




      Yes it is, although it depends a lot on the structure of your code. I don't have the full context so I will try to talk in general.




      It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function.




      It absolutely isn't. Logging is not part of the business flow, it can be disabled, it shouldn't cause (business) side effects and should not influence the state and heath of your application in any way, even if you were for some reason not able to log anything anymore. Now compare that with the logic you added.




      And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.




      SRP works in tandem with ISP (S and I in SOLID). You end up with many classes and methods that do very specific things and nothing else. They are very focused, very easy to update or replace, and in general easy(er) to test. Of course in practice you'll also have a few bigger classes that deal with the orchestration: they will have a number of dependencies, and they will focus not on atomised actions, but on business actions, which may require multiple steps. As long as the business context is clear, they can too be called single responsibility, but as you correctly said, as the code grows, you may want to abstract some of it into new classes / interfaces.



      Now back to your particular example. If you absolutely must send a notification whenever a user is created and maybe even perform other more specialised actions, then you could create a separate service that encapsulates this requirement, something like UserCreationService, which exposes one method, Add(user), which handles both the storage (the call to your repository) and the notification as a single business action. Or do it in your original snippet, after _userRepository.SaveChanges();






      share|improve this answer














      Is this a valid point?




      Yes it is, although it depends a lot on the structure of your code. I don't have the full context so I will try to talk in general.




      It seems to me that the raising an event here is essentially the same thing as logging: just adding some side functionality to the function.




      It absolutely isn't. Logging is not part of the business flow, it can be disabled, it shouldn't cause (business) side effects and should not influence the state and heath of your application in any way, even if you were for some reason not able to log anything anymore. Now compare that with the logic you added.




      And SRP does not prohibit you from using logging or firing events in your functions, it just says that such logic should be encapsulated in other classes, and it is OK for a repository to call these other classes.




      SRP works in tandem with ISP (S and I in SOLID). You end up with many classes and methods that do very specific things and nothing else. They are very focused, very easy to update or replace, and in general easy(er) to test. Of course in practice you'll also have a few bigger classes that deal with the orchestration: they will have a number of dependencies, and they will focus not on atomised actions, but on business actions, which may require multiple steps. As long as the business context is clear, they can too be called single responsibility, but as you correctly said, as the code grows, you may want to abstract some of it into new classes / interfaces.



      Now back to your particular example. If you absolutely must send a notification whenever a user is created and maybe even perform other more specialised actions, then you could create a separate service that encapsulates this requirement, something like UserCreationService, which exposes one method, Add(user), which handles both the storage (the call to your repository) and the notification as a single business action. Or do it in your original snippet, after _userRepository.SaveChanges();







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 3 hours ago









      asyncasync

      52459




      52459












      • Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

        – Andre Borges
        1 hour ago

















      • Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

        – Andre Borges
        1 hour ago
















      Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

      – Andre Borges
      1 hour ago





      Logging is not part of the business flow - how is this relevant in the context of SRP? If the purpose of my event would be to send new user data to Google Analytics - then disabling it would have the same business effect as disabling logging: not critical, but pretty upsetting. What is the rule of a thumb for adding/not adding new logic to a function? "Will disabling it cause major business side effects?"

      – Andre Borges
      1 hour ago











      1














      Be careful with premature event launching, because its side effects are hard (if possible) to undo.



      That said, consider the next premise. Creating users is one thing, it's persistence a different one.



      Creating users is a business-specific rule. A business concern. It might or might not involve persistence. It might involve more business operations, involving at the same time more database/network operations. Operations the persistence layer knows nothing about (and should not).



      It's not even true that _dataContext.SaveChanges(); has persisted the user successfully. It will depend on the db' transaction span. It could be true for databases like Mongodb, which transactions are atomic, but It could not for traditional RDBS implementing ACID transactions.



      There's a reason why transaction management happens at the business or service level. These are levels closer to the semantics of the business. They usually describe what user creation means, what to do when everything goes ok and what to do when not.




      It seems to me that the raising an event here is essentially the same
      thing as logging




      Note even close. Logging has no side effects. At least not the ones application events could have.




      it just says that such logic should be encapsulated in other classes,
      and it is OK for a repository to call these other classes




      Not true. SRP is not a class-specific concern. It also operates at higher-levels of abstractions, like layers, components, systems! It's about cohesion, keeping together what changes for the same reasons. If the user creation (use case) changes it's likely the moment and the reasons for the event to happen also changes.






      share|improve this answer

























      • +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

        – Andres F.
        4 hours ago






      • 1





        Exactly. Events denote certainity. Something happened but it's over.

        – Laiv
        4 hours ago












      • @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

        – Robert Harvey
        3 hours ago











      • Hmm. I have never seen this sort of events. Would you mind sharing some references?

        – Laiv
        3 hours ago















      1














      Be careful with premature event launching, because its side effects are hard (if possible) to undo.



      That said, consider the next premise. Creating users is one thing, it's persistence a different one.



      Creating users is a business-specific rule. A business concern. It might or might not involve persistence. It might involve more business operations, involving at the same time more database/network operations. Operations the persistence layer knows nothing about (and should not).



      It's not even true that _dataContext.SaveChanges(); has persisted the user successfully. It will depend on the db' transaction span. It could be true for databases like Mongodb, which transactions are atomic, but It could not for traditional RDBS implementing ACID transactions.



      There's a reason why transaction management happens at the business or service level. These are levels closer to the semantics of the business. They usually describe what user creation means, what to do when everything goes ok and what to do when not.




      It seems to me that the raising an event here is essentially the same
      thing as logging




      Note even close. Logging has no side effects. At least not the ones application events could have.




      it just says that such logic should be encapsulated in other classes,
      and it is OK for a repository to call these other classes




      Not true. SRP is not a class-specific concern. It also operates at higher-levels of abstractions, like layers, components, systems! It's about cohesion, keeping together what changes for the same reasons. If the user creation (use case) changes it's likely the moment and the reasons for the event to happen also changes.






      share|improve this answer

























      • +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

        – Andres F.
        4 hours ago






      • 1





        Exactly. Events denote certainity. Something happened but it's over.

        – Laiv
        4 hours ago












      • @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

        – Robert Harvey
        3 hours ago











      • Hmm. I have never seen this sort of events. Would you mind sharing some references?

        – Laiv
        3 hours ago













      1












      1








      1







      Be careful with premature event launching, because its side effects are hard (if possible) to undo.



      That said, consider the next premise. Creating users is one thing, it's persistence a different one.



      Creating users is a business-specific rule. A business concern. It might or might not involve persistence. It might involve more business operations, involving at the same time more database/network operations. Operations the persistence layer knows nothing about (and should not).



      It's not even true that _dataContext.SaveChanges(); has persisted the user successfully. It will depend on the db' transaction span. It could be true for databases like Mongodb, which transactions are atomic, but It could not for traditional RDBS implementing ACID transactions.



      There's a reason why transaction management happens at the business or service level. These are levels closer to the semantics of the business. They usually describe what user creation means, what to do when everything goes ok and what to do when not.




      It seems to me that the raising an event here is essentially the same
      thing as logging




      Note even close. Logging has no side effects. At least not the ones application events could have.




      it just says that such logic should be encapsulated in other classes,
      and it is OK for a repository to call these other classes




      Not true. SRP is not a class-specific concern. It also operates at higher-levels of abstractions, like layers, components, systems! It's about cohesion, keeping together what changes for the same reasons. If the user creation (use case) changes it's likely the moment and the reasons for the event to happen also changes.






      share|improve this answer















      Be careful with premature event launching, because its side effects are hard (if possible) to undo.



      That said, consider the next premise. Creating users is one thing, it's persistence a different one.



      Creating users is a business-specific rule. A business concern. It might or might not involve persistence. It might involve more business operations, involving at the same time more database/network operations. Operations the persistence layer knows nothing about (and should not).



      It's not even true that _dataContext.SaveChanges(); has persisted the user successfully. It will depend on the db' transaction span. It could be true for databases like Mongodb, which transactions are atomic, but It could not for traditional RDBS implementing ACID transactions.



      There's a reason why transaction management happens at the business or service level. These are levels closer to the semantics of the business. They usually describe what user creation means, what to do when everything goes ok and what to do when not.




      It seems to me that the raising an event here is essentially the same
      thing as logging




      Note even close. Logging has no side effects. At least not the ones application events could have.




      it just says that such logic should be encapsulated in other classes,
      and it is OK for a repository to call these other classes




      Not true. SRP is not a class-specific concern. It also operates at higher-levels of abstractions, like layers, components, systems! It's about cohesion, keeping together what changes for the same reasons. If the user creation (use case) changes it's likely the moment and the reasons for the event to happen also changes.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 3 hours ago

























      answered 5 hours ago









      LaivLaiv

      6,89311241




      6,89311241












      • +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

        – Andres F.
        4 hours ago






      • 1





        Exactly. Events denote certainity. Something happened but it's over.

        – Laiv
        4 hours ago












      • @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

        – Robert Harvey
        3 hours ago











      • Hmm. I have never seen this sort of events. Would you mind sharing some references?

        – Laiv
        3 hours ago

















      • +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

        – Andres F.
        4 hours ago






      • 1





        Exactly. Events denote certainity. Something happened but it's over.

        – Laiv
        4 hours ago












      • @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

        – Robert Harvey
        3 hours ago











      • Hmm. I have never seen this sort of events. Would you mind sharing some references?

        – Laiv
        3 hours ago
















      +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

      – Andres F.
      4 hours ago





      +1 Very good point about the transaction span. It can be premature to assert the user has been created, because rollbacks can happen; and unlike with a log, it's likely some other part of the app does something with the event.

      – Andres F.
      4 hours ago




      1




      1





      Exactly. Events denote certainity. Something happened but it's over.

      – Laiv
      4 hours ago






      Exactly. Events denote certainity. Something happened but it's over.

      – Laiv
      4 hours ago














      @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

      – Robert Harvey
      3 hours ago





      @Laiv: Except when they don't. Microsoft has all sorts of events prefixed with Before or Preview that make no guarantees at all about certainty.

      – Robert Harvey
      3 hours ago













      Hmm. I have never seen this sort of events. Would you mind sharing some references?

      – Laiv
      3 hours ago





      Hmm. I have never seen this sort of events. Would you mind sharing some references?

      – Laiv
      3 hours ago











      1














      SRP is, theoretically, about people. The correct question is:



      Which "stakeholder" added the "send emails" requirement?



      If that stakeholder is also in charge of data persistence (unlikely but possible) then this does not violate SRP. Otherwise, it does.






      share|improve this answer





























        1














        SRP is, theoretically, about people. The correct question is:



        Which "stakeholder" added the "send emails" requirement?



        If that stakeholder is also in charge of data persistence (unlikely but possible) then this does not violate SRP. Otherwise, it does.






        share|improve this answer



























          1












          1








          1







          SRP is, theoretically, about people. The correct question is:



          Which "stakeholder" added the "send emails" requirement?



          If that stakeholder is also in charge of data persistence (unlikely but possible) then this does not violate SRP. Otherwise, it does.






          share|improve this answer















          SRP is, theoretically, about people. The correct question is:



          Which "stakeholder" added the "send emails" requirement?



          If that stakeholder is also in charge of data persistence (unlikely but possible) then this does not violate SRP. Otherwise, it does.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 3 hours ago









          user949300user949300

          5,84511528




          5,84511528





















              0














              Sending a notification that the persistent data store changed seems like a sensible thing to do when saving.



              Of course you shouldn't treat Add as a special case - you'd have to fire events for Modify and Delete as well. It's the special treatment of the "Add" case that smells, forces the reader to explain why it smells, and ultimately leads to the simple (in my humble opinion false) conclusion that it violates SRP.



              A "notifying" repository that can be queried, changed, and fires events on changes is a perfectly normal object. You can expect to find multiple variations thereof in pretty much every decently sized project.




              But is a "notifying" repository actually what you need? You mentioned C#: Many people would agree that using a System.Collections.ObjectModel.ObservableCollection<> instead of System.Collections.Generic.List<> when the latter is all you need is all kinds of bad and wrong, but few would immediately point to SRP.



              What you are doing now is swapping your UserList _userRepository with an ObservableUserCollection _userRepository. If that's the best course of action or not depends on the application. But while it unquestionably makes the _userRepository considerably less lightweight, it doesn't violate SRP.






              share|improve this answer



























                0














                Sending a notification that the persistent data store changed seems like a sensible thing to do when saving.



                Of course you shouldn't treat Add as a special case - you'd have to fire events for Modify and Delete as well. It's the special treatment of the "Add" case that smells, forces the reader to explain why it smells, and ultimately leads to the simple (in my humble opinion false) conclusion that it violates SRP.



                A "notifying" repository that can be queried, changed, and fires events on changes is a perfectly normal object. You can expect to find multiple variations thereof in pretty much every decently sized project.




                But is a "notifying" repository actually what you need? You mentioned C#: Many people would agree that using a System.Collections.ObjectModel.ObservableCollection<> instead of System.Collections.Generic.List<> when the latter is all you need is all kinds of bad and wrong, but few would immediately point to SRP.



                What you are doing now is swapping your UserList _userRepository with an ObservableUserCollection _userRepository. If that's the best course of action or not depends on the application. But while it unquestionably makes the _userRepository considerably less lightweight, it doesn't violate SRP.






                share|improve this answer

























                  0












                  0








                  0







                  Sending a notification that the persistent data store changed seems like a sensible thing to do when saving.



                  Of course you shouldn't treat Add as a special case - you'd have to fire events for Modify and Delete as well. It's the special treatment of the "Add" case that smells, forces the reader to explain why it smells, and ultimately leads to the simple (in my humble opinion false) conclusion that it violates SRP.



                  A "notifying" repository that can be queried, changed, and fires events on changes is a perfectly normal object. You can expect to find multiple variations thereof in pretty much every decently sized project.




                  But is a "notifying" repository actually what you need? You mentioned C#: Many people would agree that using a System.Collections.ObjectModel.ObservableCollection<> instead of System.Collections.Generic.List<> when the latter is all you need is all kinds of bad and wrong, but few would immediately point to SRP.



                  What you are doing now is swapping your UserList _userRepository with an ObservableUserCollection _userRepository. If that's the best course of action or not depends on the application. But while it unquestionably makes the _userRepository considerably less lightweight, it doesn't violate SRP.






                  share|improve this answer













                  Sending a notification that the persistent data store changed seems like a sensible thing to do when saving.



                  Of course you shouldn't treat Add as a special case - you'd have to fire events for Modify and Delete as well. It's the special treatment of the "Add" case that smells, forces the reader to explain why it smells, and ultimately leads to the simple (in my humble opinion false) conclusion that it violates SRP.



                  A "notifying" repository that can be queried, changed, and fires events on changes is a perfectly normal object. You can expect to find multiple variations thereof in pretty much every decently sized project.




                  But is a "notifying" repository actually what you need? You mentioned C#: Many people would agree that using a System.Collections.ObjectModel.ObservableCollection<> instead of System.Collections.Generic.List<> when the latter is all you need is all kinds of bad and wrong, but few would immediately point to SRP.



                  What you are doing now is swapping your UserList _userRepository with an ObservableUserCollection _userRepository. If that's the best course of action or not depends on the application. But while it unquestionably makes the _userRepository considerably less lightweight, it doesn't violate SRP.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  PeterPeter

                  2,857515




                  2,857515



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Software Engineering Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsoftwareengineering.stackexchange.com%2fquestions%2f389237%2fapplicability-of-single-responsibility-principle%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

                      Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

                      Чепеларе Съдържание География | История | Население | Спортни и природни забележителности | Културни и исторически обекти | Религии | Обществени институции | Известни личности | Редовни събития | Галерия | Източници | Литература | Външни препратки | Навигация41°43′23.99″ с. ш. 24°41′09.99″ и. д. / 41.723333° с. ш. 24.686111° и. д.*ЧепелареЧепеларски Linux fest 2002Начало на Зимен сезон 2005/06Национални хайдушки празници „Капитан Петко Войвода“Град ЧепелареЧепеларе – народният ски курортbgrod.orgwww.terranatura.hit.bgСправка за населението на гр. Исперих, общ. Исперих, обл. РазградМузей на родопския карстМузей на спорта и скитеЧепеларебългарскибългарскианглийскитукИстория на градаСки писти в ЧепелареВремето в ЧепелареРадио и телевизия в ЧепелареЧепеларе мами с родопски чар и добри пистиЕвтин туризъм и снежни атракции в ЧепелареМестоположениеИнформация и снимки от музея на родопския карст3D панорами от ЧепелареЧепелареррр