Why do template patterns in Java design patterns use abstract classes instead of interfaces?

Why should the template pattern in the Java design pattern use abstract classes instead of interfaces?


because the hooks exposed by the template pattern are part of the life cycle (or processing flow).

obviously the interface doesn't let you do some things first, and then some of them (judge? Persistence? The data structure required to transform from an external data structure to a template? And so on) leave room for others to do .

The

interface just tells others what I can do, but I don't know how to do it , which is defined by the interface's implementation class.

Abstract class is I've done most of it, so you can ok me with some details about what to do .


is very simple, the template contains some common business design, which contains a lot of common methods. The interface cannot contain methods (Java 8's interface supports default and static methods, blurring the boundaries of abstract classes, but it is still impossible to add various public/protected methods as freely as abstract classes.)


interface can not define variables, can only define constants. The
interface method is not specifically implemented. Abstract classes can have concrete implementations.
and. You can still think so. If you want to use a template, use a template. Instead of using multiple templates together. Interfaces can be implemented more often. Abstract classes can only inherit


because the parent class needs to do something , while the interface parent class is that does nothing

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30703-2bd29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30703-2bd29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?