Access Modifier

4. Juni 2024 10:57

Welche Unterschied gibt zwischen Local und Protected?

when ich die MS Doku lese:

Local: The field can be accessed only by code in the same table or table extension where the field is defined.
Note: Applies to table fields only.

Protected: The field can be accessed only by code in the same table or table extensions of that table.
Note: Applies to table fields only.

Dank im Voraus

Re: Access Modifier

4. Juni 2024 11:05

Hallo,

das ist hier wie bei anderen Programmiersprachen auch.

local meint Zugriff lokal zur Quell-Datei also "where it is defined"
protected meint Zugriff durch alle lokalen und davon abgeleiteten Objekte ( also auch von TableExtensions)

Gruß Fiddi

Re: Access Modifier

4. Juni 2024 11:21

Danke für die Erklärung.

So wenn ich richtig verstanden habe, in protected definition wäre bessere "and" statt "or" benutzen.

EDIT

Ich dachte, ich hätte es verstanden, aber ich habe gerade zwei Beispiele gelesen und bin jetzt wieder verwirrt

Scenario 1:
You are extending a base table that represents products in an inventory system. In your extension, you are adding a field to store additional product-speific information that is relenat only within your module.
Wich access mod?
Answer: Local --> The new field is specific to the extended table and is not intended for use outside of it. Making it as Local ensure that it is only accessible within the same table or table extension.

Scenario 2:
Your application is a Base page that dispays customer information. You are creating a page extension to add a new field that shows a custom indicator specific to your department´s requirements.
Which access mod?

Answer: Protected --> The new field in the page extension is relevant to your departement´s specific requirements. Making it as Protected allows it to be accessible within the base page and its extension but not directly from othe moules.

Daher sind sowohl Local als auch Protected von beiden Tabellen und ihren extension aus zugänglich (und daher verstehe ich den Unterschied zwischen Local und Protected immer noch nicht). Außerdem in der MS-Dokumentation steht: Note: Applies to table fields only und Beispiel 2 ist über Page

Sorry, aber ich habe vor etwa einem Monat angefangen und habe keine Erfahrung mit anderen Programmiersprachen.

Re: Access Modifier

4. Juni 2024 12:21

Hallo,

das "or" ist schon richtig.

Wie ich oben schon schrieb ist "Local" nur in der Datei (besser Objekt) verfügbar, in der es definiert wurde.

D.h. benutzt du "local" in einer Tabelle ist es lokal zu dieser Table, benutzt du es in einer TableExtension ist es lokal zu eben dieser. :mrgreen:

Gruß Fiddi