Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

That doesn't mean there's anything fundamentally wrong with the class design; there might be a situation somewhere down the road where I really do want to keep links for multiple left records. But probably most uses of the class will only have one left record and multiple right records. 

This also leads me to want some slightly different method names:

  • IsLinkedTo(long rightRecordID)
  • IsLinkBetween(long leftRecordID,long rightRecordID)
  • SetLinkTo(long rightRecordID)
  • SetLinkBetween(long leftRecordID,long rightRecordID)

The naming isn't strictly consistent (IsLink vs IsLinked) but I think it's a bit better grammatically. I added a LeftRecordID property to the class, which defaults to zero, and two new methods. I also renamed the existing methods:

Code Block
CML_Data_ManyToManyLinks                        Class,Type,Module('CML_Data_ManyToManyLinks.CLW'),Link('CML_Data_ManyToManyLinks.CLW',_CML_Classes_LinkMode_),Dll(_CML_Classes_DllMode_)
LinksQ                                              &CML_Data_ManyToManyLinks_DataQ
LeftRecordID                                        long
Construct                                           Procedure()
Destruct                                            Procedure()
IsLinkBetween                                       procedure(long leftRecordID,long rightRecordID),bool
IsLinkedTo                                          procedure(long rightRecordID),bool
SetLinkBetween                                      procedure(long leftRecordID,long rightRecordID)
SetLinkTo                                           procedure(long rightRecordID)
                                                End

The naming isn't strictly consistent (IsLink vs IsLinked) but I think it's a bit better grammatically. 

Here is the method code:

Code Block
CML_Data_ManyToManyLinks.IsLinkedTo             procedure(long rightRecordID)!,bool
    code
    return self.IsLinkBetween(self.LeftRecordID,rightRecordID)
    
CML_Data_ManyToManyLinks.IsLinkBetween          procedure(long leftRecordID,long rightRecordID)!,bool
    code
    self.LinksQ.LeftRecordID = LeftRecordID
    self.LinksQ.RightRecordID = rightRecordID
    get(self.LinksQ,self.LinksQ.LeftRecordID,self.LinksQ.RightRecordID)
    if not errorcode() then return true.
    return false
CML_Data_ManyToManyLinks.SetLinkTo              procedure(long rightRecordID)
    code
    self.SetLinkBetween(self.LeftRecordID,rightRecordID)
CML_Data_ManyToManyLinks.SetLinkBetween         procedure(long leftRecordID,long rightRecordID)
    code
    clear(self.LinksQ)
    self.LinksQ.LeftRecordID = LeftRecordID
    self.LinksQ.RightRecordID = rightRecordID
    add(self.LinksQ,self.LinksQ.LeftRecordID,self.LinksQ.RightRecordID)

I renamed the unit test procedure and added a second one:

Image Added

Next time I'll finish wiring the Links object into my UITest application, which no doubt will lead to some further code changes.