In this video we will see what are the ingredients of object oriented programming. Let's start first by some details on the definition. The object-oriented programming is an approach to writing code that is cross-development environment that is independent and the language we choose to use. So it is valid for both Visual Basic and C # and Java and so on.
What did Microsoft in a few words and was making his own concepts of object oriented programming and create a new class of languages that Visual Basic. NET and C #, that first of all were directed to objects and then secondly that were compatible with the procedural programming that is used to program up to that time.
This is to avoid creating too sharp a separation between the past so the future by drawing a guideline and at the same time so the ability of developers to approach this new methodology in a gradual manner.
The main difference between procedural programming and object-oriented programming is that the first is to split the application domain in many functions or procedures, each of which can independently accomplish a small part of total work that will make the application .
Instead, the object-oriented programming requires a mental effort than us, a higher level of abstraction because it asks us to carry the code directly into the players that are involved in the application domain, then use them in providing the various interactions there may be.
Let's take a trivial example: create an application that after login as a customer allows us to create an order using procedural programming so we could write something like a function and a function as the login name and parameters agreed gives us the integer that represents the code of the user client code within the database. Once logged into the application so once authenticated user could submit a form to fill out in order to create a new order.
So we press the button save a reference to a function such as order creation function CreaOrdine. This function takes as a parameter to which to tie the user ID 's order that you will create and return a Boolean value and a true / false indicas that if the function was successful or not.
It 'easy to see in this case that these two procedures allow us to break more complex operations in subparts slightly smaller, thus easier to manage. In fact, the first procedure is carried out creates a whole second order and this is definitely better than having a single procedure that makes the first login and then save the new order in the sequence.
As anticipated in the first object-oriented programming but we do not have the concept of separating the problem into multiple smaller blocks.
We are going to use it directly to the actors involved in the problem that we solve the case that we took it to the client that is simple to s'autentica and then creates a new order. It 'quite simple to define the actors of the problem because the actors are just the order and customer.
These actors are called objects in a generic way. Objects are called precisely because they represent the various entities involved in the application.
These objects are nothing more than imaginary representations of whatever exists in reality of course, related to the problem we must solve. The objects that we create so the cars could be if we were to develop such an application for rental cars, or seats but if our program will handle the booking of the halls of a film or even film if it will be a ' video rental application is tied so on.
But in our specific example we could then create a customer object that is not more than the fictional representation of our real customer.
When this customer is going to log into our code, the object will call the client authentication method and then follow a cliente.autenticazione and when then the real customers will save and create an order, the customer object and within the Our code will invoke the method CreaOrdine, which returns a Boolean value instead.
An object of the second order type entity that comes into play in the order in fact, this object is the fictional representation of the order you just created. That way if we pay attention, we are only going to use the same objects that we used a simple spreadsheet to graph our problem and then we will have our objects and our customer order object that allows us to focus on more specifically on the problem by using an abstraction layer so definitely more to get an idea more concrete when we write our code we will no longer write to the compiler or a list of imperatives such as authentic customer support password pleasant d ' art is, and then creates the order is linked to you instead of you're going to describe a situation composed of a series of actions taken by the customer so variable that it is authentic and there is returned to the same customer's account is used in compilation of a new order and then in the creation of a new order object.