We've learned so many things but nothing is related to the CS or SE.
Beyond any shadow of doubt, logic is the core skill of any programmer.
Since you're studying BSE, I'll use an example that is common to the field of enterprise software (as opposed to e.g. hardware drivers). For reference, this is a fairly common problem and by no means a fringe case.
I have two date ranges (i.e. each range has a start date and an end date). I want to know if they overlap in any way. Please write the code necessary to evaluate if these two ranges overlap.
If you want a problem situation: You're making an application for hotel reservations and you need to make sure that you don't double book a room. No two reservations can exist for the same room on the same day.
There is no way to not use logic to answer the question. Because you need to account for many different situations. An overlap is created if:
- range1 is fully in range2
- or range2 is fully in range1
- or range1 is before but partially overlaps range2
- or range2 is before but partially overlaps range1.
This is a diagram of all possibilities you need to account for (ignore case 5).
As a coder, you will work out the logic needed for each of the four cases, and then or their results to see if any of them are true. That's the basic approach to checking if one of many conditions is true.
But if you worked it out and knew how to reduce the logic (remove duplicates, negate the logic, or remove things that are invariably proven by an already existing check), you would see that it's much simpler than that:
bool thereIsOverlap = !(range1.end < range2.start || date2.end < range2.start);
And that is a whole lot simpler than fully writing out all of those checks.
It's all about gates and related to Electrical Engineer.
As I mentioned before, logical gates are essential to programming.
The reason you're seeing this in the context of electrical engineering is because that is a very simple context in which to see its practical applicability.
- I want this lamp to turn on while I press the button.
- I want this lamp to turn off when I press the button.
- I want a buzzer to go off when the this button is pressed and another one is not.
- ...
Consider electrical engineering as the example scenario, rather than the ultimate goal of the lesson. Because you're not learning about electricity (which is obviously a major part of electrical engineering), you're only learning about logic and how to apply it.
Electrical engineers and programmers both use logical gates, and the principle of understanding them is exactly the same, even if their practical application is for different purposes.