Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Interface, Attribute and visibility

Former Member
0 Likes
1,599

Dear all,

how can I make my attributes protected or privat in an interface. The class setting up the interface has then the getter and setter methods for the attributes (even the interface has the methods too).

Kind regards

Roman

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,052

Why would you need to do that? I am not sure you can do that because all interface's components belong to public section of class in which they are implemented.

Message was edited by: Tomasz Kozerski

4 REPLIES 4
Read only

Former Member
0 Likes
1,053

Why would you need to do that? I am not sure you can do that because all interface's components belong to public section of class in which they are implemented.

Message was edited by: Tomasz Kozerski

Read only

0 Likes
1,052

As far as I understand interfaces they give me a "template" for an implemantation. So everything, the methods and attributes should be public, protected or private. So if they just "template" the visible part (public) this would make sense.

Ok do I think right, the interface only holds the public components?

Kind regards

Roman

Read only

0 Likes
1,052

Yes, they are a 'public' face or template and belog to public section of a class.

Read only

luc_chalifour
Product and Topic Expert
Product and Topic Expert
0 Likes
1,052

Hi Roman,

An interface should not be pictured as a template, but more as a communication channel for different objects with common characteristics. If you want a template to create other classes, with private/protected attributes, and methods, I recommend that you use an abstract class. An abstract class will allow you to declare attributes and methods without code. Of course, you cannot instantiate an abstract class; you have to create another class that inherits from it.

Cheers,

Luc