PHPnews.io

Overview for 'oop'

Abstract Objects

Written by Yegor Bugayenko / Original link on Dec. 1, 2020

How do you create objects in your object-oriented language? Let’s take something classic, like C++, Java, or C#. First you define a class, and then you make an instance of it. The first step is known as abstraction, and the second one as instantiation. A similar pair of operations exist in function…


Objects Without Methods

Written by Yegor Bugayenko / Original link on Nov. 24, 2020

What do you think an object is in OOP? No matter what language you are programming with, you will most probably agree with Bruce Eckel, the author of Thinking in Java, who said that “each object has a state and operations that you can ask it to perform,” or Benjamin Evans, the author of Java in a…


Strong Typing without Types

Written by Yegor Bugayenko / Original link on Nov. 10, 2020

In 1974, Liskov and Zilles defined a strongly-typed language as one in which “whenever an object is passed from a calling function to a called function, its type must be compatible with the type declared in the called function.” Strong type checking, without doubt, decreases the amount of type erro…


New Metric: the Distance of Coupling

Written by Yegor Bugayenko / Original link on Oct. 27, 2020

Encapsulation, as you know, is one of the four key principles in object-oriented programming. Encapsulation, according to Grady Booch et al., is “the process of hiding all the secrets of an object that do not contribute to its essential characteristics.” Practically speaking, it’s about those priva…


Veil Objects to Replace DTOs

Written by Yegor Bugayenko / Original link on May. 19, 2020

Here is a new idea I discovered just a few days ago while working with Codexia, a Ruby web app. I had to fetch data rows from PostgreSQL and return objects to the client. It’s always been a problem for me, how to do that without turning objects into DTOs. Here is the solution I found and gave a nam…


Prefixed Naming

Written by Yegor Bugayenko / Original link on Mar. 3, 2020

If you look at the source code of Takes or Cactoos for the first time, you most probably, like many others, will be triggered by the naming convention, which implies that most class names have two-letter prefixes: BkSafe, RqFake, RsWithStatus, TkGzip, and so on. To be honest, I haven’t seen a singl…