Tagging database

24 views
Skip to first unread message

Michel Martens

unread,
Sep 14, 2011, 6:01:22 AM9/14/11
to band...@googlegroups.com
Hello guys,

In a different thread we mentioned a tagging database we are using. It's available here: https://gist.github.com/546a2aa661f976672964

For interacting with Bandicoot from Ruby, we are using this gem: https://rubygems.org/gems/rel

Do you find the code idiomatic enough? Are we missing something obvious or doing something wrong?

Thanks.

Julius Chrobak

unread,
Sep 20, 2011, 2:14:55 PM9/20/11
to band...@googlegroups.com
Hello guys,

Unfortunately, neither of us has experience with Ruby so we cannot comment too much about the client library. However, from the look of it it seems to do the work in a simple and elegant manner. 

In regards to the tagging database we could suggest the following improvements. There is an input parameter "o" of type "Object" in the functions "delete" and "related". In all these functions you apply the project operator to the parameter to take only the "obj" attribute. This operation can be omitted because:
  * the Object type has only one attribute "obj"
and
  * for every input parameter the project operator is applied implicitly to remove duplicate entries in the relation. 

In this specific case "o" parameter represents a result of "o project(obj)"  operation already. 
The "related" function is very interesting. While playing with it we came up with the following version:

fn related(o: Object): Object {
    tags := (taggings * o) project(tag);

    return (taggigns - o) * tags;
}

which does the same job. Please note it is not required to project the results of a function to match the defined function output type. This is done automatically by Bandicoot.


We're really happy to see this kind of code written in Bandicoot :)

Regards,
   Julius & Ostap

Michel Martens

unread,
Sep 20, 2011, 6:42:48 PM9/20/11
to band...@googlegroups.com
Hey there!

On Tue, Sep 20, 2011 at 8:14 PM, Julius Chrobak <ju...@bandilab.org> wrote:
> Hello guys,
> Unfortunately, neither of us has experience with Ruby so we cannot comment
> too much about the client library. However, from the look of it it seems to
> do the work in a simple and elegant manner.

Thank you :-)

> In regards to the tagging database we could suggest the following
> improvements. There is an input parameter "o" of type "Object" in the
> functions "delete" and "related". In all these functions you apply the
> project operator to the parameter to take only the "obj" attribute. This
> operation can be omitted because:
>   * the Object type has only one attribute "obj"
> and
>   * for every input parameter the project operator is applied implicitly to
> remove duplicate entries in the relation.
> In this specific case "o" parameter represents a result of "o project(obj)"
>  operation already.

Excellent, great piece of advice.

> The "related" function is very interesting. While playing with it we came up
> with the following version:
> fn related(o: Object): Object {
>     tags := (taggings * o) project(tag);
>     return (taggigns - o) * tags;
> }
> which does the same job. Please note it is not required to project the
> results of a function to match the defined function output type. This is
> done automatically by Bandicoot.

That's awesome, and good to know about the automatic project.

> We're really happy to see this kind of code written in Bandicoot :)

And we are very happy using Bandicoot, great work guys!

Reply all
Reply to author
Forward
0 new messages