CRITICAL
Rule Definition
In order to improve encapsulation in your custom event, it is better not to have public variable in your event. Prefer having read-only attributes, set by the event constructor.
Remediation
Prefer having non-public, read-only attributes, set by the event constructor.
Violation Code Sample
public class FirstCustomEvent
{
public var lala : String; // VIOLATION
public function FirstCustomEvent()
{
}
}
Fixed Code Sample
package {
import flash.events.Event;
public class CustomEvent extends Event
{
private var _field : String;
public function CustomEvent()
{
}
public function get field() : String {
return _field;
}
}
}
Reference
http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD
Related Technologies
Technical Criterion
Secure Coding - Encapsulation
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.