Note that there are some explanatory texts on larger screens.

plurals
  1. POLearning Single Responsibility Principle with C#
    primarykey
    data
    text
    <p>I am trying to learn the Single Responsibility Principle (SRP) but it is being quite difficult as I am having a huge difficult to figure out when and what I should remove from one class and where I should put/organize it.</p> <p>I was googling around for some materials and code examples, but most materials I found, instead of making it easier to understand, made it hard to understand.</p> <blockquote> <p>For example if I have a list of Users and from that List I have a class Called Control that does lots of things like Send a greeting and goodbye message when a user comes in/out, verify weather the user should be able to enter or not and kick him, receive user commands and messages, etc.</p> </blockquote> <p>From the example you don't need much to understand I am already doing too much into one class but yet I am not clear enough on how to split and reorganize it afterwards.</p> <p>If I understand the SRP, I would have a class for joining the channel, for the greeting and goodbye, a class for user verification, a class for reading the commands, right ?</p> <p>But where and how would I use the kick for example ?</p> <p>I have the verification class so I am sure I would have all sort of user verification in there including weather or not a user should be kicked.</p> <p>So the kick function would be inside the channel join class and be called if the verification fails ?</p> <p>For example:</p> <pre><code>public void UserJoin(User user) { if (verify.CanJoin(user)) { messages.Greeting(user); } else { this.kick(user); } } </code></pre> <p>Would appreciate if you guys could lend me a hand here with easy to understand C# materials that are online and free or by showing me how I would be splitting the quoted example and if possible some sample codes, advice, etc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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