HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

API for SQLConnect Library

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
apisqlconnectforlibrary

Problem

I've designed a library for connecting Objective-C (and now Swift) apps to Microsoft SQL Server 2005+. (I believe there are other databases it works with, but I've only tested with MSSQL.)

The project is available on Github here, and while users are fully capable of downloading the uncompiled project, my recommended option is downloading the compiled project along with the necessary headers.

I am interested in a review of the library's API.

Here it is:

SQLConnect.h

@import Foundation;

NSString * const SQLCONNECTION_VERSION_NUM;

#import "SQLConnection.h"

#import "SQLViewController.h"
#import "SQLTableViewController.h"
#import "SQLCollectionViewController.h"
#import "SQLSettings.h"

BOOL isNull(id obj);
id nullReplace(id obj, id replacement);


SQLConnection.h

```
#import "SQLConnectionDelegate.h"
#import "SQLSettings.h"

@interface SQLConnection : NSObject

#pragma mark Properties
/**
* Indicates whether or not the database is currently connected
*/
@property (nonatomic,assign,readonly) BOOL connected;

/**
* The database server to use. Supports server, server:port, or server\instance (be sure to escape the backslash)
*/
@property (nonatomic,strong) NSString *server;

/**
* The database username
*/
@property (nonatomic,strong) NSString *username;

/**
* The database password
*/
@property (nonatomic,strong) NSString *password;

/**
* The database name to use
*/
@property (nonatomic,strong) NSString *database;

/**
* Delegate to handle callbacks
*/
@property (nonatomic,weak) id delegate;

/**
* The queue to execute database operations on. A default queue name is used, but can be overridden.
*/
@property (nonatomic,strong) NSOperationQueue *workerQueue;

/**
* The queue for delegate callbacks. Uses current queue by default, but can be overridden.
*/
@property (nonatomic,strong) NSOperationQueue *callbackQueue;

/**
* The character set to use for converting the UCS-2 server results. Default is UTF-8. Can be overridden to an

Solution

A few notes:

-
I feel like some of your properties should have the readonly attribute applied to them. Do we really want the API users to have the ability to change the username, password, or server variables after initialization?

@property (nonatomic, strong, readonly) NSString *server;


If you do really want them to have that ability, I would add a method so that those variables could be set to different values at the same time.

-
You have the phrase "Required." in a lot of your @param comments. As a frequent user of many APIs, I always assume that a valid parameter value is required unless told otherwise. So you only need to tell me what parameters are optional in your documentation (which is just one, that I could see).

-
You forgot that little extra * on some of your comment lines. This is important, since this is needed for Doxygen to parse these comment blocks (you are using Doxygen, correct?).

/*  <---- need two * right there
 *
 *  Required delegate method to handle successful execution of a SQL command on the server
 *
 *  @param  connection  The SQLConnection instance which handled the execution
 *  @param  results     The results, if any, returned from the database
 */

Code Snippets

@property (nonatomic, strong, readonly) NSString *server;
/*  <---- need two * right there
 *
 *  Required delegate method to handle successful execution of a SQL command on the server
 *
 *  @param  connection  The SQLConnection instance which handled the execution
 *  @param  results     The results, if any, returned from the database
 */

Context

StackExchange Code Review Q#60648, answer score: 8

Revisions (0)

No revisions yet.