➡️ Code (GitLab) Link: Shared in the Member Community Post (If you are Member of this channel, then pls check the Member community post, i have shared the Git link there) ➡️ Become a Member: / @conceptandcoding
I have been at this problem for 2 days and have been looking for a correct implementation and explanation. Finally found both in this video!! The only one on yt i think for tic tac toe. Thank you for realising that people start from basic problems❤
Amazing video. One improvement I would suggest is the use of proper access modifiers for methods and variables. Making everything public might be acceptable if someone is interviewing for an SDE-1 position, but for anything above that, it’s important to ensure that proper scopes and access modifiers are applied to each variable and method.
@Concept && Coding , this is the optimization we can do: Instead of having while loop and then checking getFreeCells() again and again, we know that in 3*3 tic tac toe, player1 and player2 can play maximum 9 times. Thus, we can use simple for loop from 0 < i < board.size*board size. If any player wins in between, we mark winner flag to true and break, else if for loop is exhausted we know it is Tie, thus redundant getFreeCall() loop is avoided.
can you provide code for the same. It will be nice if you can make video explaining the code and approach. It's high time to start a you tube channel bro
I think we can make the board as abstract class and extend it as per different game boards like tictactoeboard, chessboard etc... and we can separate out the logic of checking the winner to the board class. This will help achieve single responsibility principle and also make game class reusable.
Firstly, thanks for the video Shreyansh. I have 2 queries regarding the arrows that you used for class diagram: 1.) The relation between (Board and Pieces) and (Players and Pieces) seems to be of aggregation, but that arrow is not the sign of aggregation. 2.) What exactly that arrow represent as I have not seen that arrow anywhere in class diagrams?
Thank you for this LLD series. I always get confused between the is-a , has-a , etc. relationships. Could you provide me any book or resources in which I could improve this ?
i am not good at designing part and drawing uml diagrams all this stuff should i nned to shift my career to another one like any gove job through ssc cgl any help sir
Just a suggestion , i think the GetFreeCells function is only acting as counter we can replace it with that and while checking IsWinner we can exit when we have first match rather than checking for all cases(except n queen).
Hey shreyansh, I was not able to access parking lot video, it says member access is needed, I don’t find member access join button anywhere. Also, I thought you’re doing it for free. Can you pls help me here with link for member access?
Sir, in this problem, in most interviews, the expectation would be the design + implementation of isThereWinner() method ? Keeping the core design same, I am writing a more generalized and optimised version, thank you sir
Hi Aniket, to me Piece is an Object which can have both the things "Properties" and "Function". That's why i define it as an object. Rather than enum. But definitely you can also implement the same using enum
Correct me If I am wrong. Enumerations will violate the Open Close principle in SOLID principles. Hence I think the design should be improved to follow all the SOLID principles.
Can anyone please tell Which lld pattern tells us that we should create PieceX and PieceO classes instead of passing piece type directly while creating player object
Both. In 45 mins round, if you can explain with UML, always go for it and try to come up with UML in first 20-25 mins and rest 20 mins keep for coding. Couple of points: - Don't try to create perfect design. - involve interviewer and keep asking for his input.
Definitely there can be other ways to implement loggers. I used Chain of responsibility to implement it. Could you try to do it some other way, then we can discuss more.
Hi, I have not given any system design interviews yet in my short career so does the candidate need to develop the whole working solution for an LLD problem or just the class & its methods ?
Hi Ayush, there are 2 types of round 1. LLD Round 2. Machine Coding Round In LLD round, usually it held for 45mins, in that full coding sometimes are not mandatory (depends upon company and interviewer), class diagram and sometimes partial coding works out too. In Machine coding round, it happens generally for more than 1:30hrs (depends upon different company), there they do expect full code with usecases which need to be satisfied.
It would be helpful if you mention whether it's hindi audio or English audio in title. Getting frustrated everytime when I open the design which is hindi.
Hello sir, Iam planning to buy ur RU-vid membership, can you please cover the topics again in English only for the videos in which you have thought in hindi.
@@ConceptandCoding I have last round of interview at amazon most probably bar raiser round, my first two rounds were purely technical rounds which I have cleared so will they ask me to code in bar raiser or ask leadership principles related stuff.. I am so much confused right now..pls help
Hi Vishal, i think Bar Raiser round is also rown as Loop round, pls correct me, if this is the case yes in Loop rounds, there will be coding questions+ Leadership principles questions too. Generally Amazon has 5 rounds, of 2 you have cleared then i am thinking its loop round only where rest 3 round will happen including managerial round.
Got it, one more doubt, why are we not making variables private and using getters/setters Is that not required for games or did I miss something? Thanks.
hi, here can you please explain what is the need of making separate classes for each playingpeice like can't we make a common class here, like enum pieceType then just make two objects of it with X and O type
Do we actually need to check free space every time? Cant we just check the number of free cells by keeping the count? For example in a 3x3 board initially 9 free cells will be there, we can decrease the count each time user makes a move.
Yes we can do. Implementation we can do with many ways, but overall design is imp for this video. But yes there might be efficient way to implement the logic
Hi Shreyansh, I have one query 1. In the video you have 'player' contains 'playingPiece' which in turn contains 'pieceType'(pieceType is enum). What if we don't use 'playingPiece', instead we make 'player' contains 'pieceType'. So we make one less class than earlier. will the second design be better/worse than the first design? And how so? Thanks, great content btw. really appreciate your work.
There is no one solution in LLD, but just think from future perceptive that can more fields will be added in playing piece in future (today it has only piece type), then you have to add them in player class.
Hey Shreyansh I have one doubt that as you Game class is doing multiple things so in future if I need to change(or modify) winning logic, so is it following Single Responsibility Principle?
Depends, how you are grouping your classes. For example: for each method performing some task, we can not put into different class else we will face class explosion issue. So sometimes we have to group some logical related functionality into 1 class. That's why I said in LLD there is no 1 solution. If you think winning logic does not belong to this class and should be other, go ahead but question is will you create separate class for each method?
@@ConceptandCoding "So sometimes we have to group some logical related functionality into 1 class." this clears as I will not create separate class for each method.
why do we need PieceX and PieceO classes. I mean couldn't we simply pass PieceType.X in constructor of playingPiece for a user.. How does this decision make it a better design?
@Shreyansh can you pls clarify my doubt that why playing piece class and it's child class is created, we can simply use the PieceTypeEnum only, this will not violate solid principles
yes, we can, i just thought in future, if any more playing piece need to be introduced with some specific logic, we can add that here. but for this specific X and O you can you Enum too.
Hi Shraytansh, I have a doubt. addPiece() should be in Board Class or Player Class? I think Player Can add the Piece, so adding piece is player Behaviour . On the other side, we can say Board Object can be modified by adding Piece. By this, we can say addPiece() should in Board class. Which is correct and why?
@@ConceptandCoding My second thought was not to keep the playing pieces inside the player and to randomly assign playing pieces to players during the game, eliminating the need for players to change their playing pieces during the game. Would this be a beneficial enhancement, or might it potentially conflict with certain design principles?
I am a member, want to get the Gitlab code link but cannot find it in the member community. Can you please provide any keyword by which I can search it?
It seems code will not work correct for the tie case. All players will get removed from the deque since you are using continue for the case when there is no free cells. It will give null pointer exception. Instead of continue, break should be used.
Hi Subhashish, usage of design patterns is not mandatory. Following SOLID principles is imp. As far as i can recollect, it's a very small question, no design pattern is needed for it. But all SOLID principles properly followed
Hi Ram, i am not comfortable in CPP, college mein padi thi but 7yr in company using Java only. really sorry buddy, but i will let other members if they can help to provide the same solution in Cpp
Hi Shreyansh. Let's say i can have different ways to print a board so i make an interface and different printers will implement that interface. Now this interface should be part of game class or the board class? Same doubt with winning strategy? And if we put it in game class then should we pass the whole board object or the matrix only. Keep making such videos❤
I think the board interface would be part of board concrete class. And you can make various types of board. In TicTacToeGame class you can use parent board interface for refrencing & apply run-time polymorphism to achieve various types of boards.
why are you making most of the videos as members only? I thought u were becoming great just like Striver and what he did for DSA. He still doesn't charge anything...just take some brand promotion or something in the video. This sucks. I really had high hopes from you shrayansh.