OpenTraining

 

 
Segna il video come già completato  
Se vuoi, sarebbe utile un giudizio su questo video    
In questo video vedremo quali sono gli ingredienti della programmazione ad oggetti. Partiamo innanzitutto da alcuni dettagli sulla definizione. La programmazione ad oggetti è un approccio alla scrittura del codice che risulta trasversale cioè indipendente dall'ambiente di sviluppo e dal linguaggio che decidiamo di utilizzare. Quindi è valido sia per Visual Basic che per C# che per Java e così via. Ciò che ha fatto Microsoft in poche parole e stato fare propri concetti della programmazione ad oggetti e creare così una nuova classe di linguaggi cioè Visual Basic .NET e C#, che prima di tutto fossero orientati ad oggetti e poi secondo luogo che fossero compatibili con la programmazione procedurale cioè la programmazione utilizzata fino ad allora. Questo per evitare di creare una separazione troppo netta tra il passato del futuro tracciando così una linea guida e allo stesso tempo tanto la possibilità di sviluppatori di approcciarsi questa nuova metodologia in maniera graduale. La differenza principale tra la programmazione procedurale e la programmazione ad oggetti è che la prima consiste nel suddividere il dominio dell'applicazione in tanti funzioni o procedure ognuna delle quali in grado di compiere autonomamente una piccola parte del lavoro che andrà fare in totale l'applicazione. Invece la programmazione ad oggetti ci richiede uno sforzo mentale diverso, un livello di astrazione superiore perché infatti ci chiede di trasportare direttamente all'interno del codice gli attori che sono coinvolti nel dominio dell'applicazione, quindi utilizzarli prevedendo tra di loro le varie interazioni che ci possono essere. Facciamo un esempio banale: creare un'applicazione che dopo aver effettuato login come cliente ci consente di creare un ordine utilizzando quindi una programmazione di tipo procedurale potremmo scrivere una cosa del genere quindi una funzione una funzione di login e dato nome e cognome concordati dei parametri ci restituisce l'intero che rappresenta il codice dell'utente il codice del cliente all'interno del database. una volta loggato quindi una volta autenticato all'interno dell'applicazione potremmo presentare all'utente un form da compilare in modo tale da creare un nuovo ordine. Pertanto alla pressione del pulsante salva avremmo un richiamo ad una funzione di creazione dell'ordine ad esempio la funzione CreaOrdine. Questa funzione accetta come parametro l'identificativo dell'utente al quale legare l' ordine che si andrà creare e restituisce un valore booleano e un true/false che ci indicas se la funzione ha avuto successo o meno. E' semplice notare in questo caso che queste due procedure ci consentono di spezzare operazioni più complesse in sotto parti leggermente più piccole, quindi più facili da gestire. Infatti la prima procedura effettuano viene intera seconda crea un ordine e questo è decisamente meglio rispetto ad avere una procedura unica che faccia prima il login e poi salvi il nuovo ordine in sequenza. Come anticipato prima invece nella programmazione ad oggetti non abbiamo più il concetto di separare il problema in più blocchi più ridotti. Andremo infatti ad utilizzare direttamente gli attori che intervengono all'interno del problema che non vogliamo risolvere il caso che abbiamo preso è ad è semplice quello della cliente che s'autentica e quindi crea un nuovo ordine. E' abbastanza semplice definire gli attori del problema infatti gli attori sono proprio l'ordine e di cliente. Questi attori sono chiamati in maniera generica oggetti. Sono chiamati oggetti perché appunto rappresentano le varie entità che intervengono nell'applicazione. Questi oggetti non sono altro che rappresentazioni immaginarie di qualsiasi cosa esista nella realtà naturalmente attinente al problema che dobbiamo risolvere. Gli oggetti che creeremo quindi potrebbero essere delle auto se dovessimo sviluppare ad esempio un'applicazione per il noleggio di vetture, oppure posti a sedere se invece nostro programma andrà gestire la prenotazione delle sale di un cinema, oppure ancora film se si tratterà di un'applicazione è legata videonoleggio così via. Ma nel nostro esempio specifico potremmo quindi creare un oggetto cliente che non è altro che la rappresentazione immaginaria del nostro cliente reale. Quando questo cliente andrà ad effettuare il login nel nostro codice, l'oggetto cliente chiamerà il metodo di autenticazione quindi e seguiremo un cliente.autenticazione e quando quindi il vero cliente andrà salvare e a creare un ordine, l'oggetto cliente e all'interno del nostro codice richiamerà il metodo CreaOrdine, che ritornerà invece che un valore booleano. Un oggetto di tipo ordine nella seconda entità che entri in gioco nell'applicazione questo oggetto ordine infatti è la rappresentazione immaginaria dell'ordine appena creato. In questo modo se ci facciamo caso, non facciamo altro che andare ad utilizzare gli stessi oggetti che avremmo utilizzato in uno schema su carta per rappresentare graficamente il nostro problema quindi e avremo i nostri oggetti cliente e il nostro oggetto ordine questo ci consente di concentrarci in maniera più specifica sul problema utilizzando un livello di astrazione sicuramente maggiore tanto per farci un'idea ancora più concreta quando andremo a scrivere il nostro codice non dovremo più né scrivere al compilatore una lista di imperativi come ad esempio autentica cliente con aiuti ameni password d'arte è e è successivamente crea l'ordine legato all'utente di utente al contrario andremo a descrivere una situazione composta da una serie di azioni compiute da variatore quindi il cliente che sia autentica e viene restituito lì di cliente lo stesso di cliente viene utilizzato nella compilazione di un nuovo ordine quindi nella creazione di un nuovo oggetto ordine.
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.