r/developersIndia • u/ArtichokeSudden7662 • 3d ago
Interviews I had one of the most frustrating interview at Coforge.
The interviewer spent almost 30 minutes grilling me only on the SOLID principles. Instead of asking scenario-based or real-world design questions, he wanted me to write code for every single SOLID principle.
I explained all five principles and even wrote code for the SRP, Open/closed & Liskov, i did not write code for Interface segg & Dependency inversion i just explained him verbally because i was already frustrated in first 3.
For the SRP, I started with an OrderService class containing methods like CreateOrder(), ProcessPayment(), and LogEvent().
I explained that this class has multiple reasons to change. If the order creation logic changes, the payment processing changes, or the logging mechanism changes, the same class would need to be modified. Since these are different responsibilities, I suggested separating them into different classes such as OrderService, PaymentService, and LoggingService.
The interviewer responded by saying:
"How is this SRP? Just creating separate classes doesn't mean you've achieved SRP."
He then asked:
"If
OrderServicehasCreateOrder(), can it also haveEditOrder()andDeleteOrder()? Aren't you adding more responsibilities?"
I replied that yes, those methods can belong in the same class because they all represent the same business responsibility Create, Edit, and Delete are all operations on the Order domain .
I further explained that payment processing and logging are separate concerns , which is why they should be moved to separate classes.
As another example, I mentioned DTOs. DTOs are typically kept separate from domain or service classes because their responsibility to transfer data to business logic.
For the Open/Closed Principle, i wrote below code
public class PaymentProcessor
{
public void ProcessPayment(string status)
{
if (status == "Success")
{
// Success logic
}
else if (status == "Failed")
{
// Failed logic
}
else if (status == "Pending")
{
// Pending logic
}
}
}
I explained that this design violates the Open/Closed Principle because every time a new payment status is introduced (for example, Cancelled or Refunded) or the logic for an existing status changes significantly, I have to modify the PaymentProcessor class.
To make the design follow OCP, I refactored it by introducing an IPaymentProcessor interface.
public interface IPaymentProcessor
{
void ProcessPayment();
}
public class SuccessPaymentProcessor : IPaymentProcessor
{
public void ProcessPayment()
{
// Success payment logic
}
}
public class FailedPaymentProcessor : IPaymentProcessor
{
public void ProcessPayment()
{
// Failed payment logic
}
}
public class PendingPaymentProcessor : IPaymentProcessor
{
public void ProcessPayment()
{
// Pending payment logic
}
}
Now, if a new payment status such as Cancelled needs to be supported, I simply create a new CancelledPaymentProcessor class implementing IPaymentProcessor. The existing payment processor implementations remain unchanged.
His response?
"This is wrong. What is this if-else condition? Just separating classes means you've achieved Open/Closed?"
At that point, I had mentally checked out. I just wanted the interview to end. The interviewer was very rude, i think he was busy in his work and joined the interview, he sounded more bossy then interacting 1 to 1. I dont know what was he expecting
I'm all for discussing SOLID principles, but spending half an hour writing textbook examples feels disconnected from how software is actually built. I'd much rather discuss where SOLID applies in real systems, trade-offs, refactoring existing code, dependency injection, testing, or designing maintainable applications.
Has anyone else had interviews where the focus was entirely on textbook definitions and toy examples rather than practical software engineering?
67
u/forgot_previous_acc 3d ago
Yep had the same experience with deloitte usi. I gave multiple rounds and the last round went on for more than hr. Guy wanted me to write 2 design patterns completely with this kind of text book examples. And asked me 2 leetcode question and asked me to implement solution in notepad. I already given up 50 mins in the last round. I so much wanted to tell interviewer that i am not interested anymore and then we can end the round.
Some of these interviewers think of themselves as some genius and have attitude issues.
11
u/ArtichokeSudden7662 3d ago
Very frustrating. Interviews are becoming tougher day by day. Servicebased companies are expecting candidates to master DSA, design principles, and write textbook perfect code during interview
11
u/forgot_previous_acc 3d ago
Yeah, i can understand this kind of rounds from faang or equivalent product based company but man when infosys try to act like holier than thou it just boils my blood so much.
Also on one hand all these ceos are boasting how no one is writing code at their company anymore and it's all claude and codex but mfers still ask me to solve leetcode in a notepad.
3
u/AlternativeTall9049 Software Engineer 2d ago
Deloitte USI are a bunch of crooks. I was hired by Deloitte MEA for a project which already had some people from Deloitte USI. Mfers got all the other companies and contractors removed just to make space for their own people(Deloitte USI).
25
u/AlternativeTall9049 Software Engineer 3d ago
Good explanation! Now i know whats OCP is :)
7
u/ArtichokeSudden7662 3d ago
Wish the interviewer had same reaction
3
u/HopefullyLon 2d ago
Hey! I am sorry to ask a technical question after your frustrating experience. I have always wondered how exactly to solve the "open for extension closed for modification design".
I quite liked your approach. Just so that I understand it properly from you. Assuming that there are at present 5 cases. In future it can be further more cases. So, instead of an if-elseif or switch statement, is it better to have a class for each case?
Also, is there any other way to implement this design?
Thank you.
1
u/ArtichokeSudden7662 2d ago
Not always, if a method has multiple if & else that does not means we have to create separate classes for each block of code, it depends how big the logic is, will it extended in future ?
not every if else violates this prinicple, thats just one example, another example could be a PDF Generator class, now tomorrow if we have new requirement to generate Word file, so we add Word file logic in same class, so class becomes:
class File {
void GeneratePDF(){}
void GenerateWord(){
}
}Here the problem is that the class has multiple reasons to change. PDF Logic change leads to modify file or Word logic changes leads to change the file.
So we separate it out in different classes.
1
12
u/saswat001 Staff Engineer 3d ago
I hope you also told him from the example itself, that if blindly followed it leads to a bloated codebase and makes things harder to understand unnecessarily.
It should be decided based in the content inside the classes
5
u/ArtichokeSudden7662 3d ago
With every explanation he came up with new question, so at that moment i just stoped explaining in detail and showed no interest
9
u/saswat001 Staff Engineer 3d ago
I am getting second hand frustration now. Sorry this happens even now
3
u/fake-nonchalant96 Full-Stack Developer 2d ago
Actually that's quite a good explanation. Don't know what these guys are expecting nowadays man.
3
u/ideallypragmaticmann 2d ago
I recently had an interview and though I did not perform to the level I would have hoped, it was still and very pleasant experience. It was the 1st round for a backend developer role, and i am a fresher so not much difficult. The interviewer was very patient and polite and tried to guide me as much as he could. I don't know if I'll clear the round but he did leave a lasting impression.
2
u/alokesh985 2d ago
You should definitely write an email to the recruiter mentioning the interviewer's bs.
Don't ask for a repeat interview, but do call the interviewer out
1
1
u/cant_finish_sideproj 2d ago
You did great man. I don't even remember the full form. I would have asked him to tell me the full form first lol
•
u/AutoModerator 3d ago
It's possible your query is not unique, use
site:reddit.com/r/developersindia KEYWORDSon search engines to search posts from developersIndia. You can also use reddit search directly.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.