Uplay Services and Client Core in C++ Client Interface in CEF (Chromium Embedded Framework) Interface in HTML/CSS/JS (Presentation Logic Only) Backend Portal to manage all this
Uplay Multithread all the things. Blocking operations are a no no! Scaling is very hard. Especially in a system like this. Almost no comments in the code. If it’s not readable as code you redo it.
Uplay Multithread all the things. Blocking operations are a no no! Scaling is very hard. Especially in a system like this. Almost no comments in the code. If it’s not readable as code you redo it. Very pragmatic programming style. At this scale you don’t follow the rules.
Uplay Multithread all the things. Blocking operations are a no no! Scaling is very hard. Especially in a system like this. Almost no comments in the code. If it’s not readable as code you redo it. Very pragmatic programming style. At this scale you don’t follow the rules. There is no book called “How to deal with all the users in the world at the same time”
Object Oriented Programming Don’t* *It’s a tool like anything else. Use it when applicable. If it solves your problems. Good. Otherwise you should question it!
Let’s go back in time In the old old time of far far away, the idea of software was much simpler. You had data. You had functions. The functions modified the data and returned new data.
Let’s go back in time In the old old time of far far away, the idea of software was much simpler. You had data. You had functions. The functions modified the data and returned new data. End of story.
This is fine This style is called functional programming, procedural programming or structured programming (depending how you look at it). But as software complexity grows, this style of programming can grow out of hand, very fast.
This is fine This style is called functional programming, procedural programming or structured programming (depending how you look at it). But as software complexity grows, this style of programming can grow out of hand, very fast. There is no sense of structure (hah) and over time it gets difficult to get work done.
History Even though some of the concepts of OOP date back to the 50s, it’s not until around 1965 when the a lot of the common concepts of OOP appear in the language Simula.
History Even though some of the concepts of OOP date back to the 50s, it’s not until around 1965 when the a lot of the common concepts of OOP appear in the language Simula. These concepts influenced some languages but it wasn’t until the mid 1980 when language designers started to take notice. C++, Objective- and Eiffel were one of the first ones.
History Even though some of the concepts of OOP date back to the 50s, it’s not until around 1965 when the a lot of the common concepts of OOP appear in the language Simula. These concepts influenced some languages but it wasn’t until the mid 1980 when language designers started to take notice. C++, Objective- and Eiffel were one of the first ones. And in the 90s OOP became the tour de force in languages like Java.
Enough history old man! So what is OOP? What even is the point? OOP is usually defined by three concepts. Which I will try to explain, and then show with examples how they benefit you.
Enough history old man! So what is OOP? What even is the point? OOP is usually defined by three concepts. Which I will try to explain, and then show with examples how they benefit you. But first. Let’s talk about OOP generally.
Let’s see this in C++ Objects in C++ are defined by classes (or structures). Classes are ways to group together functions and variables. To create an object, we create a variable that is of the Class’s type.
Let’s see this in C++ Objects in C++ are defined by classes (or structures). Classes are ways to group together functions and variables. To create an object, we create a variable that is of the Class’s type. But even with this simple idea, we gain a lot of power.
Constructor A constructor is a function that is run only once, at the initialization of an object. An object is fully formed when a constructor has finished running.
Constructor A constructor is a function that is run only once, at the initialization of an object. An object is fully formed when a constructor has finished running. They have no name and cannot be called directly.
Destructor “A destructor is a special member function that is called when the lifetime of an object ends.” “The purpose of the destructor is to free the resources that the object may have acquired during its lifetime.”
Single responsibility principle “A class should have only a single responsibility” or “A class should have only one reason to change” Animal shouldn’t be responsible for Eat(); and GrassGrow(); that is just going to make it increasingly harder to use and maintain.
Inheritance Is the idea where a class inherits properties and variables from a parent class. The child class is considered a subtype of the parent class. This is a way to extend the functionality of the parent class and creates a certain kind of hierarchy.
Liskov substitution principle “If S is a subtype of T, then objects of type T may be replaced with objects of type S” In our case. If you need an Animal, you can use a Cat or a FoxHound, they both 100% work as Animals.
Liskov substitution principle “If S is a subtype of T, then objects of type T may be replaced with objects of type S” In our case. If you need an Animal, you can use a Cat or a FoxHound, they both 100% work as Animals. But if you need a Cat, you can’t use a FoxHound.
Dog is an Animal. Animal is not a Dog When initializing the class Animal, the compiler will allocate memory for an Animal. In our case, it will allocate for the integer stored within animal.
Dog is an Animal. Animal is not a Dog When initializing the class Animal, the compiler will allocate memory for an Animal. In our case, it will allocate for the integer stored within animal. When trying to store a Dog in the memory space allocated for Animal, then there isn’t enough space for barkCount.
Dog is an Animal. Animal is not a Dog When initializing the class Animal, the compiler will allocate memory for an Animal. In our case, it will allocate for the integer stored within animal. When trying to store a Dog in the memory space allocated for Animal, then there isn’t enough space for barkCount. This is called Slicing
Dog is an Animal. Animal is not a Dog When initializing the class Animal, the compiler will allocate memory for an Animal. In our case, it will allocate for the integer stored within animal. When trying to store a Dog in the memory space allocated for Animal, then there isn’t enough space for barkCount. This is called Slicing The vector is storing memory for Animal. Nothing more.
Pointers to the rescue If you would store in the vector a pointer to Animal (either raw/unique/shared), then the actual memory stored within the vector is a pointer. A pointer can’t slice because they are always of the same size.
Pointers to the rescue If you would store in the vector a pointer to Animal (either raw/unique/shared), then the actual memory stored within the vector is a pointer. A pointer can’t slice because they are always of the same size. If you then allocate memory on the heap for a Dog but store it in a Animal pointer, no slicing will occur. Because you explicitly allocated memory for a Dog on the heap but point to it.
But dogs eat in a special way Yes yes dogs eat. But they eat so much, and they slobber all over. I like how all Animals have an Eat(); function and it’s useful to have one function you can call. But I need a way to change how Eat(); is implemented, but only for Dogs.
Open–closed principle "Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" Here we have done this in two ways. Once with inheritance and in another way with overriding virtual functions.
Is this magic? Wait wait! How did the for loop know which Eat(); function to call? The variable in the loop is Animal* but it’s able to call the Dog version of the function?
Is this magic? Wait wait! How did the for loop know which Eat(); function to call? The variable in the loop is Animal* but it’s able to call the Dog version of the function? I call heresy!
No, it’s not magic... When you have a basic class, with no virtual functions. When that class is allocated on the stack, only the member variables are allocated to that stack.
No, it’s not magic... When you have a basic class, with no virtual functions. When that class is allocated on the stack, only the member variables are allocated to that stack. So when someone calls a function, it’s almost like someone is calling a freestanding function.
Virtual Virtuality But when you have at least one virtual function in your class a different thing happens. A pointer to a virtual function table is allocated. This pointer is used when calling virtual functions.
Virtual Virtuality But when you have at least one virtual function in your class a different thing happens. A pointer to a virtual function table is allocated. This pointer is used when calling virtual functions. When a class of type Animal is created, the virtual function entry for Eat(); points to the Animal version of Eat. And when you allocate for Dog, it points to the Dog implementation of Eat
Polymorphism Is the idea where the same interface can be used but against many different objects. In the example we just did, we were able to use the interface of Animal but the underlying object could be a Dog without us ever knowing it.
Abstract Classes / Interfaces So thinking about our class Animal against the real world. It actually doesn’t make sense to create an animal by itself. It always has to be a certain kind of animal.
Abstract Classes / Interfaces So thinking about our class Animal against the real world. It actually doesn’t make sense to create an animal by itself. It always has to be a certain kind of animal. This can be solved by creating an Abstract Class or what is often called an Interface.
Abstract Classes / Interfaces When we do this, it will not work to create a variable of the type Animal. This is because there has been no implementation of the function Eat(); and any derived class has to implement that function if they want to be usable.
Don’t play with my toys! Now we have another problem. In the last example the user was able to refer to the numberOfMeals variable directly. He could even change it if he wanted.
Don’t play with my toys! Now we have another problem. In the last example the user was able to refer to the numberOfMeals variable directly. He could even change it if he wanted. If that is our design, then fine. But this can cause someone to write code that changes the state of our class to something invalid.
C++ Access Specifiers C++ implements three types of Access Specifiers. They apply to functions and variables (any member of the class). public: Anyone can access the member. Same as we had before.
C++ Access Specifiers C++ implements three types of Access Specifiers. They apply to functions and variables (any member of the class). public: Anyone can access the member. Same as we had before. protected: Only accessible inside of Base and Derived classes. Not publically.
C++ Access Specifiers C++ implements three types of Access Specifiers. They apply to functions and variables (any member of the class). public: Anyone can access the member. Same as we had before. protected: Only accessible inside of Base and Derived classes. Not publically. private: Only accessible inside of Base. Not derived classes and not publically.
Clean Interfaces This allows you to design well made interfaces towards classes that are then enjoyable to use correctly and hard to use incorrectly. Also. The only difference between struct and class is that a struct is by default public and a class is by default private. There is no other difference between them.
Encapsulation “A language mechanism for restricting direct access to some of the object's components.” Encapsulation is often called an “information hiding mechanism” where the user of the system is not aware of the underlying complexity but can still use the system.
Those are the three concepts Inheritance: “A class inherits properties and variables from a parent class.” Polymorphism: “A common interface can be used against many different underlying objects.”
Those are the three concepts Inheritance: “A class inherits properties and variables from a parent class.” Polymorphism: “A common interface can be used against many different underlying objects.” Encapsulation: “A language mechanism for restricting direct access to some of the object's components.”
This is just the beginning I have only scratched the surface of OOP. There are countless design patterns that use the flexibility of OOP to solve commonly encountered problems.
This is just the beginning I have only scratched the surface of OOP. There are countless design patterns that use the flexibility of OOP to solve commonly encountered problems. Aspects like Inheritance vs Composition are important as well.
This is just the beginning I have only scratched the surface of OOP. There are countless design patterns that use the flexibility of OOP to solve commonly encountered problems. Aspects like Inheritance vs Composition are important as well. But let’s go back to an earlier slide I had.
Object Oriented Programming Don’t* *It’s a tool like anything else. Use it when applicable. If it solves your problems. Good. Otherwise you should question it!
Let’s make a game! What can we model as a class? Well a player sounds like a fine abstraction. What does a player have? Location, Health, Weapon, Inventory, Name.
Let’s make a game! What can we model as a class? Well a player sounds like a fine abstraction. What does a player have? Location, Health, Weapon, Inventory, Name. Great! Let’s model this.
Locality of Reference “Locality of reference is a term for the phenomenon in which the same values, or related storage locations, are frequently accessed, depending on the memory access pattern.”
Locality of Reference “Locality of reference is a term for the phenomenon in which the same values, or related storage locations, are frequently accessed, depending on the memory access pattern.” This means that when you load that first myX variable into memory, that is not the only thing loaded into memory, because the computer is guessing that you also need the values that are stored after the value. So it loads a lot of the memory that comes after that variable.
Cache miss “A cache miss is a failed attempt to read or write a piece of data in the cache, which results in a main memory access with much longer latency”
Cache miss “A cache miss is a failed attempt to read or write a piece of data in the cache, which results in a main memory access with much longer latency” If all of the data you need is tightly packed together, it’s much more likely that you will not need to go into main memory to access it, which will drastically speed up your program.
Cache miss “A cache miss is a failed attempt to read or write a piece of data in the cache, which results in a main memory access with much longer latency” If all of the data you need is tightly packed together, it’s much more likely that you will not need to go into main memory to access it, which will drastically speed up your program. But. As with anything. Measure first!
Object Oriented Programming Is very useful. The ability to model real world things or abstract ideas is something we do daily. But be mindful of how your data is stored and used, because when it comes down to it, those are the bits that matter the most.