O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Laying Out Your Data

Once again, the principle of encapsulation will be broken. Let's assume your application needs to store records of some sort, and each record contains two fields: an id and a value. A very object-oriented approach is to define a Record class, as shown in Listing 4–12.

Listing 4–12. Record Class

public class Record {     private final short id;     private final short value;     // and possibly more          public Record(short id, short value) {         this.id = id;         this.value = value;     }     public final short getId() {         return id;     }     public final short getValue() {         return value;     }     public void doSomething() {         // do something here     } }

Now that the Record class is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required