Should a base class be marked abstract if there are no abstract members?

Can a class be considered abstract if it does not have abstract members? Even if there is no practical reason for directly creating an instance? (except unit tests)

+3
source share
5 answers

Yes, it is reasonable and useful to designate explicitly as an abstract base class that should not be created, even in the absence of abstract methods.

  • It provides general guidance so that abstract classes are not sheets.
  • This prevents other programmers from instantiating the class. This may make it easier for you to add abstract methods to it later.
+7
source

, ? , . , .

+4

: .

: abstract / . ; , , . , , , , . , , , , .

+4

, , .

, , , - Utility - , static - - private. , . , static. ( Java, )

+1

, . , ; -)

0

All Articles