interface abstract in php real world scenario
- by jason
The goal is to learn whether to use abstract or interface or both...
I'm designing a program which allows a user to de-duplicate all images but in the process rather then I just build classes I'd like to build a set of libraries that will allow me to re-use the code for other possible future purposes.
In doing so I would like to learn interface vs abstract and was hoping someone could give me input into using either.
Here is what the current program will do:
recursive scan directory for all files
determine file type is image type
compare md5 checksum against all other files found and only keep the ones which are not duplicates
Store total duplicates found at the end and display size taken up
Copy files that are not duplicates into folder by date example Year, Month folder with filename is file creation date.
While I could just create a bunch of classes I'd like to start learning more on interfaces and abstraction in php.
So if I take the scan directory class as the first example I have several methods...
ScanForFiles($path)
FindMD5Checksum()
FindAllImageTypes()
getFileList()
The scanForFiles could be public to allow anyone to access it and it stores in an object the entire directory list of files found and many details about them. example extension, size, filename, path, etc...
The FindMD5Checksum runs against the fileList object created from scanForFiles and adds the md5 if needed.
The FindAllImageTypes runs against the fileList object as well and adds if they are image types.
The findmd5checksum and findallimagetypes are optionally run methods because the user might not intend to run these all the time or at all.
The getFileList returns the fileList object itself.
While I have a working copy I've revamped it a few times trying to figure out whether I need to go with an interface or abstract or both.
I'd like to know how an expert OO developer would design it and why?