PHPnews.io

Fat vs. Skinny Design

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

It seems that type/class hierarchies in OOP may be designed in twoextreme ways: either with full encapsulation of data in mind; or with just a fewinterfaces making raw data visible, and letting classes deal with it, parse it,and turn it into smaller data elements. You may be surprised, but I’msugge…


File structure

Written by Sebastian De Deyne / Original link on Feb. 19, 2020

In the previous posts, we've gone through our first few utility functions. We now have enough in our toolbox to move on to our first component. However, where do all these functions belong?Let's get straight to the point. Here's what the structure of my vanilla JS projects looks like:components/dat…


Implementing an opaque type in typescript

Written by Evert Pot / Original link on Feb. 18, 2020

Say, you’re in a situation where you have a user type, that looks a bit asfollows:export type User = { firtName: string; lastName: string; email: string;}function save(user: User) { // ...}const user = { firstName: 'Evert', lastName: 'Pot', email: 'foo@example.org',}save(user);But, instead …