admin-paul

SOLID OOP, Liskov Substitution Principle

Liskov Substitution Principle The Liskov Substitution Principle [1] (LSP) is applied to inheritance hierarchies. LSP specifies that classes should be designed such that client dependencies can be substituted with subclasses without the client “knowing”. How to apply the Liskov Substitution Principle To adhere to Liskov Substitution Principle, subclasses must function in the same way as… Read more SOLID OOP, Liskov Substitution Principle

SOLID OOP, OPEN/CLOSE PRINCIPLE (OCP)

Open/Close Principle (OCP) The Open/Close Principle means that software entities should be open for extension but closed for modification [1]. Open to extension “Open to extension” means that classes are designed with the possibility of new functionality in mind. Down the road, one can extend functionality as new requirements come up. Closed for modification “Closed… Read more SOLID OOP, OPEN/CLOSE PRINCIPLE (OCP)

SOLID OOP, Single Responsibility Principle

Single Responsibility Principle (SRP): Single responsibility principle [1] means that any one class should not have more than one reason to change. For this to be true, a class will only have one single responsibility. Avoid creating a god class [2]. Objects that controlling way too many other objects in a system and often becoming… Read more SOLID OOP, Single Responsibility Principle

PHP: Dynamically refer to an object property

Sometimes you may need to programmatically determine which property of an object you would like to call. Are you trying to dynamically refer to an object property? In order to do this, you need to get past an issue with ambiguity. The PHP documentations says: …if you write$$a[1] then the parser needs to know if you… Read more PHP: Dynamically refer to an object property

PHP Find php.ini and edit configuration settings from command line

Manipulating the PHP ini file from the command line is really quite straight forward. To get yourself started on the command line, just ask PHP for help like this:

You’ll see a list of options and arguments. From the php help output one can see that the -i option will show what amounts to the… Read more PHP Find php.ini and edit configuration settings from command line

EXAMPLE OF PROMISE.ALL()

Example of Promise.all() Do you need to iterate over an array of promises? Promise.all() is often the best way. Promise.all(iterable) returns a single promise. Promise.all(iterable) only resolves after every promise in an array of promises has completed resolving. Since the elements of the array are promises, they do not resolve in any particular order. If… Read more EXAMPLE OF PROMISE.ALL()

Inject jQuery into a Webpage Through Chrome Javascript Console

include these lines of jQuery instantiation code in the javascript console Exploring the DOM is much easier with jQuery. However, You may be working with a webpage that does not natively have jQuery installed. That’s ok, the following lines of code will solve this. Just include these lines of jQuery instantiation code before you explore… Read more Inject jQuery into a Webpage Through Chrome Javascript Console

Iterate an array with a promise in javascript

Example of how to iterate an array with a promise It can be challenging to figure out how to iterate over an array of items with a promise. The following code takes a callback function that may or may not be a promise already. Once inside the PromiseForEach function, the callback will become a promise… Read more Iterate an array with a promise in javascript

[solved] devtool reloads if application writes to a file

If you are developing a node js application using devtool, you may experience a rather frustrating situation whereby you application stops without any traceable errors followed by a subsequent reload of the devtool. Why does devtool keep reloading when there are no errors? There is a likelyhood that you are experiencing this issue as you… Read more [solved] devtool reloads if application writes to a file