Earning Made Easy in 2020 With ClickFunnels

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/jUCWlbRXSTo/earning-made-easy-in-2020-with-clickfunnels

Starting a company was never easy, but now if they are not online, they practically don’t exist. If you are stressing over your startup or are trying to figure out the ins and outs of how to establish your presence online, ClickFunnels are just what you are looking for. ClickFunnels helps business owners with the […]

The post Earning Made Easy in 2020 With ClickFunnels appeared first on designrfix.com.

Power and portability: The laptop changing the game for 3D artists

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/7ZY0fekA3eo/zenbook-pro-duo-3d-artists

If you are a 3D artist, chances are your studio will include at least a large workstation, multiple monitors and a graphics tablet. The hardware required to create show-stopping 3D art doesn’t exactly lend itself to working on the go. Until now. 

Introducing the blisteringly powerful, dual screen Asus ZenBook Pro Duo laptop. 

The foundation of any workstation is the processing power, and this is where the Zenbook excels. Under the hood of this amazing device you’ll find an Intel Core i9 CPU and NVIDIA RTX 2060 GPU, providing all the power to support the most complex of 3D tasks at speed. 

A creative game-changer

But all the processing power in the world is next to useless unless you can harness it properly, and this is where the ZenBook Pro Duo really shines. This laptop has been specifically designed to help 3D and digital artists make the most of the immense power that lies beneath its equally impressive-looking exterior. 

Built into the ZenBook Pro Duo are not one but two 4K screens, both of which are touch sensitive and colour accurate. The glossy main OLED display is beautifully crisp, but it’s the second screen that really makes this device a game-changer for digital and 3D artists. 

Located at the top of the lower half of the device, the second screen boasts a paper-like finish that works wonderfully with the stylus included. A 3D artist’s workflow will often involve working with multiple palettes and keyboard shortcuts. In this case the second screen is ideal for docking these palettes for easy access and to free up the main screen for the perspective viewport.

The extra screen also means the keyboard has moved to the front edge of the laptop’s body and the trackpad to the right. A huge ergonomic improvement over centralised trackpads, the ZenBook Pro Duo puts an end to reaching over the chassis when typing or using keyboard shortcuts, and offers a much more natural workflow. To use the second screen will, however, mean leaning over the keyboard. But Asus has all bases covered with this design, adding an in-built function to simply lock the keys.

Highly portable power

The ZenBook Pro Duo’s unique design and rich feature set makes for a highly intuitive user experience on a truly mobile workstation that doesn’t compromise on power, and, in many cases, excels over that of a desktop experience.

If you are a 3D or digital artist who needs uncompromised power and portability, the Zenbook Pro Duo is the best solution.


Whimsical Balance in 3D

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/_UTO6zh33Xs/whimsical-balance-3d

Whimsical Balance in 3D
Whimsical Balance in 3D

abduzeedo07.02.20

Pol Solà has an incredible portfolio with some beautiful projects like Rings Of Saturn which was featured on Behance. There’s something about his projects that capture the 80s, in special, that sense of discovering what 3D and CGI could bring to the world in terms of visual design. With “Whimsical Balance” Pol creates a new a series of 3D explorations in collaboration with Guasch Studio. This project expands a bit more the use of textures and other materials. Glass and its reflection/refractions, caustics and how these materials and effects interact with each other to create the whimsical balance.

3D 

Image may contain: indoor

Process

Image may contain: screenshot, illustration and cartoonImage may contain: fog

Part II

Image may contain: indoor, table and wall

Process

​​​Image may contain: cartoon, drawing and vector graphicsImage may contain: cartoon and abstract

Part III

Image may contain: indoor and screenshot ​​

Process

Image may contain: cartoon, illustration and screenshotImage may contain: wall, screenshot and indoor

Taking one of Pol Sola’s Illustrations as a starting point, this 3D series with Guasch Studio is an exploration of visual tricks: Lights and shadows giving depth and sense to objects that play within the space, still movement and whimsical balance.

For more information make sure to check out Pol’s Instagram and Guasch’s Instagram 


Learn web design using Adobe XD

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/Us4ji5JU37Y/learn-uiux-web-design-using-adobe-xd

A designer never stops learning new programs, tools, and techniques. Whether you want to start your creative career or further your design speciality, The Ultimate UX/UI Designer Bundle is a great way to finesse your web design expertise, and create responsive and user-friendly websites. Best yet, it's currently price-dropped to only $29.

With over 35 hours of lectures and more than 200 tutorials, this comprehensive design bundle brings you everything you need to master HTML5, CSS3, jQuery, JavaScript, and more, without needing former training in front end web development. The eight-course master bundle focuses on various levels of experience, so no matter where you are in your design journey, you're likely to get something out of it. And the best web design tools will help, too.

Start with essential tutorials and move forward

You'll start with beginner-friendly UX/UI essential tutorials and move your way into more advanced techniques in industry-leading software. Courses on HTML5 Canvas and Bootstrap 4 will get you up to speed with key streamlining web developer elements, while other front end web courses will teach you the essential tools to styling and structuring your code to get the results you want. With step-by-step tutorials and no time constraints, you'll be able to learn at your own pace and visit each lesson whenever you want.  

Not only will you learn how to create the framework needed to develop apps and websites, but you'll also comprehend how to understand the needs of your users to get them the results they want. With project-based courses in powerful software platforms, such as Adobe XD and Illustrator, you'll be on your way to ramping up your design skills based on device – desktop, tablet, mobile, and more. By the end of the courses, you'll have the tools you need to create and present a visual roadmap for your clients successfully. Plus, a certification of completion is included in the bundle, allowing for valuable credentials to add to your résumé and portfolio. 

While access to The Ultimate UX/UI Designer Bundle is valued at over $1,500 for a limited time, you can start your developer journey at only $29 – that's a saving of 98 per cent. With all the content available 24/7, you'll soon be on your way to finessing your UX/UI skills and developing stunning websites and apps for projects of all sizes in 2020. 

Read more:

The next big thing in web design: 7 trends you need to knowThe best laptops for programming in 2020The future of frameworks: What's in store for the rest of 2020?

Creating a Menu Image Animation on Hover

Original Source: http://feedproxy.google.com/~r/tympanus/~3/N1YGL0M-ap0/

At Codrops, we love experimenting with playful hover effects. Back in 2018, we explored a set of fun hover animations for links. We called that Image Reveal Hover Effects and it shows how to make images appear with a fancy animation when hovering items of a menu. After seeing the fantastic portfolio of Marvin Schwaibold, I wanted to try this effect again on a larger menu and add that beautiful swing effect when moving the mouse. Using some filters, this can also be made more dramatic.

If you are interested in other similar effect, have a look at these:

Image Trail EffectsImage Distortion Effects with SVG FiltersImage Dragging Effects

So, today we’ll have a look at how to create this juicy image hover reveal animation:

Some Markup and Styling

We’ll use a nested structure for each menu item because we’ll have several text elements that will appear on page load and hover.

But we’ll not go into the text animation on load or the hover effect so what we are interested in here is how we’ll make the image appear for each item. The first thing I do when I want to make a certain effect is to write up the structure that I need using no JavaScript. So let’s take a look at that:

<a class=”menu__item”>
<span class=”menu__item-text”>
<span class=”menu__item-textinner”>Maria Costa</span>
</span>
<span class=”menu__item-sub”>Style Reset 66 Berlin</span>
<!– Markup for the image, inserted with JS –>
<div class=”hover-reveal”>
<div class=”hover-reveal__inner”>
<div class=”hover-reveal__img” style=”background-image: url(img/1.jpg);”></div>
</div>
</div>
</a>

In order to construct this markup for the image, we need to save the source somewhere. We’ll use a data attribute on the menu__item, e.g. data-img=”img/1.jpg”. We’ll go into more detail later on.

Next, we’ll have some styling for it:

.hover-reveal {
position: absolute;
z-index: -1;
width: 220px;
height: 320px;
top: 0;
left: 0;
pointer-events: none;
opacity: 0;
}

.hover-reveal__inner {
overflow: hidden;
}

.hover-reveal__inner,
.hover-reveal__img {
width: 100%;
height: 100%;
position: relative;
}

.hover-reveal__img {
background-size: cover;
background-position: 50% 50%;
}

Any other styles that are specific to our effect (like the transforms) we’ll add dynamically.

Let’s take a look at the JavaScript.

The JavaScript

We’ll use GSAP and besides our hover animation, we’ll also use a custom cursor and smooth scrolling. For that we’ll use the smooth scroll library from the amazing folks of Locomotive, the Agency of the year. Since those are both optional and out of the scope of the menu effect we want to showcase, we’ll not be covering it here.

First things first: let’s preload all the images. For the purpose of this demo we are doing this on page load, but that’s optional.

Once that’s done, we can initialize the smooth scroll instance, the custom cursor and our Menu instance.

Here’s how the entry JavaScript file (index.js) looks like:

import Cursor from ‘./cursor’;
import {preloader} from ‘./preloader’;
import LocomotiveScroll from ‘locomotive-scroll’;
import Menu from ‘./menu’;

const menuEl = document.querySelector(‘.menu’);

preloader(‘.menu__item’).then(() => {
const scroll = new LocomotiveScroll({el: menuEl, smooth: true});
const cursor = new Cursor(document.querySelector(‘.cursor’));
new Menu(menuEl);
});

Now, let’s create a class for the Menu (in menu.js):

import {gsap} from ‘gsap’;
import MenuItem from ‘./menuItem’;

export default class Menu {
constructor(el) {
this.DOM = {el: el};
this.DOM.menuItems = this.DOM.el.querySelectorAll(‘.menu__item’);
this.menuItems = [];
[…this.DOM.menuItems].forEach((item, pos) => this.menuItems.push(new MenuItem(item, pos, this.animatableProperties)));


}

}

So far we have a reference to the main element (the menu <nav>
element) and the menu item elements. We’ll also create an array of our MenuItem instances. But let’s cover that bit in a moment.

What we’ll want to do now is to update the transform (both, X and Y translate) value as we move the mouse over the menu items. But we might as well want to update other properties. In our case we will additionally be updating the rotation and the CSS filter value (brightness). For that, let’s create an object that stores this configuration:

constructor(el) {

this.animatableProperties = {
tx: {previous: 0, current: 0, amt: 0.08},
ty: {previous: 0, current: 0, amt: 0.08},
rotation: {previous: 0, current: 0, amt: 0.08},
brightness: {previous: 1, current: 1, amt: 0.08}
};
}

With interpolation, we can achieve the smooth animation effect when moving the mouse. The “previous” and “current” values are the values we’ll be interpolating. The current value of one of these “animatable” properties will be one between these two values at a specific increment. The value of “amt” is the amount to interpolate. As an example, the following formula calculates our current translationX value:

this.animatableProperties.tx.previous = MathUtils.lerp(this.animatableProperties.tx.previous, this.animatableProperties.tx.current, this.animatableProperties.tx.amt);

Finally, we can show the menu items, which are hidden by default. This was just a little extra, and totally optional, but it’s definitely a nice add-on to reveal each item with a delay on page load.

constructor(el) {

this.showMenuItems();
}
showMenuItems() {
gsap.to(this.menuItems.map(item => item.DOM.textInner), {
duration: 1.2,
ease: ‘Expo.easeOut’,
startAt: {y: ‘100%’},
y: 0,
delay: pos => pos*0.06
});
}

That’s it for the Menu class. What we’ll be looking into next is how to create the MenuItem class together with some helper variables and functions.

So, let’s start by importing the GSAP library (which we will use to show and hide the images), some helper functions and the images inside our images folder.

Next, we need to get access to the mouse position at any given time, since the image will follow along its movement. We can update this value on “mousemove” . We will also cache its position so we can calculate its speed and movement direction for both, the X and Y axis.

Hence, that’s what we’ll have so far in the menuItem.js file:

import {gsap} from ‘gsap’;
import { map, lerp, clamp, getMousePos } from ‘./utils’;
const images = Object.entries(require(‘../img/*.jpg’));

let mousepos = {x: 0, y: 0};
let mousePosCache = mousepos;
let direction = {x: mousePosCache.x-mousepos.x, y: mousePosCache.y-mousepos.y};

window.addEventListener(‘mousemove’, ev => mousepos = getMousePos(ev));

export default class MenuItem {
constructor(el, inMenuPosition, animatableProperties) {

}

}

An item will be passed its position/index in the menu (inMenuPosition) and the animatableProperties object described before. The fact that the “animatable” property values are shared and updated among the different menu items will make the movement and rotation of the images continuous.

Now, in order to be possible to show and hide the menu item image in a fancy way, we need to create that specific markup we’ve shown in the beginning and append it to the item. Remember, our menu item is this by default:

<a class=”menu__item” data-img=”img/3.jpg”>
<span class=”menu__item-text”><span class=”menu__item-textinner”>Franklin Roth</span></span>
<span class=”menu__item-sub”>Amber Convention London</span>
</a>

Let’s append the following structure to the item:

<div class=”hover-reveal”>
<div class=”hover-reveal__inner” style=”overflow: hidden;”>
<div class=”hover-reveal__img” style=”background-image: url(pathToImage);”>
</div>
</div>
</div>

The hover-reveal element will be the one moving as we move the mouse.
The hover-reveal__inner element together with the hover-reveal__img (the one with the background image) will be the ones that we can animate together to create fancy animations like reveal/unreveal effects.

layout() {
this.DOM.reveal = document.createElement(‘div’);
this.DOM.reveal.className = ‘hover-reveal’;
this.DOM.revealInner = document.createElement(‘div’);
this.DOM.revealInner.className = ‘hover-reveal__inner’;
this.DOM.revealImage = document.createElement(‘div’);
this.DOM.revealImage.className = ‘hover-reveal__img’;
this.DOM.revealImage.style.backgroundImage = `url(${images[this.inMenuPosition][1]})`;
this.DOM.revealInner.appendChild(this.DOM.revealImage);
this.DOM.reveal.appendChild(this.DOM.revealInner);
this.DOM.el.appendChild(this.DOM.reveal);
}

And the MenuItem constructor completed:

constructor(el, inMenuPosition, animatableProperties) {
this.DOM = {el: el};
this.inMenuPosition = inMenuPosition;
this.animatableProperties = animatableProperties;
this.DOM.textInner = this.DOM.el.querySelector(‘.menu__item-textinner’);
this.layout();
this.initEvents();
}

The last step is to initialize some events. We need to show the image when hovering the item and hide it when leaving the item.

Also, when hovering it we need to update the animatableProperties object properties, and make the image move, rotate and change its brightness as the mouse moves:

initEvents() {
this.mouseenterFn = (ev) => {
this.showImage();
this.firstRAFCycle = true;
this.loopRender();
};
this.mouseleaveFn = () => {
this.stopRendering();
this.hideImage();
};

this.DOM.el.addEventListener(‘mouseenter’, this.mouseenterFn);
this.DOM.el.addEventListener(‘mouseleave’, this.mouseleaveFn);
}

Let’s now code the showImage and hideImage functions.

We can create a GSAP timeline for this. Let’s start by setting the opacity to 1 for the reveal element (the top element of that structure we’ve just created). Also, in order to make the image appear on top of all other menu items, let’s set the item’s z-index to a high value.

Next, we can animate the appearance of the image. Let’s do it like this: the image gets revealed to the right or left, depending on the mouse x-axis movement direction (which we have in direction.x). For this to happen, the image element (revealImage) needs to animate its translationX value to the opposite side of its parent element (revealInner element).
That’s basically it:

showImage() {
gsap.killTweensOf(this.DOM.revealInner);
gsap.killTweensOf(this.DOM.revealImage);

this.tl = gsap.timeline({
onStart: () => {
this.DOM.reveal.style.opacity = this.DOM.revealInner.style.opacity = 1;
gsap.set(this.DOM.el, {zIndex: images.length});
}
})
// animate the image wrap
.to(this.DOM.revealInner, 0.2, {
ease: ‘Sine.easeOut’,
startAt: {x: direction.x < 0 ? ‘-100%’ : ‘100%’},
x: ‘0%’
})
// animate the image element
.to(this.DOM.revealImage, 0.2, {
ease: ‘Sine.easeOut’,
startAt: {x: direction.x < 0 ? ‘100%’: ‘-100%’},
x: ‘0%’
}, 0);
}

To hide the image we just need to reverse this logic:

hideImage() {
gsap.killTweensOf(this.DOM.revealInner);
gsap.killTweensOf(this.DOM.revealImage);

this.tl = gsap.timeline({
onStart: () => {
gsap.set(this.DOM.el, {zIndex: 1});
},
onComplete: () => {
gsap.set(this.DOM.reveal, {opacity: 0});
}
})
.to(this.DOM.revealInner, 0.2, {
ease: ‘Sine.easeOut’,
x: direction.x < 0 ? ‘100%’ : ‘-100%’
})
.to(this.DOM.revealImage, 0.2, {
ease: ‘Sine.easeOut’,
x: direction.x < 0 ? ‘-100%’ : ‘100%’
}, 0);
}

Now we just need to update the animatableProperties object properties so the image can move around, rotate and change its brightness smoothly. We do this inside a requestAnimationFrame loop. In every cycle we interpolate the previous and current values so things happen with an easing.

We want to rotate the image and change its brightness depending on the x-axis speed (or distance traveled from the previous cycle) of the mouse. Therefore we need to calculate that distance for every cycle which we can get by subtracting the mouse position from the cached mouse position.

We also want to know in which direction we move the mouse since the rotation will be dependent on it. When moving to the left the image rotates negatively, and when moving to the right, positively.

Next, we want to update the animatableProperties values. For the translationX and translationY, we want the center of the image to be positioned where the mouse is. Note that the original position of the image element is on the left side of the menu item.

The rotation can go from -60 to 60 degrees depending on the speed/distance of the mouse and its direction. Finally the brightness can go from 1 to 4, also depending on the speed/distance of the mouse.

In the end, we take these values together with the previous cycle values and use interpolation to set up a final value that will then give us that smooth feeling when animating the element.

This is how the render function looks like:

render() {
this.requestId = undefined;

if ( this.firstRAFCycle ) {
this.calcBounds();
}

const mouseDistanceX = clamp(Math.abs(mousePosCache.x – mousepos.x), 0, 100);
direction = {x: mousePosCache.x-mousepos.x, y: mousePosCache.y-mousepos.y};
mousePosCache = {x: mousepos.x, y: mousepos.y};

this.animatableProperties.tx.current = Math.abs(mousepos.x – this.bounds.el.left) – this.bounds.reveal.width/2;
this.animatableProperties.ty.current = Math.abs(mousepos.y – this.bounds.el.top) – this.bounds.reveal.height/2;
this.animatableProperties.rotation.current = this.firstRAFCycle ? 0 : map(mouseDistanceX,0,100,0,direction.x < 0 ? 60 : -60);
this.animatableProperties.brightness.current = this.firstRAFCycle ? 1 : map(mouseDistanceX,0,100,1,4);

this.animatableProperties.tx.previous = this.firstRAFCycle ? this.animatableProperties.tx.current : lerp(this.animatableProperties.tx.previous, this.animatableProperties.tx.current, this.animatableProperties.tx.amt);
this.animatableProperties.ty.previous = this.firstRAFCycle ? this.animatableProperties.ty.current : lerp(this.animatableProperties.ty.previous, this.animatableProperties.ty.current, this.animatableProperties.ty.amt);
this.animatableProperties.rotation.previous = this.firstRAFCycle ? this.animatableProperties.rotation.current : lerp(this.animatableProperties.rotation.previous, this.animatableProperties.rotation.current, this.animatableProperties.rotation.amt);
this.animatableProperties.brightness.previous = this.firstRAFCycle ? this.animatableProperties.brightness.current : lerp(this.animatableProperties.brightness.previous, this.animatableProperties.brightness.current, this.animatableProperties.brightness.amt);

gsap.set(this.DOM.reveal, {
x: this.animatableProperties.tx.previous,
y: this.animatableProperties.ty.previous,
rotation: this.animatableProperties.rotation.previous,
filter: `brightness(${this.animatableProperties.brightness.previous})`
});

this.firstRAFCycle = false;
this.loopRender();
}

I hope this has been not too difficult to follow and that you have gained some insight into constructing this fancy effect.

Please let me know if you have any question @codrops or @crnacura.

Thank you for reading!

The images used in the demo are by Andrey Yakovlev and Lili Aleeva. All images used are licensed under CC BY-NC-ND 4.0

The post Creating a Menu Image Animation on Hover appeared first on Codrops.

Beautiful Collage Illustration by Daniel Escudeiro

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/MmWg8CEqQ_I/beautiful-collage-illustration-daniel-escudeiro

Beautiful Collage Illustration by Daniel Escudeiro
Beautiful Collage Illustration by Daniel Escudeiro

abduzeedo07.01.20

Daniel Escudeiro shared a really beautiful project on Behance that brought me back some good memories of the 90s and early 2000s. The project is a set of two collage illustrations for a short story by Raphael Montes, published in the Brazilian magazine Superinteressante (May 2017). The work has that deconstructivist look, mixing different photogs and textures. The color palette also reinforces the look, and do pay a homage to the work of  the incredible Eduardo Recife (misprintedtype.com/).

The short story

An aspiring actress is, since her childhood, obsessed with being cast in a film by her dream director. With each new audition, she completely transforms herself into the character she wants to play – which escalates from taking antidepressants to prostitution, and even to a sex change operation. She’ll never get the part, but will keep trying as her life is tragically and comically ruined in the process.

Illustration


How to Invoice Your Clients Professionally (10 Tips)

Original Source: https://www.hongkiat.com/blog/invoice-freelance-clients-professionally/

Let’s face it – while receiving money can be very addictive, invoicing is a total nightmare for freelancers, especially designers. However, the freelance business’s truth is that…

Visit hongkiat.com for full content.

How to Ensure Flexible, Reusable PHP Code with Insphpect

Original Source: https://www.sitepoint.com/how-to-ensure-flexible-reusable-php-code-with-insphpect/?utm_source=rss

Insphpect is a tool I wrote as part of my PhD project. It scans code for object-oriented programming techniques that hinder code reusability and flexibility.

Why?

Let me begin with two mundane observations:

Business requirements change over time.
Programmers are not clairvoyant.

New product launches, emergency lockdown regulations, expanding into new markets, economic factors, updated data protection laws: there are lots of potential causes for business software to need updating.

From those two observations we can infer that programmers know that the code they write is going to change, but not what those changes will be or when they will happen.

Writing code in such a way that it can be easily adapted is a skill that takes years to master.

You’re probably already familiar with programming practices that come back and haunt you. Novice programmers quickly realize that global variables are more trouble than they’re worth, and the once incredibly popular Singleton Pattern has been a dirty word for the last decade.

How you code your application has a big impact on how easy it is to adapt to meet new requirements. As you progress through your career, you learn techniques that make adapting code easier. Once you’ve grasped fundamentals of object-oriented programming you wonder how you ever did without it!

If you ask ten developers to produce software, given the same requirements, you’ll get ten different solutions. Some of those solutions will inevitably be better than others.

Consider a ship in a bottle and a model ship made of Lego. Both are model ships, but changing the sails on the ship in a bottle is very difficult, and reusing the parts is near impossible. However, with a Lego ship, you can easily swap out the sails or use the same components to build a model rocket, house or a car.

Certain programming techniques lead to the ship-in-a-bottle approach and make your code difficult to change and adapt.

Insphpect

Insphpect is a tool which scans your code for programming practices that lead to this kind of a ship in a bottle design.

It grades your code based on how flexible it is, and highlights areas where flexibility can be improved.

What does Insphpect look for?

Currently, Insphpect looks for the following:

tight coupling
hardcoded configuration
singletons
setter injection
using the new keyword in a constructor
service locators
inheritance
static methods
global state
files that have more than one role (e.g. defining a class and running some code)

If it detects anything it identifies as inflexible, it highlights the code, explains why it highlighted the issue, then grades your whole project and individual classes on a score of 0-100 (with 100 being no issues detected). As a proof of concept, for some detections it’s able to automatically generate a patch file that re-writes the code to remove the inflexibility entirely.

Take a look a sample report here.

Insphpect is currently in the testing phase, and it would really help my research progress if you can check it out and complete the survey in the “Give your feedback” section of the site.

Background

Are those bad practices really bad, though?

This was one of the more difficult parts of the background research, and you can read about how this was done in detail on the Insphpect website.

However, this can be summarized as:

The opinions of each bad practice were collected from 100 authors per practice.
The author’s opinion on the practice was graded on a scale of 1–5.
The author’s methodological rigor was graded on a scale of 1–7 based on the Jadad score used for clinical trials.

These were then plotted like the graph below:

Singleton pattern results

Each horizontal line represents an article, and the left (orange) bar for each article is the recommendation going from 5 — Avoid this practice at all costs (Far left) — to 1 — Favor this practice over alternatives.

The right (blue) bar for each article is the Jadad style score measuring analytic rigor. A score of seven means the article describes the practice, provides code examples, discusses alternative approaches, provides like-for-like code samples, discusses the pros/cons of each approach and makes a recommendation of which approach should be used.

In the case of the singleton above, authors who compare the singleton to alternative approaches, discuss the pros/cons, etc., are significantly more likely to suggest using alternative approaches.

Walkthrough

Currently, Insphpect allows uploading code via a Git repository URL or a ZIP file.

So not to point out flaws in other people’s work, let’s take a look at one of my own projects to see what it identifies.

We’ll use https://github.com/Level-2/Transphporm as an example project.

This is quite a good example, because it has a very high score on another code-quality tool Scrutinizer.

Firstly, enter the git URL https://github.com/Level-2/Transphporm into the text box at the top of the home page and press “Go”. It will take a few seconds to minutes, depending on the size of the project, and will generate a report that looks something like this:

Transphporm Report

Once you’re on the report page, you’ll see a summary at the top with an overall grade out of 100, with 100 being very good and 0 being very poor.

Underneath the summary, you’ll see a list of all the classes in the project, each with its own grade.

Don’t worry if your code doesn’t get a perfect score. It’s unlikely that it will. Remember, Insphpect is a tool that identifies flexibility in your code. There are parts of your code (like the entry point) where flexibility isn’t warranted.

For Transphporm, it has highlighted issues in seven classes.

Let’s take a look at some of those. Scroll down to TransphpormParserCssToXpath and click the link. You’ll see a score for that particular class and a list of issues which have been identified.

In this case, it has identified a static variable and a static method. Clicking on one of the red lines will reveal an explanation of why the line was flagged up.

For example, clicking line 12 will give an explanation of why static variables are less flexible than instance variables.

Single class report

Although there’s a more in-depth explanation of the issues caused by static properties on the report, as a quick refresher, static variables have one value which is shared across all the instances of the class.

This is inherently less flexible than an instance variable, because using an instance variable allows each instance to have a different value.

For example, consider the following:

class User {
public static $db;
public $id;
public $name;
public $email;

public function save() {
$stmt = self::$db->prepare(‘REPLACE INTO user (id, name, email) VALUES (:id, :name, :email)’);

$stmt->execute([
‘id’ => $this->id,
‘name’ => $this->name.
’email’ => $this->email
]);
}
}

Because $db is static, every instance of this class shares the same $db instance and records will always be inserted into the same database.

While this sounds reasonable, let me give you a real-world example.

Continue reading
How to Ensure Flexible, Reusable PHP Code with Insphpect
on SitePoint.

15 React Interview Questions with Solutions

Original Source: https://www.sitepoint.com/react-interview-questions-solutions/?utm_source=rss

15 React Interview Questions with Solutions

React’s popularity shows no sign of waning, with the demand for developers still outstripping the supply in many cities around the world. For less-experienced developers (or those who’ve been out of the job market for a while), demonstrating your knowledge at the interview stage can be daunting.

In this article, we’ll look at fifteen questions covering a range of knowledge that’s central to understanding and working effectively with React. For each question, I’ll summarize the answer and give links to additional resources where you can find out more.

1. What’s the virtual DOM?
Answer

The virtual DOM is an in-memory representation of the actual HTML elements that make up your application’s UI. When a component is re-rendered, the virtual DOM compares the changes to its model of the DOM in order to create a list of updates to be applied. The main advantage is that it’s highly efficient, only making the minimum necessary changes to the actual DOM, rather than having to re-render large chunks.

Further reading

Understanding the Virtual DOM
Virtual DOM Explained

2. What’s JSX?
Answer

JSX is an extension to JavaScript syntax that allows for writing code that looks like HTML. It compiles down to regular JavaScript function calls, providing a nicer way to create the markup for your components.

Take this JSX:

<div className=”sidebar” />

It translates to the following JavaScript:

React.createElement(
‘div’,
{className: ‘sidebar’}
)

Further reading

What is JSX?
JSX in Depth
JSX in React Design Patterns and Best Practices

3. What’s the difference between a class component and a functional one?
Answer

Prior to React 16.8 (the introduction of hooks), class-based components were used to create components that needed to maintain internal state, or utilize lifecycle methods (i.e. componentDidMount and shouldComponentUpdate). A class-based component is an ES6 class that extends React’s Component class and, at minimum, implements a render() method.

Class component:

class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}

Functional components are stateless (again, < React 16.8) and return the output to be rendered. They are preferred for rendering UI that only depends on props, as they’re simpler and more performant than class-based components.

Functional component:

function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}

Note: the introduction of hooks in React 16.8 means that these distinctions no longer apply (see questions 14 and 15).

Further reading

Functional Components vs Class Components in React
Functional vs Class-Components in React

4. What are keys used for?
Answer

When rendering out collections in React, adding a key to each repeated element is important to help React track the association between elements and data. The key should be a unique ID, ideally a UUID or other unique string from the collection item, but which can be an array index as a last resort:

<ul>
{todos.map((todo) =>
<li key={todo.id}>
{todo.text}
</li>
)};
</ul>

Not using a key can result in strange behavior when adding and removing items from the collection.

Further reading

Lists and Keys
Understanding React’s key prop

5. What’s the difference between state and props?
Answer

props are data that are passed into a component from its parent. They should not be mutated, but rather only displayed or used to calculate other values. State is a component’s internal data that can be modified during the lifetime of the component, and is maintained between re-renders.

Further reading

props vs state

6. Why call setState instead of directly mutating state?
Answer

If you try to mutate a component’s state directly, React has no way of knowing that it needs to re-render the component. By using the setState() method, React can update the component’s UI.

Bonus

As a bonus, you can also talk about how state updates are not guaranteed to be synchronous. If you need to update a component’s state based on another piece of state (or props), pass a function to setState() that takes state and props as its two arguments:

this.setState((state, props) => ({
counter: state.counter + props.increment
}));

Further reading

Continue reading
15 React Interview Questions with Solutions
on SitePoint.

How to Keep Working Remotely in a Post-COVID-19 World

Original Source: https://www.sitepoint.com/post-covid-19-remote-work/?utm_source=rss

How To Keep Working Remotely in a post-COVID-19 World

Though the COVID-19 pandemic is still far from over, many companies and employees are already looking to the post-COVID world. For many organizations, the enforced move to remote working over the past few months has presented significant challenges.

On the other hand, there are many employees who, despite being reticent to move to remote working at the beginning of the pandemic, are now finding that remote work actually suits them rather well.

If you fall into this category, you might be wondering how you can continue to work from home after the current crisis ends. Many of the strategies you can deploy to achieve this are, in fact, similar to those that make for effective remote working in the first place: ensuring effective collaboration in remote teams, and making sure that you set yourself up for success with remote work, to name a couple things.

Nevertheless, your employer might be hesitant to let you continue to work remotely after the pandemic is over. If you don’t want to move back to the office, you’ll find some tips in this article on how to convince your boss to let you continue working from home.

The Benefits of Remote Working

If you don’t want to move back to your office in the next few months, you’re not alone. In fact, nearly 43% of full-time American employees say they want to work remotely more often even after the economy has reopened. One of the biggest reasons for this is the time that the average tech worker saves in commuting. The average American spent roughly 27 minutes on their one-way commute to the office in 2018, which equates to more than 200 hours spent commuting per year.

For tech companies, there are other benefits of remote working. Many software development firms are inherently multi-national, and co-ordinating employees across the globe can actually be easier if they’re working from home. As we’ve previously pointed out, the future of remote work is asynchronous. Research has also found that the kind of creativity and flexibility that tech firms value is actually increased by remote working rather than decreased.

Despite these findings, many organizations are still hesitant to let their employees work from home — at least once the global health crisis is over. So how can you continue to work from home after all this is over?

Continue reading
How to Keep Working Remotely in a Post-COVID-19 World
on SitePoint.