Skip to main content
refinement
Source Link
Buffy
  • 36.9k
  • 10
  • 66
  • 117

Ideally, interfaces come first. Before Classes. Interfaces define concepts. Classes implement those concepts. Don't think of them as an add-on to OO programming. Think of them as the essence.

Ideally, interfaces come first. Before Classes. Interfaces define concepts. Classes implement those concepts.

Ideally, interfaces come first. Before Classes. Interfaces define concepts. Classes implement those concepts. Don't think of them as an add-on to OO programming. Think of them as the essence.

added 506 characters in body
Source Link
Buffy
  • 36.9k
  • 10
  • 66
  • 117

Note that I often write an interface when I intend only one implementing class. Capture the concept first.

Again, note that I often write an abstract class that has protocol (abstract methods) for every method in any intended subclass. This lets me capture a common implementation, but keeps my concept clear as I subclass. I never need to ask instanceof and I never need to cast an object reference. Everything naturally fits together freeing my mind to think of other (higher level) things.


Note that I often write an interface when I intend only one implementing class. Capture the concept first.

Again, note that I often write an abstract class that has protocol (abstract methods) for every method in any intended subclass. This lets me capture a common implementation, but keeps my concept clear as I subclass. I never need to ask instanceof and I never need to cast an object reference. Everything naturally fits together freeing my mind to think of other (higher level) things.

added 1 character in body
Source Link
Buffy
  • 36.9k
  • 10
  • 66
  • 117

Some rulerules that I'd adhere to with rare exceptions and no exceptions at the start.

Some rule that I'd adhere to with rare exceptions and no exceptions at the start.

Some rules that I'd adhere to with rare exceptions and no exceptions at the start.

Source Link
Buffy
  • 36.9k
  • 10
  • 66
  • 117
Loading