Today I was reading a programming book, and I came accross the term 'concrete class', look, in practice I know what a concrete class is — now, but for some reason I got stuck on the word concrete. Could the word concrete share the same morpheme as convict, or convince, or conflict? So I decided to look it up.
Delegation involves one object passing on a method call to another object. This allows for code reuse and flexibility in object interactions.
It's worth noting that you can often achieve the best of both worlds by combining both composition and inheritance to maximize code reuse and design flexibility. The following examples not only illustrate the differences between the two but also highlight how they can be used together effectively.
Parameterised types, also known as generics, allow you to define the specific type of data that a variable or class can handle. This is valuable for error prevention and enhancing the robustness of your code. However, it's important to note that not all programming languages offer support for this feature. Statically typed languages such as Java or C# have built-in support for generics.
The final keyword is probably the most non-OOP and non-SOLID feature in PHP. Classes prefixed with this keyword cannot be extended. Meaning, no-hablo inheritence! This key word can be applied to class methods and constants too. Talk about being stingy, right?
Programming to an interface is one of the most important principles of reusable object-oriented design. While it still falls under the inheritence paradigm, it is brings a unique approach in that it promotes flexibility and decoupling. Here's why:
I wanted a way to iterate over a nested associative data structure containing file URLs, and programmatically download each file through the command line. Additionally, I aimed to maintain the folder structure once the files were downloaded onto my computer.
Listen, I'll be honest here. I'm not even sure why I am trying to learn this language. But I found myself on the website and I just thought about giving it a go. I am super persimestic at the moment and I just want this to go quickly so I can tick a box and go back to the stuff I am comfortable with.
© 2023 Elvis Magagula, All rights reserved