access icon free struct.m

  • PDF

The paper patches another hole in MATLAB's default encapsulation by tailoring struct. The built-in version of struct returns the names and values of private member variables. In fact, struct 's default behavior represents a risky situation because clients can use it to gain access to private data. It needs to eliminate this possibility by developing a type-specific version of struct.m. As a bonus, a standard function that returns an object's public structure is broadly useful. The strategy of allowing MATLAB to perform most of the formatting requires a structure of public variables. At that time, public structure generation was coded directly in line and we could not easily make use of it in developer view. Further proliferation of in-line structure-generation code makes class extensions very tedious and error prone. Consolidating structure generation into one function makes a lot of sense. We can even take advantage of the tailored version of fieldnames so that even public names are not directly coded into struct.

Chapter Contents:

  • 7.1 struct
  • 7.2 Code Development
  • 7.3 The Test Drive
  • 7.4 Summary
  • 7.5 Independent Investigations

Inspec keywords: data privacy; object-oriented programming

Other keywords: object public structure; public structure generation; struct.m; data privacy; fieldnames; Matlab encapsulation; in-line structure-generation code; member variable

Subjects: Object-oriented programming; Data security

Preview this chapter:
Zoom in

struct.m, Page 1 of 2

| /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch7-1.gif /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch7-2.gif

Related content

This is a required field
Please enter a valid email address