Fase di studio. Devo colmare le mie lacune relative alla programmazione ad oggetti, ai puntatori (quanti ricordi… è dalla quinta superiore che non riesco a farmeli entrare in testa) e quindi darmi pesantemente alle Qt. In realtà, ho già letto i primi due capitolo del manuale sulle Qt di cui parlavo qualche post fa e per ora è tutto abbastanza chiaro. L’esempio dei colliding mice, inoltre, potrei teoricamente già iniziare a modificarlo per adattarlo alle mie esigenze. Non sarebbe una cosa così impossibile, tutt’altro, ma visto che il tempo c’è voglio provare a fare le cose con calma.
Approfitto della situazione per citare, dal possente manuale “C++ How to Program, 5/E” di H.M. e P.J. Deitel, una splendida introduzione alla programmazione orientata agli oggetti:

We begin our introduction to object orientation with some key terminology. Everywhere you look in the real world you see objects – people, animals, plants, cars, buildings, computers and so on. Humans think in terms of objects. Telephones, houses, traffic lights, microwave ovens and water coolers are just a few more objects we see around us every day.
We sometimes divide objects into two categories: animate and inanimate. Animate objects are “alive” in some sense – they move around and do things. Inanimate objects, on the other hand, do not move on their own. Objects of coth types, however, have some things in common. Thay all have attributes (e.g., size, shape, color and weight), and they all exhibit behaviors (e.g., a ball rolls, bounces, inflates and deflates; a baby cries, sleeps, crawls, walks and blinks; a car accelerates, brakes and turns; a towel absorbs water). We will study the kinds of attributes and behaviors that software objects have.
Humans learn about existing objects by studying their attributes and observing their behaviors. Different objects can have similar attributes and can exhibit similar behaviors. Comparisons can be made, for example, between babies and adults and between humans and chimpanzees.
Object-oriented design (OOD) models software in terms similar to those that people use to describe real-world objects. It takes advantage of class relationships, where objects of a certain class, such as a class of vehicles, have the same characteristics – cars, trucks, little red wagons and roller skates have much in common. OOD takes advantage of inheritance relationships, where new classes of objects are derived by absorbing characteristics of existing classes and adding unique characteristics of their own. An object of class “convertible” certainly has the caracteristics of the more general class “automobile”, but more specifically, the roof goes up and down.
Object-oriented design provides a natural and intuitive way to view the sofware design process – namely, modeling objects by their attributes, behaviors and interrelationships just as we describe real-world objects. OOD also models communication between objects. Just as people send messages to one another (e.g., a sergeant commands a soldier to stand at attention), objects also communicates via messages. A bank account object may receive a message to decrease its balance by a certain amount because the customer has withdrawn that amount of money.
OOD encapsulates (i.e., wraps) attributes and operations (behaviors) into object – an object’s attributes and operations are intimately tied together. Objects have the property of information hiding. This means that objects may know how to communicate with one another across well-defined interfaces, but normally they are not allowed to know how other objects are implemented – implementation details are hidden within the object themselves. We can drive a car effectively, for instance, without knowing the details of how engines, transmissions, brakes and exhaust systems works internally – as long as we know how to use the accelerator pedal, the brake pedal, the steering wheel and so on. Information hiding, as we will see, is crucial to good software engineering.
Languages like C++ are object oriented. Programming in such a language is called object-oriented programming (OOP), and it allows computer programmers to implement an object-oriented design as a working software system. Languages like C, on the other hand, are procedural, so programming tends to be action oriented. In C, the unit of programming is the function. In C++, the unit of programming is the class from which objects are eventually instantiated (an OOP term for “created”). C++ classes contain functions that implement operations and data that implements attributes.
C programmers concentrate on writing functions. Programmers group actions that perform some common task into functions, and group functions to form programs. Data is certainly important in C, but the view is that data exists primarily in support of the actions that functions perform. The verbs in a system specification help the C programmer determine the set of functions that will work together to implement the system.
(H.M. Deitel, P.J. Deitel, “C++ How to Program, 5/E“)