In undergraduate texts, the 1st Law of Thermodynamics can be confusing. This law is actually another way to express conservation of energy, but the equation that is listed in texts typically describes only one process. This often leads to confusion regarding the sign associated with work, and in fact, some texts state that work entering a system (work done by the environment on the system) is positive while some texts state that work exiting a system (work done on the environment by the system) is positive.
From a practical standpoint, after having worked on thermodynamic problems in industry for a number of years, it is apparent that the following applies regarding the 1st Law of Thermodynamics:
1) work is equivalent to energy;
2) heat is equivalent to energy;
3) if there is a net accumulation of energy in a system, the internal energy of that system increases;
4) if there is a net reduction of energy in a system, the internal energy of that system decreases.
Based on the above items, any energy entering a thermodynamic system adds to the system's internal energy, and any energy leaving a thermodynamic system subtracts from that system's internal energy. In addition, in order to keep all of the signs straight, it is best to draw the equivalent of a free body diagram for each thermodynamic system that you are working with, properly assign the energy flows to that system, and set up an energy balance for that particular system.
For the stated problem, where 80J of heat enter the system, and 30J of work leave the system, the attached drawing shows the process that is involved, and indicates that the change in internal energy is 50J.