接口隔離原則(ISP)要求不強制客戶端依賴未使用的接口。其核心是用多個小而精的接口替代大而全的接口。違反該原則的表現包括:類實現接口時拋出未實現異常、存在大量無效方法實現、無關功能被強行歸入同一接口。應用方法包括:按常用方法組劃分接口、依據客戶端使用拆分接口、必要時使用組合替代多接口實現。例如將包含打印、掃描、傳真方法的Machine接口拆分為Printer、Scanner和FaxMachine。在小型項目或所有客戶端均使用全部方法時可適當放寬規(guī)則。
The Interface Segregation Principle (ISP) is one of the five SOLID principles of object-oriented design. Simply put, it states that clients should not be forced to depend on interfaces they don’t use. In practical terms, this means it’s better to have many smaller, specific interfaces rather than one large, general-purpose interface.
Why It Matters in Real-World Code
Think of a scenario where you have a class that implements an interface with ten methods, but your class only needs three of them. If you're forced to implement all ten, you end up writing empty or throwaway implementations for the rest — which clutters your code and makes maintenance harder.
This principle helps reduce side effects from changes, keeps dependencies clean, and improves maintainability by ensuring classes only interact with what they need.
Signs You’re Violating ISP
Here are some common symptoms of violating the Interface Segregation Principle:
- Your class implements an interface but throws
NotImplementedException
for some methods. - You see a lot of “dummy” method implementations just to satisfy an interface.
- Multiple unrelated features are grouped into one interface, forcing clients to deal with unnecessary dependencies.
If any of these sound familiar, it might be time to break that big interface into smaller, more focused ones.
How to Apply ISP Effectively
Applying ISP doesn’t mean creating a new interface for every single method — that would overcomplicate things. Instead, focus on grouping related behaviors logically. Here’s how:
- Identify groups of methods in a large interface that are commonly used together.
- Split the interface based on client usage — if two clients use different parts, split them into two interfaces.
- Use composition when needed — instead of one class implementing multiple interfaces, consider combining smaller services.
For example, instead of having one Machine
interface with print()
, scan()
, and fax()
, create separate Printer
, Scanner
, and FaxMachine
interfaces. That way, a basic printer doesn’t have to pretend it can fax.
When It’s Okay to Bend the Rules
Like most design principles, ISP isn’t absolute. Sometimes merging interfaces makes sense for simplicity or performance reasons — especially in small projects or prototypes where over-engineering adds overhead. Also, if all clients truly do use all the methods, there’s no harm keeping a larger interface.
But as a rule of thumb: if you notice certain methods being ignored or faked in implementations, it’s a good time to revisit your interface design.
Basically, that's the idea behind ISP — keep interfaces lean, relevant, and respectful of the classes that use them.
? ??? ????? ?? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Java? ??? ?? ? ?? ?? ?? ???? ?? ??????. 1. ?? ??? ??? ??????. 2. ? ?? ?? ?? ??? ?? ?? ?? ???????. 3. ? ??? ??? ???? ??, ??? ? ??? ?? ? ? ????. 4. ??? ?? ??? ? ??, ?? ??? ????, name (), ordinal (), value () ? valueof ()? ?? ?? ???? ?????. 5. ??? ??? ?? ??, ??? ? ???? ???? ? ??? ?? ??, ?? ?? ?? ?? ??? ?? ????? ?????.

????? ?? ?? (ISP)? ?????? ???? ?? ?????? ???? ??????. ??? ?? ??? ?????? ?? ?? ?? ??? ?????? ???? ????. ? ??? ???? ??? ?????. ???? ?????? ???? ?? ?? ???? ?? ??? ???? ???? ??? ??? ?????? ??? ?????. ?? ???? ???? ??? ????? : ?? ??? ?? ?????? ??? ?????? ?? ?? ????? ?? ? ??? ?? ?? ????? ?? ?? ??? ?????. ?? ??, ??, ?? ? ?? ??? ?? ? ?? ?????? ???, ??? ? ??? ??????. ??? ???? ?? ?? ?????? ?? ??? ??? ? ??? ???? ?? ? ? ????.

Java? ??? ?? ??, ?? ? ??? (? : Projectreactor) ? Java19? ?? ???? ??? ??? ?????? ?????. 1. CompletableFuture? ?? ??? ?? ?? ??? ? ?? ??? ????? ?? ??????? ? ?? ??? ?????. 2. Projectreactor? ?? ? ??? ??? ???? ?? ???? ? ??? ???? ?? ? ?????? ?????. 3. ?? ???? ??? ??? ??? I/O ??? ? ??? ???? ?? ??? ????? ??? ???? ????. ? ???? ?? ??? ????? ??? ??? ??? ?? ??? ??? ?????? ???? ???? ?? ?? ??? ??????.

Java??? ?? ??? ????? ? ?? ?? ???? ????. ??, ?? ??? ??? ??? ?? ? ? ???, ?? ?? ?? ??? ?? ?? ?? ???? ??? ?????. Runnable? run () ????? ?? ?? ??? ??? ?? ?? ? ????? ??? ?????. ??, Callable? ?? ??? ?????? ?? ?? ? ??? ?? ? ????. ?? ????? ????? ??? ???????. ??, Runnable? ??? ?? ExecutorService? ?? ?? ? ? ??? Callable? ExecutorService?? ??? ? ??? ?? ??? ?? ? ? ????.

Javanio? Java 1.4? ?? ? ??? IOAPI???. 1) ?? ? ??? ?????, 2) ??, ?? ? ??? ?? ?? ??, 3) ? ??? ??? ???? 4) ?? ??? ?? IO?? ? ????? ?????. 1) ? ?? IO? ??? ?? ??? ???, 2) ??? ??? ?? ???? ?????, 3) ???? ?????? ???? 4) ??? ?? ??? ?? ?? ? ??? ?????. 1) ??? ??/??? ??? ?? ?????, 2) ???? ???? ???? ?? ???? ???????. 3) ??? ??? ??? ???????.

Java?? ??? ?? ?? ??? ???? ? ?????. ?? ???? ??? ?????. 1. ?? ?? ? ???? ??????? ?? ?? ?? ??? ???? ??? ?????. 2. ?? ??, ???, ??? ?? ?? ?? ???? ????? ?? ??? ??? ??? ?????. 3. ENUMMAP ? ENUMSET? ???? ?? ? ?? ???? ???? ??? ???? ? ?????? ?????. 4. ?? ?, ??? ?? ?? ??? ?? ????? ?? ??? ??? ?????.? ????? ?? ???? ????????. ??? ???? ???? ?? ??? ????? ??? ?? ? ??? ?? ?????? ???????.

JavaprovidesmultiplesynchronizationToolsforthreadsAfety.1.SynchronizedBlocksensUremutualExclusionByLockingMethodSorspecificCodesections.2.reentrantLockofferAdcerAdcenctrol, ratelockandFairnessPolicies.3.ConditionVariablesStowFor

Java? ????? ????? ??? ??? ?? ???? ?? ?? ??????, ?? ? ???? ? ??? ????. ?? ???? ??? ??? ???? ??? ??? ???? ?? ??? ??? ????. ???? ???? ??? ??, ?? ??? ???? ???? ?? ??? ?? ???? ?? ?????. ???? ?? ?? ??? ?? ?? ??? ?????. ?????? ?? ??? ??? ???? ?? ??? ??? ?? ??? ???? ???? ??? ?? ??? ?????? ???? ????? ??? ?? ?? ???, ?? ? ?? ???? ??? ??? ?????. ???? urlclassl? ?? ??? ??? ??? ?? ? ? ????
