Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

One important difference between languages that provide syntax to encapsulate th

ID: 3710111 • Letter: O

Question

One important difference between languages that provide syntax to encapsulate the definition of user defined data types is whether the syntax requires the specification details to be separated from the implementation details. Ada requires such a separation. In Ada, the specification information must be placed in the package specification and the implementation details in the package body. Where must the representation details be placed? Compare Ada with both C++ and Java in this regard. Take and defend a position as to whether requiring separation of the specification and representation information for a data type is a good language design decision.

Explanation / Answer

ANS:-

Given that,

  One important difference between languages that provide syntax to encapsulate the definition of user defined data types is whether the syntax requires the specification details to be separated from the implementation details.

1)
Representation details are placed in the package body.

2)
In ADA, as discussed in previous question, it stored in package body.
But in c++ and java , Representation details are placed and declared in class level itself.
This is acheived by using constructor methods. Also we can modify the values from body using setter classes.


3)
Yes I recommend separation of specification and Representation.
This helps users to have a clear idea about declaration and Representations. By following this way programmer can know
all properties. It is a good decision, thats the reason this separation is avaiable several programming languages.


4)
small ada example: which specification is done outside and Representation in body .. by using changePhoneNumber method
---------------------

with number; use Records;

procedure example_details is
phone_number :Records

begin
changePhoneNumber(phone_number,1234567890)
end;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote