![learn scala learn scala](https://media.geeksforgeeks.org/wp-content/uploads/20191122114409/scala21.png)
About this post and the Learning Scala series In the next part we’ll (finally ?) get to look at some of Scala’s functional programming features as we look at pattern matching. However, I think Scala’s implementation is much more elegant as it doesn’t require a whole separate concept in the language. class Person ) the concepts discussed in this part isn’t exactly mind blowing.
![learn scala learn scala](https://miro.medium.com/max/2000/1*4aVRzGXAFk1FVUtKq3gcfQ.jpeg)
Let’s take a look at a simple class, Person, with a single member, name. In Scala however both a method named bar and an attribute (a val or a var) named bar can be accessed using the same notation, foo.bar. Java and C# (disregarding C#’s properties) does not follow the Uniform Access Principle as a field named bar of an object foo is accessed using one notation (foo.bar) while a method named bar is accessed with another notation (foo.bar()).
![learn scala learn scala](https://cdn-images-1.medium.com/max/2600/1*SOPKKXCe9MS974f9lRJlGA.jpeg)
It states that "All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation.” In practice this means that the notation used to access a feature of a class shouldn’t differ depending on whether it’s an attribute or a method.
#LEARN SCALA SOFTWARE#
The Uniform Access PrincipleĪs many other principles and wisdoms in the world of programming the Uniform Access Principle was first published by Bertrand Meyer in Object-Oriented Software Construction. In the process we’ll also learn about how vals and vars are implemented behind the scenes. In this part of the Learning Scala series we’ll take a quick look at what the Uniform Access Principle is and how Scala implements it.