Home » Developing U++ » UppHub » FTP class and reference example for U++
Re: FTP class and reference example for U++ [message #47859 is a reply to message #47858] |
Wed, 12 April 2017 23:05 |
|
Klugier
Messages: 1079 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello,
I am not tested this package, but i would like to notice small issue with the API design. The problem is that you need to pass too many arguments to the single function, if you want to change single argument like ascii. Let's take a look at below function:
int FtpAsyncGet(const String& remote_file, const String& local_file, const String& host, int port = 21, const String& user = Null,
const String& pass = Null, Event<int, int, String, int64, int64> progress = CNULL, bool active = false, bool ssl = false,
bool ascii = false);
This is the poor design, because the call will look like this:
FtpAsyncGet("remote.txt", "local.txt", "locaclhost, 21, Null, Null, CNull, false, false, true);
Looks terrible. Isn't it? In my opinion the good API has got maximum three parameters - otherwise it becomes hard to use by the client.
We can replace following code with the object approach (This is the example and I highly recommended to over thing this design):
int FtpAsyncGet(const FtpAssyncRequestConfig& config);
FtpAsyncGet(FtpAssyncRequestConfig("remote.txt", "local.txt", "locaclhost.txt").EnableAscii());
class FtpAssyncRequestConfig final
{
public:
FtpAssyncRequestConfig(const String& remote_file, const String& local_file, const String& host)
: // initialization ...
{}
// Get, Set, Enable interface...
private:
// private members
};
Much more easier to set the n-th parameter, but require additional work for the library provider.
______________
You could replace NAMESPACE_UPP with namespace Upp { and END_NAMESPACE_UPP with }. The NAMESPACE_UPP approach was deprecated since last release.
______________
The next problem I see in the code is the ordering problem - you should put public class interface at the top then private things (Ftp and DirEntry classes). This is the general rule mentioned in following documentation topic.
______________
This code review aims to improve the code quality.
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Wed, 12 April 2017 23:22] Report message to a moderator
|
|
|
|
|
FTP class and reference example for U++
By: Oblivion on Sun, 27 April 2014 18:11
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: mirek on Wed, 14 May 2014 09:25
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Wed, 12 April 2017 22:34
|
|
|
Re: FTP class and reference example for U++
By: Klugier on Wed, 12 April 2017 23:05
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Thu, 13 April 2017 08:17
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Thu, 13 April 2017 13:55
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Fri, 14 April 2017 23:45
|
|
|
Re: FTP class and reference example for U++
By: Klugier on Sat, 15 April 2017 19:23
|
|
|
Re: FTP class and reference example for U++
By: Klugier on Sat, 15 April 2017 19:38
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Sun, 16 April 2017 18:28
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Wed, 24 December 2014 12:06
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Thu, 25 December 2014 18:03
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Wed, 07 January 2015 20:52
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Tue, 20 January 2015 01:17
|
|
|
Re: FTP class and reference example for U++
By: unodgs on Tue, 07 July 2015 19:40
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: unodgs on Wed, 08 July 2015 10:20
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Sat, 18 March 2017 23:28
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Sun, 09 April 2017 02:32
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Sun, 23 April 2017 23:41
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Mon, 24 April 2017 19:01
|
|
|
Re: FTP class and reference example for U++
By: Klugier on Mon, 24 April 2017 22:12
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Tue, 25 April 2017 08:37
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: Tom1 on Fri, 16 June 2017 10:23
|
|
|
Re: FTP class and reference example for U++
|
|
|
Re: FTP class and reference example for U++
By: Oblivion on Mon, 02 April 2018 00:17
|
Goto Forum:
Current Time: Thu Sep 12 15:03:30 CEST 2024
Total time taken to generate the page: 0.03635 seconds
|