From the course: Learning SOLID Programming Principles
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Introduction to the Interface Segregation Principle - Python Tutorial
From the course: Learning SOLID Programming Principles
Introduction to the Interface Segregation Principle
- [Instructor] The first of the solid design principles, and perhaps the most useful, is the Interface Segregation Principle. The Interface Segregation Principle says no client should be forced to depend on methods it does not use. Stated more positively, a client should depend on the smallest set of interface features, the fewest methods, the fewest attributes. A class needs to be designed so that collaborators have the narrowest interface. If a class has too many methods, the client code is then bound to methods it doesn't need. Because of Python's flexibility, it's easy to ignore this principle. In compiled languages, however, the cost of recompilation can make this principle more urgent than it is in Python. It helps to look closely at the needs of a collaborating class. I like to ask how much does a collaborator need to know? And, ideally, the answer is not much. In this case, the overall main function should read…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.