What does this code do?
class UtilService
def summer_start
...
end
def summer_end
...
end
def calc(date, charge, quantity, winter_rate, winter_service_charge, summer_rate)
if date < summer_start || date > summer_end
chargeamt = quantity * winter_rate + winter_service_charge
else
chargeamt = quantity * summer_rate
end
chargeamt
end
end
This code return the cost of a certain service depend on the input date. The way the cost is calculated depend on wherethere the input date is in summer time or winter time.
How would you refactor this code? Please include your refactored code and a brief written explanation of your changes.
class UtilService
def summer_start
...
end
def summer_end
...
end
def calc(date, quantity, winter_rate, winter_service_charge, summer_rate)
if date < summer_start || date > summer_end
return quantity * winter_rate + winter_service_charge
end
return quantity * summer_rate
end
end
I removed the charge input variable because we didnt need it. I removed chargeamt variable since I could return the result from operations right away and break out of function. If the first condition wasn't not sastified, the function would return the other condition anyway so else isn't needed.
At Bloc, we have students who enroll into one of several programs (Web Developer Track, Software Developer Track, and Designer Track). Our programs are provisioned by supplying each student with a mentor, whom they choose on their start date (which is not necessarily the same as their enroll date).
How would you go about modelling these requirements in a SQL database? Please include as much detailed information as possible.
There are a couple of business logics that associated with aboves requirements: Each student can enroll one programs. Each student have an unique start date. Each student have one mentor but one mentor can have multiple student.
For SQL database which is relational, I will have two seperate tables: mentors and students. Mentors table will have 1 to many relationship with students table to reflex the business logic: one mentor can have multiple students but one student only have one mentor. Mentors table will have entities: name, _id. Students table will have: _id, name, program, start_day, mentor_id which will be the foreignkey of _id in Mentors table.
What does it mean to you to be a good software engineer?
A good software engineer care about their product and will go the distance to make sure his code is fast, clean and maintainable. He can learns new language or framework quickly and always keeping up with new technologies. A good software engineer also needs exelent communication skill. He should be able to explain his idea and help other people understand new concepts. Finally, he needs to have a love for solving problem every single day.
Are you currently authorized to work in the United States? Yes
This is an in-person position (not remote). Do you currently live in, or open to relocating to the San Francisco Bay Area? Yes
Please rate your English language fluency: I am fluent in English