Best way to organize collections?

63 views
Skip to first unread message

Ditat

unread,
Jul 20, 2012, 9:13:41 PM7/20/12
to prot...@googlegroups.com
Let's say I have .proto like this:
 
message Dummy
{
    required Attributes DummyAttributes = 1;
    required string DummyString = 2;
    repeated Attribute DummyAttributes2 = 3;
}
message Attributes
{
    repeated Attribute List = 1;
}
message Attribute
{
    required string Name = 1;
    required string Value = 2;
}
 
What is better inside Dummy message? DummyAttributes or DummyAttributes2 ?

Christopher Smith

unread,
Jul 20, 2012, 9:46:13 PM7/20/12
to Ditat, prot...@googlegroups.com
Three points:

There isn't much value in your Attributes message, so DummyAttributes2 would be the way I'd go.

List is probably not an ideal name for an field, as it may overlap with other names depending on programming language.

Per the style guide, field names should be like_this, not LikeThis. The compiler will adjust it to fit your local language. Consequently, the right answer really should be: dummy_attributes_2.

--Chris
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/OTZR2bpElagJ.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Ivan Demkovitch

unread,
Jul 20, 2012, 9:49:18 PM7/20/12
to Christopher Smith, prot...@googlegroups.com

Valid points!

 

I use Attributes by itself also. So, I need that message. Question is should I use that collection message inside other messages where I may need collection of Attribute?

 

Naming… well. I use same .proto file in .NET and it all comes from POJO which I used for JSON so I’m going to leave this part as is..

Reply all
Reply to author
Forward
0 new messages