System Design ( Day - 43 )

Google docs LLD
Requirements
1. Text
2. Images
3. Scalable → Videos, Tables, different Fonts, etc.
Bad Design
This will break the Single Responsibility principle because it handling everything in the same class.
If we want to add another feature to this app then we have to do everything in this same class and its tightly coupled, this will break Open close Principle.
Better Design
1 . This design is following the Single Responsibility Principle. like everything is decoupled each class is doing their job, they are not interfering with each other. just we are calling that functions in the DocumentEditor.
2 . It’s also following Open Close Principle like if we want to add new feature to save that in the MongoDB then we can add another class and its easily scalable.
3 . It’s also following Liskov substitution principle like in the Save( ) method if we are passing the SaveToFile object then object inside SaveToFile will called if we are passing SaveToDb object then the method inside the SaveToDb will be called.
4 . It’s also following Interface Segregation principle, like only the methods that has to be implemented or required is declared inside the abstract class.
5 . it’s also following Dependency Inversion Principle, like TextElement and ImageElement is a low level models and Document is a high level model, DocumentElement is working as contract between the low level and high level’s.
Subscribe to my newsletter
Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
