4 ms·
I agree with nimblegorilla: an employee that fires himself does not make sense. HR fires them, or some other entity, whichever has the power and permission, doe
by valenterry 6y ago
I agree with nimblegorilla: an employee that fires himself does not make sense. HR fires them, or some other entity, whichever has the power and permission, does so.
In the end, no matter what example you will pick it will always have the same kind of problem, that a higher entity is needed. And in the cases where that is not true, no encapsulation is needed. For example, "employee.age()". You can just do "olderEmployee = copy(employee, age = employee.age + 1)" (pseudocode) from the outside by having the age exposed (which is not classical OOP at all).
But I'm curious if you can find a counter example. Usually it stops working when global constraints come in.
- moocowtruck 6y agoafter doing some smalltalk i think it would be Employee doesn't fire himself, you send him the fire message Employee fire: "immediately" so I kind of see where he's coming from here...
- valenterry 6y agoYeah but that suffers from the problems already mentioned - an employee doesn't fire themselves.
- moocowtruck 6y agoan employee isn't firing themselves, they are being sent the message they are being immediately fired
- valenterry 6y agoSure - then what happens? They notice that they have been fired, but they don't remove themselves from the payroll, or anything like that. So what does the message do?
- Udik 6y agoWhat do you do when you're fired? You collect all your belongings, wipe your machine, and leave. Sure, someone could do this for you, but how would they know that you've left a tracksuit in a locker in the hallway or some cookies in the fridge? Unless the company manages a lot of bureaucracy that keeps track of every single object or resource belonging to the employee.
- deleted 6y ago[deleted]
- valenterry 6y ago> What do you do when you're fired? You collect all your belongings, wipe your machine, and leave. I'm sure you meant to say, the you tell all your belongings to collect themselves together, the machine that it better wipe itself and then you tell yourself to go through the door...
- Udik 6y agoHaha, smart one. The point is, you can perform actions on what you own, and in turn you can ask what you own (for example a laptop) to perform an action on itself or its belongings. You don't need to know how to handle a filesystem and a specific brand of hard drive to ask your laptop to wipe itself; the laptop in turn doesn't need to know all the internals of the hard drive to ask it to perform that action.
- valenterry 6y agoI agree with that. But my answer was for https://news.ycombinator.com/item?id=25118437 https://news.ycombinator.com/item?id=25118437 > So a method call fire() on an object Employee is more "object oriented" than having HREmployeeService.fireEmployee(employeeId) Which doesn't make sense - ignoring the "to set field employedTo directly on EmployeeDAO" because that is unrelated.
- valenterry 6y ago