Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Polymorphic Abstraction of Disk versus FTP File Access: A Stumbling Block

by btrott (Parson)
on May 22, 2001 at 05:05 UTC ( [id://82145]=note: print w/replies, xml ) Need Help??


in reply to Polymorphic Abstraction of Disk versus FTP File Access: A Stumbling Block

Perhaps this is an indication that your API needs to be reworked slightly? In a generalized, transparent API like you're creating, maybe it's best not to *require* using relatively low-level methods like seek, open, read, etc.

In other words, perhaps you should be thinking of a way to unify the filesystem API and the FTP API; it seems you've been able to do so relatively well so far, but now you've hit a stopping point: so you should step back and think whether your API for this particular operation is really the best possible API.

If you can't seek FTP files, then why have a seek method in your API? That's specific to open filehandles, so it shouldn't be part of your general API.

As an alternative solution, consider this: maybe your

new
method, or your
open
method, should take an argument specifying where in the byte stream the file should be opened. The local-file implementation could then do
open FH, ... seek FH, ...
to get to the proper spot, and the FTP implementation could do
REST
or whatever it is that you need to do for FTP.

This approach might be sufficiently general that you won't get into the same problem of an implementation that cannot possibly fit into your API, because your API was not general enough to begin with.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://82145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-25 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found