--- In flexcoders@yahoogroups.com, "Doug Lowder" <[EMAIL PROTECTED]> wrote:
>
> Nope, I didn't misinterpret.  I know TestVO is a Java class 
> (probably with a Flex counterpart class), and the way the Java class 
> is coded can definitely have an effect when it is accessed from 
> Flex.  It isn't a case of "correctness", but a case of what Flex 
> expects from Java classes.  You can test this all out yourself by 
> implementing multiple constructors and/or declaring the properties 
> as private in your Java class.
> 

Ok, I hate that I keep dragging this out but I also don't like when
people promote bad coding conventions. Here is a simple example java
bean, taken from Adobe.

package flex.testdrive.store;

public class Product {

    private int productId;
    private String name;
    private String description;
    private String image;
    private String category;
    private double price;
    private int qtyInStock;
    
    public Product() {
        
    }
    
    public Product(int productId, String name, String description,
String image, String category, double price, int qtyInStock) {
                this.productId = productId;
                this.name = name;
                this.description = description;
                this.image = image;
                this.category = category;
                this.price = price;
                this.qtyInStock = qtyInStock;
        }

    public String getCategory() {
                return category;
        }
        public void setCategory(String category) {
                this.category = category;
        }
        public String getDescription() {
                return description;
        }
        public void setDescription(String description) {
                this.description = description;
        }
        public String getImage() {
                return image;
        }
        public void setImage(String image) {
                this.image = image;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public double getPrice() {
                return price;
        }
        public void setPrice(double price) {
                this.price = price;
        }
        public int getProductId() {
                return productId;
        }
        public void setProductId(int productId) {
                this.productId = productId;
        }
        public int getQtyInStock() {
                return qtyInStock;
        }
        public void setQtyInStock(int qtyInStock) {
                this.qtyInStock = qtyInStock;
        }

}

You see all of the properties are private with public getters and
setters.  When the Flex Data Services transfers the object to the
Flash Player it has all of the expected properties. This is proper,
"correct" and safe coding. Adobe even recommends this kind of coding
in ActionScript, which is why you use the set and get methods.

Paul



Reply via email to