Urgent.News

What's breaking now, across thousands of outlets.

Tech

PRINCIPLE OF INTERFACE SEGREGATION

Nenhuma classe deve ser dependente de métodos que não precisa. Um exemplo seria uma interface “Máquina”, que força os métodos print( ) , scan( ) e fax( ) . Nem toda máquina tem esses 3 métodos. Então criamos as interfaces IPrinter , IScanner e IFax . Agora uma máquina assina apenas os contratos que realmente precisa e cumpre apenas esses. Exemplo de Código (Opcional - Ilustrando o texto): // ❌…

Translated from Portuguese Read in Portuguese

The article discusses the Interface Segregation Principle (ISP), a concept in software development. It states that a class should not depend on methods it doesn't need, and that interfaces should be reusable and specific. A bad example is given of a large interface, IUserActions, that forces a StandardUser class to implement unnecessary methods.

A good example is then provided, where the interface is broken down into smaller, specific ones, such as IReader, IWriter, and IAdmin, allowing classes to implement only what they need. This approach makes the code more modular and easier to maintain.

Written by urgent.news from Dev.to's report — not a translation of it. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

AI data giant Alation confirms cyberattack

The data search and AI giant confirmed unauthorized access to its systems during an incident on Tuesday, and said it was investigating the breach.

  • Alation confirms isolated cyberattack on one system
  • Over 500 global corporations use Alation's AI software
  • Nature and extent of breach not disclosed by company

INTERFACE SEGREGATION PRINCIPLE

No class should be dependent on methods it doesn't need. An example would be a "Machine" interface that forces the print() , scan() , and fax() methods. Not every machine has these 3 methods.

More from Thursday 20 August →