Does Swift have access modifiers?

In Objective-C instance data can be public, protected or private. For example:@interface Foo : NSObject{ @public int x; @protected: int y; @private: int z; }-(int) apple;-(int) pear;-(int) banana;@endI haven't found any mention of access modifiers in the Swift reference. Is it possible to limit the visibility of data in Swift?...Read more

application structure - Access Modifiers ... Why?

Ok so I was just thinking to myself why do programmers stress so much when it comes down to Access Modifiers within OOP.Lets take this code for example / PHP!class StackOverflow{ private var $web_address; public function setWebAddress(){/*...*/}}Because web_address is private it cannot be changed by $object->web_address = 'w.e.', but the fact that that Variable will only ever change is if your programme does $object->web_address = 'w.e.';If within my application I wanted a variable not to be changed, then I would make my application...Read more

Why there is no access modifier named "Visible"?

In OO languages like C++, Java or C#, there are access modifiers like public, private, protected. Some languages have other modifiers like internal. All of them specifies who can access a certain variable or method. And for variables, this term access means both the ability to read and modify. But the most common scenario for accessing variable is making it publicly visible to others but keeping the ability to modify within the class. And this is achieved through many tactics using getter setter etc.My question is, why don't we have a access mo...Read more

access modifiers - what exactly does the word "client" means here?

i am reading a book and it says: "Two access modifiers you have looked at so far are public and private. If amethod or property of the base class is exposed as public, it is accessible by both the derived class andany client of the derived class. If you expose the property or method of the base class as private, it is notaccessible directly by the derived class or the client."what does the 'client' means?...Read more

access modifiers - When to sensibly use public variable in an OOP language?

After I learned to properly use private protected abstract sealed in a language like C# I found no reason to make a variable public ever again.An interface to the variable is usually a public method if it is an action/verb (e.g. Car.Move()), or if it is a value/property of the class then I use property with a public getter and a private setter. (e.g. Car.Color which can only change on creation, but accessible anytime.)If it is just a collection of values, its field still make more sense to be private and only assignable on creation via the cons...Read more

How to motivate adaptive an shifting class access modifiers

At the new client, we had a discussion regarding access modifiers for classes, methods, members etc. One opinion was to keep things as private as possible, only allowing for protected (internal, public) level when necessary. The opposite opinion was to "let things flow" and apply public access level throughout all (or at the very least most) of the classes.The argument for the former is to prevent misusage by malicious and/or ignorant developers. Also, a general just-in-case precaution.The argument for the latter is the ease of usage powered by...Read more