## How to apply OOP to real world examples without putting all logic in Manager classes?

I’m lately trying to implement a specific problem using an object-oriented approach. I get the main principles and its advantages, but I fail to apply it to a real world problem. Most examples one could find consist of Cats or Dogs being implementations of Animal. These however don’t give me enough understanding how to model below problem regarding another frequent example: a school administration system.

Imagine a school having Students, Courses, Professors, and Notes. My implementation would be something like this:

class Person {     string name;     int age;      Person(string name, int age) {         this.name = name;         this.age = age;     } }  class Student extends Person {     double gpa;      Student(string name, int age) {         super(name, age);     } }  class Professor extends Person {     string roomNumber;      Professor(string name, int age, string roomNumber) {         super(name, age);         this.roomNumber = roomNumber;     } }  class Course {     string name;     Professor professor;     Students[] student;      Course(string name, Professor professor) {         this.name = name;         this.professor = professor;         this.students = new Student[];     }      void enrolStudent(Student student) {         students.add(student);     } }  class Note {     Course course;     Student student;     double value;      Note(Course course, Student student, double value) {         this.course = course;         this.student = student;         this.value = value;     } } 

Now the Student has a bunch of Notes and we want to calculate its GPA. This could be either straightforward averaging its Notes‘ values or more complex logic using weights and/or ignoring optional courses.

Now my question is: where do we put this logic? Ideally I would have a function double calculateGpa() on Student so you could call student.calculateGpa(), but having this logic on Student would break the SRP in my view. It also does not belong to any other class listed here. A class called GpaCalculator or NotesManager would be another guess but that seems to me too much like moving all the logic away from the domain and into classes that do not represent a real object but just actions (see also this answer).

If that would be the way to go here, why wouldn’t I then just write a pure, static, stateless function in a class called NotesHelper? Creating a manager class to just have one function double calculate(), and using its instance instead of a static function feels to me like making it look like OOP while it isn’t really. I feel like there should be a better approach, probably one I didn’t think of, or maybe I am wrong here. Could you guys give me some pointers?

Thanks!

## How to hide the banner “This site is read only at the farm administrator’s request” after putting SP site in read only mode?

Today, as per client requirement,I made one of the site collections in our production environment on SP 2013 in read only mode. After doing so, we are getting

banner at the top of the page.

Is there any PowerShell command to hide this banner from the page?

## Putting elements in allowed bags

Let’s say I have a list of “Items”

I also have a list of “Bags”. Each bag is a set of “Items” which gives what item can be placed in that bag. But only one item can go in each bag.

I want to place all items in a bag. It’s okay if there are empty bags left over.

Does this sort of problem have a name and a solution other than a naive depth first search (a link in the direction of such an approach will be fine)?

## Does putting salt first make it easier for attacker to bruteforce the hash?

Many recommendations for storing passwords recommend hash(salt + password) rather than hash(password + salt).

Doesn’t putting the salt first make it much faster for the attacker to bruteforce the password, because they can precompute the state of the hashing function with the bytes of the salt, and then each time of their billions and trillions attempts they only need to finish calculating the hash using the bytes of the password.

In other words, each bruteforce iteration needs to calculate only the hash of the password intermediateHashState(password) instead of the whole hash(salt + password).

And if the salt was placed after the password, the attacker wouldn’t have this shortcut.

Does this advantage exist and is it significant?

## Prevent workflow change from putting file into Draft mode

I have a document library which has some documents with metadata fields attached. Some of the metadata fields are edited by a workflow on create / edit. But we are finding when a file is Published from draft to pending, the workflow fires and makes the required change to a metadata tag, and this causes that file to go back into draft mode.

Is it possible to make a change in a workflow and not changing the approval status?

## [ Politics ] Open Question : Do you support putting Harriet Tubman on the $20 bill? While I do agree Harriet was a very important historical figure, I would have thought She would have been on a commemorative silver dollar or half dollar coin I am kind of puzzled by the 20. ## Query Function Not Putting Consolidated Data in the Right Place So I don’t know how to explain this completely, but basically, I’m using the query function to consolidate data from multiple sheets into one Master Sheet. The function itself seems to be working fine and all the data from the other sheets ends up on the Master Sheet. HOWEVER… Instead of the data being added vertically so that the number of rows increases, the data is being added horizontally. A picture is attached to explain this better. Basically, it’s “copying and pasting” the data from the other sheets into the next COLUMN over instead of the next row. ## putting output of command into a string I want to store the output of a bash command to a string in a bash script. The part that matters is as follows: #!/bin/bash player_status="$  (playerctl -l)" 

The output of the command when run on terminal (not with the bash script) is “No players were found”. When I run the bash script (note that there is not an echo) it outputs “No players were found” to the terminal. I want it instead to not put it in the terminal but instead the variable.

## Probability of colour with putting back twice.

I’m having a bit of trouble with following probability-related question:

A container contains 5 red and 10 black balls. Take a ball out of the container at random and note its color. After drawing each ball, the ball gets put back and one extra ball of the same color gets added.

1) Given that the first n drawn balls are all black, calculate the probability (say $$a_{n}$$) that the $$(n+1)$$st ball will also be black. What is $$\lim_{x\to\infty} a_{n}$$ equal to?

2) Given that the second until the $$(n+1)$$st ball (inclusive) are all black, calculate the probability that (say $$b_{n}$$) that the first drawn ball was also black. Also calculate $$\lim_{x\to\infty} b_{n}$$.

I succeeded at answering the first subquestion. As the result I get that $$a_{n} = (10+n)/(15+n)$$ and thus, $$\lim_{x\to\infty} a_{n} = 1$$

However, I have much more trouble answering the second question, and would like your help.

Thanks!