开发者

Android, a not-so-simple simplexml question

开发者 https://www.devze.com 2023-03-11 07:15 出处:网络
I need to define my android \"Estates\" class using simplexml package from an xml like this one: String xml = \"

I need to define my android "Estates" class using simplexml package from an xml like this one:

String xml = "
<?xml version="1.0" encoding="utf-8"?>
    <estates>
       <000>
           <id>12345678</id>
           <description>estate one&开发者_运维技巧lt;/description>
       </000>
       <001>
           <id>23456789</id>
           <description>estate two</description>
       </001>
    </estates>
";

Estates estates = serial.read(Estates.class, xml);

How should I define my class?

Should it be named "Estates" or "Estate"?

Sorry, but I can't yet get a feeling with simplexml... ;-(


You're asking "should I name my class plural or singular" and you're saying in the title that your question is not so simple? Since the name of a class you create is inconsequential to the execution of your program I'd say it's a very simple question.

That being said, my opinion is that you name the class "Estate" and you reduce its functionality to not assume more than one id/description tuple, and in order to use more than one (such as the 000 and 001 in your example), you use multiple Estate objects in a container (array, List, etc.).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号