Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:58:03+00:00 2026-05-30T17:58:03+00:00

In a module I’m currently developing I tried to model the requirements to a

  • 0

In a module I’m currently developing I tried to model the requirements to a class diagram with correct relations.

The requirements:

  1. The module will connect to a set of ftp servers and download some files.
  2. The module will parse each file to generate a set of invoices.

So I created 4 classes File, Ftp & Parser. Now I thought I should make the File class be able to download()and parse() itself.

class File{    
 private   $supplier;
 private   $status;
 private   $fileName;
 private   $fileId;

    function __construct($supplier){
        $this->supplier=$supplier;
    }

   function downloadFile(){
       $ftp= new Ftp($this->supplier);
       $this->fileName=$ftp->download();
   }    

  function parseFile(){
      $parser= new Parser($this); // The parse needs the fileName in addition to the supplier info to parse the file correctly.
      $parser->parse();
  }

  function saveFileInfoToDB(){
  //Save file Info to db.
  }

}

So whenever I need to download a File I did the following:

 class ServiceInvoker{

 function downloadFilesFromFtpServers(){
     foreach($suppliers as $supplier){

    /*$supplier here is an object containing all data needed to download a file 
    from that certain supplier filled from the database 
    (i.e. ftpUsername, ftpPassword, ftpHost, SupplierName, supplierFileType).*/

     try{
     $file= new File($supplier);
     $file->downloadFile() 
     $file->saveFileInfoToDB(); 
      }catch(Exception $e){
       //log error
       }

   }
  }

}

You can clearly see that to download a file I have to go through multiple download calls in different objects.

I think the problem was mainly because I thought the a File class should be able to download itself and therefore I instantiated a Ftp object in the File class itself.

The same happens when I try to parse a file as I need to pass $this to the parse to get the info of the file.

I think that the Ftp class should have been passed an object of the Supplier directly in the ServiceInvoker and make it return a File object if the process succeeded in downloading that file.

Now how should I have correctly identified the relation between classes Ftp Parser and File ? Should File contain a parser object or should the parser itself contain the File object and be called directly from the service invoker ? I can clearly identify the relation between the Parser and File classes as Association. The same between the Ftp and file classes but who should contain who ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:58:04+00:00Added an answer on May 30, 2026 at 5:58 pm

    In my opinion you should reconsider the responsibilties of the file. A file can be downloaded, but it isn’t a responsibility of a file.

    What I mean is that the class File should outline the properties and the responsibilities of a File. The responsibility to download a file should be put in a DownloadManager or somehing equal.

    Some great guidelines for desigining an application can be found in [SOLID design principle, origin of the principle can be found in this paper of Uncle Bob

    It gives you five guidelines which gives you a design which should be loosely coupled and easier to maintain and re-use. There are many resources available about this topic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any python module to convert PDF files into text? I tried one
module Imodule ??? end class Some include Imodule def self.imethod puts original end end
module MyModule def my_method; 'hello'; end end class MyClass class << self include MyModule
Module M Class C end end What I need is something like: M.was_defined_here?(M::C) M.classes.include?(M::C)
My module currently imports the json module, which is only available in 2.6. I'd
GIN Module: public class InjectorModule extends AbstractGinModule { @Override protected void configure() { bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
My Module: bind( Translator.class ).to( TranslatorImpl.class ).in( Scopes.SINGLETON ); Now I expect to get
module M def f=(x) @f= x end def f @f end end class A
I have a module whose purpose is to define a class called nib. (and
module App::Models class Team < Base has_many :players [...] end class Player < Base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.