emGee Software Solutions Custom Database Applications

Share this

Web Design

Using Design Workouts To Build World-Class Design Teams

Smashing Magazine - Thu, 12/07/2017 - 09:19
What do the makers of the most successful products in the world, whether digital or physical, have in common? I bet they put design and user experience at the center of everything they do. These companies recognize that the smallest detail can make or break a product. The best design ideas, though, are made not in isolation, but by strong, well-rounded teams. So, how do you cultivate a strong design team?
Categories: Web Design

Everything You Ever Wanted To Know About Prototyping (But Were Afraid To Ask)

Smashing Magazine - Thu, 12/07/2017 - 06:00
Prototypes are my framework for learning new tools, platforms and techniques. A prototype works as hard proof that an idea will or won’t work. It is central to my entire creative process and is the medium I use to relate to the people and businesses I collaborate with. I’m gushy about prototypes because I think they can work wonders, but I also think they don’t get they’re due. Prototyping is usually not incorporated into project timelines at all or, if it is, usually as some tangential deliverable to a larger project.
Categories: Web Design

Dealing With Stress As A Designer: Here's What Research Says

Smashing Magazine - Thu, 12/07/2017 - 04:00
The world is a stressful place. That’s probably why if you search for articles about dealing with stress you’ll find lots of great advice. But the problem is that most of it is pretty generic. Eat good food. Exercise. Get plenty of sleep. Those are all good general tips — but is there anything more specific to the profession of design? If you’re a designer who feels stressed from time to time, then this article is for you.
Categories: Web Design

Understanding ExpressJS Routing

Tuts+ Code - Web Development - Thu, 12/07/2017 - 04:00

Express is a popular Node.js web framework. Amongst its functionality, it provides a wrapper for Routing. The Express Router helps in the creation of route handlers. In this tutorial, you will learn how to work with Express Router.

Let's get started.

Create a new directory for your application. Run the command to initialize npm in the directory you just created.

npm init -y

The only dependency you will need is express, so go ahead and install it.

npm install --save express

At the end, your package.json file should look like this.

#package.json { "name": "express-router", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "express": "^4.16.2" } }

Now create a new file called index.js, which will be your entry file as stated in your package.json.

For now, you just need a basic setup like this:

#index.js const express = require('express') const app = express() app.listen(3000, () => { console.log(`Server running at port 3000`) })Basic Routing

Start by creating some basic routes as I have below.

#index.js ... const router = express.Router() // 1 router.get('/', (req, res) => { // 2 res.send('This is the homepage!') }) router.post('/contact', (req, res) => { // 3 res.send('This is the contact page with a POST request') }) app.use('/', router) // 4 ...
  1. An instance of Express Router is created. The instance is set to a variable called router. This variable will be used whenever you want to create a route.
  2. A new route is defined for the GET method to the root of the application. It is attached to the instance of the Express Router class.
  3. A new route is defined for the POST method to the contact page of the application. It is attached to the instance of the Express Router class.
  4. This mounts some middleware that will be used to handle your routes. Here you tell your app that you want to make use of the router (which is the instance of the Express Router) for every request made to the app that corresponds to the path '/'. If you fail to mount a path on this middleware, it will be executed for every request made to the app.

Let's say you had the code below instead.

app.use('/user', router)

This will match all the following: /user/profile, user/profile/edit, user/dashboard/article/view, and so on.

Route Methods

In the above code, you attached a route method to an instance of Express Router. The route method is derived from one of the HTTP methods and attached to the instance of the Express Router as you did.

Express supports the following routing methods that correspond to HTTP methods: get, post, put, head, delete, options, trace, copy, lock, mkcol, move, purge, unlock, report, mkactivity, checkout, merge, m-search, notify, subscribe, unsubscribe, patch, and search.

There is a routing method app.all() which is not derived from any HTTP method. This routing method gets loaded for functions at a specified path for all request methods.

Say you have the code below in your application.

app.all('/books', (req, res) => { res.send('This accesses the book section') })

This will be executed for requests to "/books" when you are using GET, POST, PUT, or any HTTP request method.

Route Paths

A route path is used to define an endpoint where requests can be made. It does so with the combination of a request method. In Express, route paths can be string patterns or regular expressions.

Here are examples you can add to your index.js file.

#index.js router.get('/about', (req, res) => { res.send('This route path will match to /about') }) router.get('/profile.txt', (req, res) => { res.send('This route will match to /profile.txt') })

Let's see a route path using string patterns.

router.get('/ab+xy', (req, res) => { // 1 res.send('ab+xy') }) router.get('/ab(xy)?z', (req, res) => { // 2 res.send('/ab(xy)?z') })
  1. The route will match abxy, abbxy, abbbxy, and so on.
  2. The route will match /abz and /abxyz.
Route Parameters

These are used to capture values that are specified at a certain position in the URL. They are called URL segments. The values captured are made available in the req.params object, using the name of the route parameter specified in the path as the keys of the values.

Here is an example.

If you have a route path similar to this in your application: /users/:userId/articles/:articleId

The requested URL will look like this: http://localhost:3000/users/19/articles/104

In the req.params, the following will be available: { "userId": "19", "bookId": "104" }

Go ahead and create a new route in your application, using the route path above.

router.get('/users/:userId/articles/:articleId', (req, res) => { res.send(req.params) })

Start your server and point your browser to http://localhost:3000/users/19/articles/104. You will see the req.params object displayed in your browser.

The name of the route parameters must be made up of word characters ([A-Za-z0-9_]).

Let's take it further!

Say you want to have a route path called /users/:name, where the name of the user is passed into the URL and the application displays the name along with a string. How do you think that can be achieved?

Go ahead and try it out on your own first.

Here is what the route should look like.

router.get('/users/:name', (req, res) => { res.send(`Welcome, ${req.params.name}!`) })

When you visit http://localhost:3000/users/vivian, you should see Welcome, vivian! displayed in the browser.

Login Routes

Let's see how to create a login route in Express. Your login routes require two actions on a single route path. The actions will be differentiated by the route method used. Here is how it will look.

router.get('/login', (req, res) => { res.send('This is should lead to the login form') }) router.post('/login', (req, res) => { res.send('This is used in processing the form') })

After doing this, your store form should have an action whose value is the route defined with the HTTP POST method. Here is how it should look.

<form action="/login" method="POST"> </form>

When the submit button of the form gets clicked, the specified router gets called. The difference between both route paths as stated above is the HTTP POST. This is how the application determines which is responsible for handling the data passed through the form.

Another aspect where this can be experienced is in the area of editing and updating resources.


app.route() can be used to create a chain of route handlers for a specific route path.

Using the example of the login route, here is how you will make use of app.route().

app.route('/login') .get((res, req) => { res.send('This is should lead to the login form') }) .post((res, req) => { res.send('This is used in processing the form') })

You can add more route handlers than we have above.


At this point, you should know how routing works in Express. You have learned how to set up basic routing, and also how to work with route methods and paths. You saw how to make use of route parameters and retrieve values sent via the URL.

If you’re looking for additional JavaScript resources to study or to use in your work, check out what we have available on Envato Market.

With this knowledge, you can go further to build an Express application with complex routing.

Categories: Web Design

17 Worthwhile Website Builders You Must Checkout

In this post, I’ve created a list of 17 quality website builders. These services range from very specific design portfolio and landing pages purposes to more general, build whatever...

The post 17 Worthwhile Website Builders You Must Checkout appeared first on Onextrapixel.

Categories: Web Design

The Evolution Of User Experience Design

Smashing Magazine - Wed, 12/06/2017 - 04:28
(This series of articles is kindly supported by Adobe.) We’re fortunate enough to be working at an incredibly exciting time in our industry. Yes, the challenges are considerable, but the opportunities are – equally – transformational. It’s never been a more exciting time to work as a User Experience (UX) designer. Great designers deliver wonderful, considered and memorable experiences. Doing that isn’t easy and – through this series of articles – I’ll provide a wealth of pointers to ensure you’re on the right track.
Categories: Web Design

Copyright Law Essentials All Designers Should Know

Smashing Magazine - Tue, 12/05/2017 - 00:27
As software designers or developers, you have the important task of ensuring that a program works the way it is supposed to while being efficient, user-friendly, and unique. After all the creativity that is poured into making a program work just right, it’s fair to say that a well-designed software program is a work of art. From a legal perspective, a software program is a complex work that includes both functional and artistic elements.
Categories: Web Design

Welcome To The Next Level Of Mobile App Development

Smashing Magazine - Mon, 12/04/2017 - 06:00
(This is a sponsored article.) As users spend 89% of their mobile time inside apps — and 56% of all traffic is now mobile — creating a mobile app has become a top priority for many businesses. Statistics show that the average American spends more than two hours a day on their mobile device. Having a mobile app can be beneficial for your company for a number of reasons. But we all know that building an app from scratch is difficult — the gap between a concept and solution is wide and requires a lot of time, effort and money.
Categories: Web Design

Rendering AJAX-crawling pages

Google Webmaster Central Blog - Mon, 12/04/2017 - 05:57

The AJAX crawling scheme was introduced as a way of making JavaScript-based webpages accessible to Googlebot, and we've previously announced our plans to turn it down. Over time, Google engineers have significantly improved rendering of JavaScript for Googlebot. Given these advances, in the second quarter of 2018, we'll be switching to rendering these pages on Google's side, rather than on requiring that sites do this themselves. In short, we'll no longer be using the AJAX crawling scheme.

As a reminder, the AJAX crawling scheme accepts pages with either a "#!" in the URL or a "fragment meta tag" on them, and then crawls them with an "?_escaped_fragment_=" in the URL. That escaped version needs to be a fully-rendered and/or equivalent version of the page, created by the website itself.

With this change, Googlebot will render the #! URL directly, making it unnecessary for the website owner to provide a rendered version of the page. We'll continue to support these URLs in our search results.

We expect that most AJAX-crawling websites won't see significant changes with this update. Webmasters can double-check their pages as detailed below, and we'll be sending notifications to any sites with potential issues.

If your site is currently using either #! URLs or the fragment meta tag, we recommend:

  • Verify ownership of the website in Google Search Console to gain access to the tools there, and to allow Google to notify you of any issues that might be found.
  • Test with Search Console's Fetch & Render. Compare the results of the #! URL and the escaped URL to see any differences. Do this for any significantly different part of the website. Check our developer documentation for more information on supported APIs, and see our debugging guide when needed.
  • Use Chrome's Inspect Element to confirm that links use "a" HTML elements and include a rel=nofollow where appropriate (for example, in user-generated content)
  • Use Chrome's Inspect Element to check the page's title and description meta tag, any robots meta tag, and other meta data. Also check that any structured data is available on the rendered page.
  • Content in Flash, Silverlight, or other plugin-based technologies needs to be converted to either JavaScript or "normal" HTML, if their content should be indexed in search.

We hope that this change makes it a bit easier for your website, and reduces the need to render pages on your end. Should you have any questions or comments, feel free to drop by our webmaster help forums, or to join our JavaScript sites working group.

Posted by John Mueller, Google Switzerland
Categories: Web Design

Debugging CSS Grid Layouts With Firefox Grid Inspector

Smashing Magazine - Mon, 12/04/2017 - 05:56
You may have heard quite a bit of talk about a CSS feature called “Grid” this year. If you are someone who cringes when you hear the words “CSS” and “grid” in the same sentence, then I highly suggest you check out this new CSS module called CSS Grid. Browsers render HTML elements as boxes according to the CSS box model, and CSS Grid is a new layout model that provides authors the ability to control the size and position of these boxes and their contents.
Categories: Web Design

Task Scheduling in Laravel

Tuts+ Code - Web Development - Mon, 12/04/2017 - 04:00

In this article, we’ll go through one of the exciting features of the Laravel web framework—task scheduling. Throughout the course of this article, we’ll look at how Laravel allows you to manage scheduled tasks in your application. Moreover, we’ll also end up creating our own custom scheduled tasks for demonstration purposes.

The Laravel framework allows you to set up scheduled tasks so that you don't have to worry about setting them up at the system level. You can get rid of that complex cron syntax while setting up scheduled tasks since Laravel allows you to define them in a user-friendly way.

We’ll start the article with how you are used to setting up traditional cron jobs, and following that we’ll explore the Laravel way of achieving it. In the latter half of the article, we’ll give it a try by creating couple of custom scheduled tasks that should provide hands-on insight into the subject.

Traditional Scheduled Task Setup

In your day-to-day application development, you often face a situation that requires you to execute certain scripts or commands periodically. If you're working with the *nix system, you are probably aware that cron jobs handle these commands. On the other hand, they're known as scheduled tasks on Windows-based systems.

Let's have a quick look at a simple example of the *nix based cron job.

*/5 * * * * /web/statistics.sh

Pretty simple—it runs the statistics.sh file every five minutes!

Although that was a pretty simple use case, you often find yourself in a situation that requires you to implement more complex use cases. On the other hand, a complex system requires you to define multiple cron jobs that run at different time intervals.

Let's see some tasks a complex web application has to perform periodically in the back-end.

  • Clean up the unnecessary data from the database back-end.
  • Update the front-end caching indexes to keep it up-to-date.
  • Calculate the site statistics.
  • Send emails.
  • Back up different site elements.
  • Generate reports.
  • And more.

So, as you can see, there's plenty of stuff out there waiting to be run periodically and also at different time intervals. If you're a seasoned system admin, it's a cake walk for you to define the cron jobs for all these tasks, but sometimes we as developers wish that there was an easier way around.

Luckily, Laravel comes with a built-in Task Scheduling API that allows you to define scheduled tasks like never before. And yes, the next section is all about that—the basics of Laravel task scheduling.

The Laravel Way

In the earlier section, we went through the traditional way of setting up cron jobs. In this section, we'll go through the specifics of Laravel in the context of the Task Scheduling API.

Before we go ahead, the important thing to understand is that the scheduling feature provided by Laravel is just like any other feature and won't be invoked automatically. So if you're thinking that you don't need to do anything at the system level then you're out of luck, I'd say.

In fact, the first thing you should do should you wish to use the Laravel scheduling system is to set up the cron job that runs every minute and calls the artisan command shown in the following snippet.

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

The above artisan command calls the Laravel scheduler, and that in turn executes all the pending cron jobs defined in your application.

Of course, we are yet to see how to define the scheduled tasks in your Laravel application, and that's the very next thing we'll dive into.

It's the schedule method of the App\Console\Kernel class that you need to use should you wish to define application-specific scheduled tasks.

Go ahead and grab the contents of the app/Console/Kernel.php file.

<?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ 'App\Console\Commands\Inspire', ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->command('inspire')->hourly(); } }

As you can see, the core code itself provides a useful example. In the above example, Laravel runs the inspire artisan command hourly. Don't you think that the syntax is so intuitive in the first place?

In fact, there are a couple of different ways in which Laravel allows you to define schedule tasks:

  • Use the closure/callable.
  • Call the artisan command.
  • Execute the shell command.

Moreover, there are plenty of built-in scheduling frequencies you could choose from:

  • every minute/every five minutes
  • hourly/daily/weekly/quarterly/yearly
  • at a specific time of the day
  • and many more

In fact, I would say that it provides a complete set of routines so that you don't ever need to touch the shell to create your custom cron jobs!

Yes I can tell that you're eager to know how to implement your custom scheduled tasks, and that is what I also promised at the beginning of the article.

Create Your First Scheduled Task in Laravel

As we discussed, there are different ways in which Laravel allows you to define scheduled tasks. Let's go through each to understand how it works.

The Closure/Callable Method

The scheduling API provides the call method that allows you to execute a callable or a closure function. Let's revise the app/Console/Kernel.php file with the following code.

<?php namespace App\Console; use Illuminate\Support\Facades\DB; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // the call method $schedule->call(function () { $posts = DB::table('posts') ->select('user_id', DB::raw('count(*) as total_posts')) ->groupBy('user_id') ->get(); foreach($posts as $post) { DB::table('users_statistics') ->where('user_id', $post->user_id) ->update(['total_posts' => $post->total_posts]); } })->everyThirtyMinutes(); } }

As you can see, we've passed the closure function as the first argument of the call method. Also, we've set the frequency to every 30 minutes, so it'll execute the closure function every 30 minutes!

In our example, we count the total posts per user and update the statistics table accordingly.

The Artisan Command

Apart from the closures or callables, you could also schedule an artisan command that will be executed at certain intervals. In fact, that should be the preferred approach over closures as it provides better code organization and reusability at the same time.

Go ahead and revise the contents of the app/Console/Kernel.php file with the following.

<?php namespace App\Console; use Illuminate\Support\Facades\Config; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ 'App\Console\Commands\UserStatistics' ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // artisan command method $schedule->command('statistics:user')->everyThirtyMinutes(); } /** * Register the Closure based commands for the application. * * @return void */ protected function commands() { require base_path('routes/console.php'); } }

It's the command method that you would like to use should you wish to schedule an artisan command as shown in the above code snippet. You need to pass the artisan command signature as the first argument of the command method.

Of course, you need to define the corresponding artisan command as well at app/Console/Commands/UserStatistics.php.

<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; class UserStatistics extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'statistics:user'; /** * The console command description. * * @var string */ protected $description = 'Update user statistics'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { // calculate new statistics $posts = DB::table('posts') ->select('user_id', DB::raw('count(*) as total_posts')) ->groupBy('user_id') ->get(); // update statistics table foreach($posts as $post) { DB::table('users_statistics') ->where('user_id', $post->user_id) ->update(['total_posts' => $post->total_posts]); } } }The Exec Command

We could say that the methods we've discussed so far were specific to the Laravel application itself. Moreover, Laravel also allows you to schedule the shell commands so that you could run external applications as well.

Let's go through a quick example that demonstrates how to take a backup of your database every day.

<?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // exec method $host = config('database.connections.mysql.host'); $username = config('database.connections.mysql.username'); $password = config('database.connections.mysql.password'); $database = config('database.connections.mysql.database'); $schedule->exec("mysqldump -h {$host} -u {$username} -p{$password} {$database}") ->daily() ->sendOutputTo('/backups/daily_backup.sql'); } }

It's apparent from the code that you need to use the exec method of the scheduler, and you need to pass the command that you would like to run as its first argument.

Apart from that, we've also used the sendOutputTo method that allows you to collect the output of the command. On the other hand, there's a method, emailOutputTo, that allows you to email the output contents!

And that brings us to the end of the article. In fact, we've just scratched the surface of the Laravel Scheduling API, and it has a lot to offer in its kitty.


Today, we went through the task scheduling API in the Laravel web framework. It was fascinating to see how easily it allows you to manage tasks that need to be run periodically.

At the beginning of the article, we discussed the traditional way of setting up scheduled tasks, and following that we introduced the Laravel way of doing it. In the latter half of the article, we went through a couple of practical examples to demonstrate task scheduling concepts.

I hope that you’ve enjoyed the article, and you should feel more confident about setting up scheduled tasks in Laravel. For those of you who are either just getting started with Laravel or looking to expand your knowledge, site, or application with extensions, we have a variety of things you can study in Envato Market.

Should anything pop up in your mind, let’s start a conversation using the feed below!

Categories: Web Design

12 Best Free JavaScript Image Magnification Plugins

Image thumbnails are great since they cut down load time and take up less space on the page. But they’re also harder to see, even on larger screens. With...

The post 12 Best Free JavaScript Image Magnification Plugins appeared first on Onextrapixel.

Categories: Web Design

Customizing Admin Columns In WordPress

Smashing Magazine - Fri, 12/01/2017 - 08:46
(This is a sponsored article.) If you manage a WordPress website, you've probably faced a common problem. How do you get insight into all of your content at a glance? WordPress' admin area does not show you much about your pages, posts, users and comments. That can make it hard to find the right page, to check if all associated fields are properly filled, or simply to get a general sense of your website's content.
Categories: Web Design

Inheritance and Extending Objects With JavaScript

Tuts+ Code - Web Development - Thu, 11/30/2017 - 05:00

If you are familiar with object-oriented programming, you are most likely familiar with subclassing and inheritance. However, inheritance has been getting a bad rap. I believe that is because some developers see it as a catch-all solution when you need to modify a program. The problem with this is that class hierarchies can become unmanageable. 

There are other design patterns we can use to make our apps easier to understand and ready for change. I will show you examples of how you can use inheritance and the decorator and composite pattern to improve your program's design.


The idea behind inheritance is that one object "is a" specialized version of another object. There is a parent class (also known as a superclass) which defines the base properties of our object. And there is a child class (subclass) that inherits the properties of the parent class. 

An example of inheritance is a dog and a poodle. All dogs have certain features like four legs and the ability to bark. A poodle “is a” kind of dog. An SUV is a vehicle. A circle is a shape. This is what our class hierarchy would look like if we were designing a program for creating shapes.

The benefit of having a Shape class is that we can reuse the properties and methods we defined in other classes. 

Notice that the getArea method was redefined in each of our subclasses. We did not have to redefine this method, but we did it to replace our parent's implementation of the method. That is because each shape will have its own way of calculating the area. 

Overriding a parent method in a child class is an example of polymorphism. Polymorphism is the ability for objects to have multiple forms. It allows subclasses to have methods with the same name as their superclass but with different implementations.  

This is an example of what our code would look like for creating a Shape and Circle subclass:

class Shape { constructor(x, y) { this.xPosition = x; this.yPosition = y; } getArea() {...} } class Circle extends Shape { constructor(x, y, radius) { super(x, y, radius); this.radius = radius } getArea() {...} } let circle = new Circle(1,2,3);

One of the drawbacks to this design choice is that if you decide the parent class needs to change, then the subclasses may need to change too, along with all the objects we created. 

For example, suppose we decided later on that it would be better to replace the x and y parameters of the Shape class with an object. Consequently, we would need to change the constructor for all of our subclasses and the arguments for every object we instantiated.

We can see how this can easily become problematic. We would have to make sure we got our design right the first time around so that we could avoid making a change. But that is not practical, nor is it what we should be striving for. A program is an ever-evolving entity, and it’s better for us developers if we have the flexibility to make changes easily. At the very least, we should not have more than one level of child classes.

Decorator Pattern

A decorator allows us to attach properties to an object after they have been created. This means we can add functionality without subclassing or being concerned with the implementation of our object. 

Instead of thinking a circle is a shape, we could use the Shape class to create circles and wrap it with the additional properties we want. Here is an alternative to creating circle objects using a decorator:

class Shape { constructor(data) { this.x = data.x; this.y = data.y; } getArea() {...} } function CircleDecorator(shape) { shape.radius = 3; shape.getArea = function() {...}; return shape; } let shape = new Shape({x:1,y:2}); let circle = new CircleDecorator(shape);

We can add or modify members of our Shape class with a decorator as opposed to subclassing it. With our shapes example, you might find that you just want to create a circle object that has all of the properties you need and do the same for other shapes. That is fine. But a decorator allows us to reuse the code in our Shape class and modify it with the functionality that differs with each shape. As a result, we will have more objects, but more objects are easier to manage than more subclasses.

This pattern is not limited to creating graphics. You can use it in any situation where you want to add responsibilities to an object. 

For example, we may have a class that handles signing up users to our account. Before we save their information to our database, it would be wise to check that the input is valid and doesn’t contain any malicious scripts. We could decorate the class with a method to validate the information first. This same decorator can be reused anywhere in our application where we accept user input.

Composite Pattern

Objects can be composed of other objects. The view for an app can be thought of as a component that is composed of other views. If we were making a game, our game world would display all our graphics we created like circles and squares. Every time we update our view, we would need to redraw every element. We need a way to manage all of the elements as a group. 

That is where the composite pattern can help us. We can create a class that is responsible for all of the elements. When we want to redraw the elements, we call this class’s draw method, and it will call the draw method on each individual element.  

class Component { constructor(name){ this.components = []; this.element = document.createElement(name); } add(elem) { this.components.push(elem); } draw() { for (const elem of this.components) { elem.draw(); } } } class Circle { constructor(data) { this.x = data.x; this.y = data.y; this.radius = data.radius; } getArea() {...} draw() {...} } let world = new Component('div'); let circle = new Circle({x: 1, y:1, radius: 2}); let circle2 = new Circle({x: 10, y:10, radius: 2}); world.add(circle); world.add(circle2); world.draw();

A webpage can also be thought of as a component. This component could have a menu, a sidebar, and a blog post. The post would be a sub-component that has a picture, a title, and a body. The draw method for our main app component will call draw on the menu, sidebar, and post. The post component will in turn call draw on the post image, title, and body. 

Here is a view of what a web page would like divided into components:

This pattern isn’t limited to creating views. For example, if we were making a game, we might have a component to manage the elements on the screen, a component to manage the audio, and a component to manage the game state. 

These would all be inside a component I call the game engine. The game engine would have an initialize method that would call the initialize method on each of its sub-components. That is the power in using the composite pattern. Instead of dealing with individual objects, we can treat them as one object.  


Inheritance lets us reuse code by defining an object in terms of another object. The decorator pattern allows us to add responsibilities to an object without changing the original code or subclassing. The composite pattern models part-whole relationships. These patterns aren’t meant to be used in isolation. 

JavaScript has become the language of working on the web. It’s not without its learning curves, and there are plenty of frameworks and libraries to keep you busy, as well. If you’re looking for additional resources to study or to use in your work, check out what we have available on Envato Market.

They can be combined as you see fit. The examples I provided also should not be taken as the only application for using the patterns. They are just a guide. Feel free to use your creativity to apply them. There is no one way to implement them or one use case.

Categories: Web Design

Cheerful Wallpapers To Deck Your December Desktop (2017 Edition)

Smashing Magazine - Thu, 11/30/2017 - 03:59
To get you in the right mood for December and the upcoming holiday season, artists and designers from across the globe once again got their creative ideas bubbling and created festive and inspiring desktop wallpapers for you. Wallpapers that are a bit more distinctive as the usual crowd and that are bound to add some holiday cheer to your screen. All wallpapers featured in this post can be downloaded for free and come in versions with and without a calendar for December 2017.
Categories: Web Design

From Idea To Reality: Designing An App With Sketch And Xcode

Smashing Magazine - Wed, 11/29/2017 - 05:12
Everyone has an idea for a mobile app, from your mom to the guy you met in line at the grocery store. You might even be one of those people, if you are reading this tutorial. Building your own app really gives you the ability to create anything you can imagine. For some people, the idea is the easy part; when it comes to making it a reality, they have no clue where to start.
Categories: Web Design

Designing Ethics: Shifting Ethical Understanding In Design

Smashing Magazine - Tue, 11/28/2017 - 07:21
The influence of design is expanding beyond the realms of typography and objects and into healthcare, public policy, education, financial services, and more. Designers working in these emerging design fields are responsible for projects that have significant and fundamental impact on the quality of people's lives with clear ethical implications. In healthcare, for example, designers are responsible for creating everything from the industrial designer's medical device that keeps a heart beating to the service designer's physical layout of an operating room.
Categories: Web Design

A reminder about “event” markup

Google Webmaster Central Blog - Mon, 11/27/2017 - 09:01

Lately we’ve been receiving feedback from users seeing non-events like coupons or vouchers showing up in search results where “events” snippets appear. This is really confusing for users and also against our guidelines, where we have added additional clarification.

So, what’s the problem?

We’ve seen a number of  publishers in the coupons/vouchers space use the “event” markup to describe their offers. And as much as using a discount voucher can be a very special thing, that doesn’t make coupons or vouchers events or “saleEvents”. Using Event markup to describe something that is not an event creates a bad user experience, by triggering a rich result for something that will happen at a particular time, despite no actual event being present.

Here are some examples to illustrate the issue:

Since this creates a misleading user experience, we may take manual action on such cases. In case your website is affected by such a manual action, you will find a notification in your Search Console account. If a manual action is taken, it can result in structured data markup for the whole site not being used for search results.  

While we’re specifically highlighting coupons and vouchers in this blogpost, this applies to all other non-event items being annotated with “event” markup as well -- or, really, for applying a type of markup to something other than the type of thing it is meant to describe.

For more information, please visit our developer documentation or stop by our Webmaster Forum in case you have additional questions!

Posted by Sven Naumann, Trust & Safety Search Team
Categories: Web Design

Designing For A Browserless Web

Smashing Magazine - Mon, 11/27/2017 - 06:23
What happens when we take the web browser out of web browsing? Google’s new "Add to Homescreen" feature delivers fast, focused web experiences that are indistinguishable from those of a native app. What can designers learn from the successes of early adopters such as Twitter, and how can we leverage app-like design patterns to tackle this brand new set of user experience challenges? The "Add to Homescreen" installation process, as shown on Google Chrome Developer’s mobile website (Image source) (Large preview) We’ve seen debates on the topic of native versus web experiences.
Categories: Web Design

Black Friday & Cyber Monday Deals for Designers – Huge Savings!

Black Friday is a wonderful time of the year to go shopping for all sorts of things. Today, I’m bringing you a list of discounts for designers and some...

The post Black Friday & Cyber Monday Deals for Designers – Huge Savings! appeared first on Onextrapixel.

Categories: Web Design