Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] renaming methods on table suggestions #46

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/tightdb/objc/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
-(TightdbQuery *)endgroup;
-(void)subtable:(size_t)column;
-(void)parent;
-(NSNumber *)count;
-(NSNumber *)count; // countNumberOfRows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or 'countMatchingRows', 'countNumberOfMatchingRows'

-(NSNumber *)countWithError:(NSError *__autoreleasing *)error;
-(NSNumber *)remove;
-(NSNumber *)remove; // removeRow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be multiple rows. So maybe 'removeRows'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for removeRows

-(NSNumber *)removeWithError:(NSError *__autoreleasing *)error;
-(NSNumber *)minimumWithIntColumn:(size_t)colNdx;
-(NSNumber *)minimumWithIntColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error;
Expand Down Expand Up @@ -75,29 +75,29 @@

/* Conditions: */

-(TightdbQuery *)column:(size_t)colNdx isBetweenInt:(int64_t)from and_:(int64_t)to;
-(TightdbQuery *)column:(size_t)colNdx isBetweenFloat:(float)from and_:(float)to;
-(TightdbQuery *)column:(size_t)colNdx isBetweenInt:(int64_t)from and_:(int64_t)to; // intValuesIncolumn: column areBetween: from and: to
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be intValuesIncolumn: column areGreaterThan: anInt andLessThan: anInt

-(TightdbQuery *)column:(size_t)colNdx isBetweenFloat:(float)from and_:(float)to; // floatValuesInColumn: column areBetween: from and: to
-(TightdbQuery *)column:(size_t)colNdx isBetweenDouble:(double)from and_:(double)to;
-(TightdbQuery *)column:(size_t)colNdx isBetweenDate:(time_t)from and_:(time_t)to;

-(TightdbQuery *)column:(size_t)colNdx isEqualToBool:(bool)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToInt:(int64_t)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToBool:(bool)value; // boolValuesInColumn: column areEqualTo: aBool
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-(TightdbQuery *)column:(size_t)colNdx isEqualToInt:(int64_t)value; // intValuesInColumn: column areEqualTo: anInt
-(TightdbQuery *)column:(size_t)colNdx isEqualToFloat:(float)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToDouble:(double)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToString:(NSString *)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToString:(NSString *)value caseSensitive:(bool)caseSensitive;
-(TightdbQuery *)column:(size_t)colNdx isEqualToString:(NSString *)value caseSensitive:(bool)caseSensitive; // stringValuesInColumn: column areEquaTo: aString withSameCase
-(TightdbQuery *)column:(size_t)colNdx isEqualToDate:(time_t)value;
-(TightdbQuery *)column:(size_t)colNdx isEqualToBinary:(TightdbBinary *)value;

-(TightdbQuery *)column:(size_t)colNdx isNotEqualToInt:(int64_t)value;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToInt:(int64_t)value; // intValuesInColumn: column areNotEqualTo: anInt
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToFloat:(float)value;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToDouble:(double)value;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToString:(NSString *)value;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToString:(NSString *)value caseSensitive:(bool)caseSensitive;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToDate:(time_t)value;
-(TightdbQuery *)column:(size_t)colNdx isNotEqualToBinary:(TightdbBinary *)value;

-(TightdbQuery *)column:(size_t)colNdx isGreaterThanInt:(int64_t)value;
-(TightdbQuery *)column:(size_t)colNdx isGreaterThanInt:(int64_t)value; // intValuesInColumn: column areGreaterThan: anInt
-(TightdbQuery *)column:(size_t)colNdx isGreaterThanFloat:(float)value;
-(TightdbQuery *)column:(size_t)colNdx isGreaterThanDouble:(double)value;
-(TightdbQuery *)column:(size_t)colNdx isGreaterThanDate:(time_t)value;
Expand Down Expand Up @@ -132,14 +132,14 @@

@interface TightdbQueryAccessorInt: NSObject
-(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query;
-(TightdbQuery *)columnIsEqualTo:(int64_t)value;
-(TightdbQuery *)columnIsEqualTo:(int64_t)value; // intValuesAreEqualTo: anInt
-(TightdbQuery *)columnIsNotEqualTo:(int64_t)value;
-(TightdbQuery *)columnIsGreaterThan:(int64_t)value;
-(TightdbQuery *)columnIsGreaterThanOrEqualTo:(int64_t)value;
-(TightdbQuery *)columnIsLessThan:(int64_t)value;
-(TightdbQuery *)columnIsLessThanOrEqualTo:(int64_t)value;
-(TightdbQuery *)columnIsBetween:(int64_t)from and_:(int64_t)to;
-(NSNumber *)minimum;
-(NSNumber *)minimum; // calcMinimum
-(NSNumber *)minimumWithError:(NSError *__autoreleasing *)error;
-(NSNumber *)maximum;
-(NSNumber *)maximumWithError:(NSError *__autoreleasing *)error;
Expand Down
96 changes: 48 additions & 48 deletions src/tightdb/objc/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
@interface TightdbTable: NSObject <NSFastEnumeration>
-(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len;

-(BOOL)isEqual:(TightdbTable *)other;
-(BOOL)isEqual:(TightdbTable *)other; //isEqualToTable

-(BOOL)isReadOnly;

Expand All @@ -98,7 +98,7 @@
* The specified table class must be one that is declared by using
* one of the table macros TIGHTDB_TABLE_*.
*/
-(BOOL)isClass:(Class)obj;
-(BOOL)isClass:(Class)obj; //Hm, not very clear. Maybe isOfType

/**
* If the type of this table is not compatible with the specified
Expand All @@ -111,56 +111,56 @@
-(id)castClass:(Class)obj;

/* Column meta info */
-(size_t)getColumnCount;
-(NSString *)getColumnName:(size_t)ndx;
-(size_t)getColumnIndex:(NSString *)name;
-(TightdbType)getColumnType:(size_t)ndx;
-(TightdbDescriptor *)getDescriptor;
-(TightdbDescriptor *)getDescriptorWithError:(NSError *__autoreleasing *)error;
-(size_t)getColumnCount; // columnCount
-(NSString *)getColumnName:(size_t)ndx; // nameOfColumn: column
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 'column' sufficiently describing? Is it a name? a number?
I suggest 'columnIndex' all over.
So this becomes 'nameOfColumnIndex' or even 'nameOfColumnWithIndex' to match the 'indexOfColumnWithName'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also makes it easier to add other methods that takes either a 'columnIndex' or 'coumnName' as parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we could consider using *columnWithColumnIndex: columnIndex for all methods that take the columnIndex as a parameter. That would make it very easy to make a corresponding *columnWithColumnName: columnName.
That would make a lot of methods a bit longer, so we could decide, that 'column' => use the columnIndex and 'columnName' => use the columnName

-(size_t)getColumnIndex:(NSString *)name; // indexOfColumnWithName: name
-(TightdbType)getColumnType:(size_t)ndx; //typeOfColumn: column
-(TightdbDescriptor *)getDescriptor; // descripter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

descriptor of what?
suggest 'tableDescriptor'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do we want to expose this method at the moment?

-(TightdbDescriptor *)getDescriptorWithError:(NSError *__autoreleasing *)error; //does it even need to be here?
-(BOOL)isEmpty;
-(size_t)count;
-(size_t)count; //rowCount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not. In NSArray it's called 'count'. Let's keep that.
We should match the naming of NSArray/NSMutableArray where it makes sense.
So we should review against that as priority one.
Maybe here also return an NSUInteger (need to check mapping to size_t)

-(TightdbCursor *)addEmptyRow;

/* Only curser based add should be public. This is just a temporaray way to hide the methods. */
/* TODO: Move to class extension. */
-(size_t)_addEmptyRow;
-(size_t)_addEmptyRows:(size_t)rowCount;

-(BOOL)clear;
-(BOOL)clearWithError:(NSError *__autoreleasing *)error;
-(BOOL)removeRowAtIndex:(size_t)ndx;
-(BOOL)removeRowAtIndex:(size_t)ndx error:(NSError *__autoreleasing *)error;
-(BOOL)clear; //clearRows
-(BOOL)clearWithError:(NSError *__autoreleasing *)error; //Hm, should throw exception
-(BOOL)removeRowAtIndex:(size_t)ndx; // removeRow: row
-(BOOL)removeRowAtIndex:(size_t)ndx error:(NSError *__autoreleasing *)error; //Hm, should throw exception
-(BOOL)removeLastRow;
-(BOOL)removeLastRowWithError:(NSError *__autoreleasing *)error;
-(BOOL)removeLastRowWithError:(NSError *__autoreleasing *)error; //Hm, should throw exception

-(TightdbCursor *)cursorAtIndex:(size_t)ndx;
-(TightdbCursor *)cursorAtIndex:(size_t)ndx; //:index
-(TightdbCursor *)cursorAtLastIndex;

-(TightdbCursor *)insertRowAtIndex:(size_t)ndx;
-(TightdbCursor *)insertRowAtIndex:(size_t)ndx; //:index

-(BOOL)insertRow:(size_t)ndx;
-(BOOL)insertRow:(size_t)ndx error:(NSError *__autoreleasing *)error;
-(BOOL)insertRow:(size_t)ndx; //:index
-(BOOL)insertRow:(size_t)ndx error:(NSError *__autoreleasing *)error; //Hm, should throw exception

-(BOOL)getBoolInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(int64_t)getIntInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(float)getFloatInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(BOOL)getBoolInColumn:(size_t)colNdx atRow:(size_t)ndx; // boolValueInColumn: column andRow: row
-(int64_t)getIntInColumn:(size_t)colNdx atRow:(size_t)ndx; //intValueInColumn: column andRow: row
-(float)getFloatInColumn:(size_t)colNdx atRow:(size_t)ndx; // same as above......
-(double)getDoubleInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(time_t)getDateInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(NSString *)getStringInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(TightdbBinary *)getBinaryInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(TightdbTable *)getTableInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(id)getTableInColumn:(size_t)colNdx atRow:(size_t)ndx withClass:(Class)obj;
-(TightdbMixed *)getMixedInColumn:(size_t)colNdx atRow:(size_t)ndx;
-(TightdbMixed *)getMixedInColumn:(size_t)colNdx atRow:(size_t)ndx; // same same

-(void)setInt:(int64_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setBool:(BOOL)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setInt:(int64_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; // setIntValue: anInt inColumn: column andRow: row
-(void)setBool:(BOOL)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; // same all the way down
-(void)setFloat:(float)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setDouble:(double)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setDate:(time_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setString:(NSString *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setBinary:(TightdbBinary *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setTable:(TightdbTable *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setMixed:(TightdbMixed *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx;
-(void)setMixed:(TightdbMixed *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; // same same


/* FIXME: It has been decided that the insert methods must not be a
Expand All @@ -169,9 +169,9 @@
* `addEmptyRow` and then setting each column value afterwards, or possibly
* by calling a method that takes all column values as arguments at
* once. */
-(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value;
-(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error;
-(BOOL)insertInt:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value;
-(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value; // insertBoolValue: aBool inColumn: column andRow: row
-(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error; //Hm, should throw exception
-(BOOL)insertInt:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value; // same same
-(BOOL)insertInt:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value error:(NSError *__autoreleasing *)error;
-(BOOL)insertFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value;
-(BOOL)insertFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value error:(NSError *__autoreleasing *)error;
Expand All @@ -184,7 +184,7 @@
-(BOOL)insertBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size;
-(BOOL)insertBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size error:(NSError *__autoreleasing *)error;
-(BOOL)insertDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value;
-(BOOL)insertDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value error:(NSError *__autoreleasing *)error;
-(BOOL)insertDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value error:(NSError *__autoreleasing *)error; // same same
-(BOOL)insertDone;
-(BOOL)insertDoneWithError:(NSError *__autoreleasing *)error;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all 'insert*()' should be removed. They are unsafe.


Expand All @@ -207,8 +207,8 @@

/* Searching */
/* FIXME: Should be findBool:(BOOL)value inColumn:(size_t)colNdx; */
-(size_t)findBool:(size_t)colNdx value:(BOOL)value;
-(size_t)findInt:(size_t)colNdx value:(int64_t)value;
-(size_t)findBool:(size_t)colNdx value:(BOOL)value; // findfirstBoolValue: aBool inColumn: column
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firstFirstBool: aBool inColumn: column is better. No need for Value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSArray uses 'indexOfObject', so something similar.

-(size_t)findInt:(size_t)colNdx value:(int64_t)value; // same same
-(size_t)findFloat:(size_t)colNdx value:(float)value;
-(size_t)findDouble:(size_t)colNdx value:(double)value;
-(size_t)findString:(size_t)colNdx value:(NSString *)value;
Expand All @@ -219,8 +219,8 @@
/* FIXME: The naming scheme used here is superior to the one used in
most of the other methods in this class. As time allows, this
scheme must be migrated to all those other methods. */
-(TightdbView *)findAllBool:(BOOL)value inColumn:(size_t)colNdx;
-(TightdbView *)findAllInt:(int64_t)value inColumn:(size_t)colNdx;
-(TightdbView *)findAllBool:(BOOL)value inColumn:(size_t)colNdx; // findAllRowsWithBoolValue: aBool inColumn: column
-(TightdbView *)findAllInt:(int64_t)value inColumn:(size_t)colNdx; // same same
-(TightdbView *)findAllFloat:(float)value inColumn:(size_t)colNdx;
-(TightdbView *)findAllDouble:(double)value inColumn:(size_t)colNdx;
-(TightdbView *)findAllString:(NSString *)value inColumn:(size_t)colNdx;
Expand All @@ -232,8 +232,8 @@
-(TightdbQuery *)whereWithError:(NSError *__autoreleasing *)error;

/* Indexing */
-(BOOL)hasIndex:(size_t)colNdx;
-(void)setIndex:(size_t)colNdx;
-(BOOL)hasIndex:(size_t)colNdx; // isIndexSetInColumn: column // columHasIndex: column
-(void)setIndex:(size_t)colNdx; // setIndexInColumn: column

/* Optimizing */
-(BOOL)optimize;
Expand All @@ -244,20 +244,20 @@

/* Aggregate functions */
/* FIXME: Should be countInt:(int64_t)value inColumn:(size_t)colNdx; */
-(size_t)countWithIntColumn:(size_t)colNdx andValue:(int64_t)target;
-(size_t)countWithFloatColumn:(size_t)colNdx andValue:(float)target;
-(size_t)countWithIntColumn:(size_t)colNdx andValue:(int64_t)target; // countRowsWithIntValue: antInt inColumn: column
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to make it more clear what is going on

-(size_t)countWithFloatColumn:(size_t)colNdx andValue:(float)target; // same same
-(size_t)countWithDoubleColumn:(size_t)colNdx andValue:(double)target;
-(size_t)countWithStringColumn:(size_t)colNdx andValue:(NSString *)target;
-(int64_t)sumWithIntColumn:(size_t)colNdx;
-(double)sumWithFloatColumn:(size_t)colNdx;
-(int64_t)sumWithIntColumn:(size_t)colNdx; // sumColumn: column containingIntValues // calcSumOnIntColumn : column
-(double)sumWithFloatColumn:(size_t)colNdx; // sumColumn: column containingFloatValues
-(double)sumWithDoubleColumn:(size_t)colNdx;
-(int64_t)maximumWithIntColumn:(size_t)colNdx;
-(int64_t)maximumWithIntColumn:(size_t)colNdx; //maximumValueInColumn: column containingIntValues // calcMaximumOnIntColumn: column
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maximumIntInColumn: column

-(float)maximumWithFloatColumn:(size_t)colNdx;
-(double)maximumWithDoubleColumn:(size_t)colNdx;
-(int64_t)minimumWithIntColumn:(size_t)colNdx;
-(float)minimumWithFloatColumn:(size_t)colNdx;
-(double)minimumWithDoubleColumn:(size_t)colNdx;
-(double)averageWithIntColumn:(size_t)colNdx;
-(double)averageWithIntColumn:(size_t)colNdx; // averageColumn: column containingIntValues
-(double)averageWithFloatColumn:(size_t)colNdx;
-(double)averageWithDoubleColumn:(size_t)colNDx;

Expand All @@ -275,16 +275,16 @@
@interface TightdbView: NSObject <NSFastEnumeration>
-(TightdbCursor *)cursorAtIndex:(size_t)ndx;

-(size_t)count;
-(size_t)count; // countRows
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rowCount is better, as no operation is happening. Same is suggested in Table

-(BOOL)isEmpty;
-(int64_t)get:(size_t)colNdx ndx:(size_t)ndx;
-(BOOL)getBool:(size_t)colNdx ndx:(size_t)ndx;
-(int64_t)get:(size_t)colNdx ndx:(size_t)ndx; // intValueInColumn: column andRow: row
-(BOOL)getBool:(size_t)colNdx ndx:(size_t)ndx; // same
-(time_t)getDate:(size_t)colNdx ndx:(size_t)ndx;
-(NSString *)getString:(size_t)colNdx ndx:(size_t)ndx;
-(void)removeRowAtIndex:(size_t)ndx;
-(void)clear;
-(TightdbTable *)getTable;
-(size_t)getSourceIndex:(size_t)ndx;
-(void)removeRowAtIndex:(size_t)ndx; // removeRow: row
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep removeRowAtIndex - it's similar in NSMutableArray

-(void)clear; // clearRows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest 'removeAllRows'. NSMutableArray has 'removeAllObjects'

-(TightdbTable *)getTable; // sourceTable
-(size_t)getSourceIndex:(size_t)ndx; // rowIndexInSourceTableForRow: row
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len;

/* Private */
Expand Down