Blogging News

iStock Promo – Save 50% Off Vectors


Advertise here with BSA

Listen up guys! Today we have an iStock promo that is SO BIG it is only available for 24 hours so we don’t want you to miss it!

Today iStockphoto is offering 50% off credit downloads for vector illustrations. What makes this offer even better is that we still have several other iStock promo codes that still work that can be combined with today’s 50% off discount. Never have a I seen a discount this large from iStockphoto. You do the math.

Click below to grab this coupon code and start browsing iStockphoto.

10% Off iStockphoto Coupon Code


iStock Promo Details

  1. Click on the button above to unlock the 10% off iStock promo code.
  2. Select your desired credit package (remember it’s 50% off today only. Now is your chance to stock up for the rest of the year)
  3. Enter the promo code at the bottom of that page and click the “Next” button.
  4. Review your order and check out.


Advertise here with BSA


How to Craft Unique and Valuable Content for your Website


Advertise here with BSA

Building your own website is certainly a task in-and-of itself. But to then fill up your website will useful content and get those pages indexed into Google is a completely separate task. The obligations are much different and SEO factors a big role into the equation. But webmasters should feel comfortable writing their own copy and putting together pages with great content.

There cannot be any single rule that always tends to work. But we can look at trends over time and see how other websites have followed things in the past. Also don’t be afraid to do your own research on this topic, either. Hit Google and try searching for keywords related to your own niche. Study what is already out there and make a note of things that you could be doing better than the competition.

Pinpoint your Ideas

When you have the task of writing multiple articles on similar topics it will help to split up different ideas into categories. Try writing them down or saving a document with all your listed ideas, and then put them together in an organized draft. It is especially a good idea to list your talking points if the article is intended to be a long, detailed process.

writing on dell laptop computer

If I am sitting down to write a longer piece I will also go out into Google and do research to see what else is out there. You should know who you are competing with and what the results are for your targeted keywords. If there are lots of results with poor-quality websites then it should be easier for you to capitalize on these keywords.

Google can be very lenient with rankings. Be sure and check out their Webmaster Tools if you are curious about tracking your top keywords and where your website ranks on the page. The best method of securing your place in Google is by predicting which areas need more attention with more useful content, then writing your webpages to fit that description.

Build Writing off your Titles

The HTML title tag is very important because this is what Google users will read before anything else. It should be obvious if you have ever used Google before that top keywords will appear bold in the title and description, as well as the domain name. But most people have become self-trained to only skim the description and really look at what the title says.

Write your web copy based off the initial title tags and their own meanings. Try to add more narrative and talking points which will draw readers deeper into your page. The whole idea of valuable web content implies that you are writing something which contains helpful information on a given topic. You should be adding your own personal touch into the large pool of resources to be found on the Internet.

writing titles headlines sketches artists

But never forget that your title tag is the one indicator explaining what your entire page is about. People will naturally associate with this whether you mean it or not. Sometimes it is better to split articles into 2 or 3 different ideas, so they each have their own page full of talking points.

Including Digital Media

Think of some really great websites that you frequently visit for information. Often times it will be the design style, the website layout, and the color scheme which is superior than other alternatives. The text styles and content layout is easier to read and so you would prefer their method over any other.

Keep yourself in this mindset when building content and you will not stray too far off the path. Understanding which styles are “best” for your website is all about repetition. A custom web font may be a solution for spicing up an otherwise bland website. Please also consider the use of digital media aside from text like images or videos.

tumblr media blogging book how to writing

If you can illustrate a point better than tell it, find some space to include that illustration! Graphics and charts are sometimes much more handy than words. But it doesn’t take much effort to ruin the page using too many graphics. Test the ideas in your head first and determine if the graphics will be a good fit on the page. Does the extra media help to define your content? Ask questions from the reader’s point of view – your writing will turn out much stronger and easier to understand.

Final Thoughts

Keywords and meta tags are always going to be a cornerstone to good SEO practices. But when you delve deeper into the idea of content curation then we have to start thinking about how writers are publishing stuff on the web. Google indexes millions of pages every day and domain rankings also play a big part in how your website appears to others.

I do hope these ideas for writing content may be applied into your other works. It is not an easy process but those who are well-versed in writing and reading comprehension will understand the subtle differences in writing styles. And as you practice more in a specific niche the writing will get easier and more understandable. Keep up with your own works and if you have any questions or ideas feel free to share with us in the post discussion area below.


Advertise here with BSA


45 Japanese Animation; Video Game Website Layouts


Advertise here with BSA

Comparing Japanese web design trends to the United States is a great difference. Icons and banners and Flash media is all too common, especially amongst video game websites and cartoons/TV shows. The Japanese culture is so different from the western world, yet we all share the same planet and the same Internet.

I want to showcase 45 Japanese animation & gaming website layouts for design inspiration. You may not consider using these techniques in your own layouts, but it is always good to know the market. Japan’s economy is within the top 5 worldwide and they spend a lot of money online. And you do not need to understand the Japanese language to appreciate beautiful website design. It is truly magnificent how designers may communicate across language barriers to share and understand more complex design trends.

Otomate

otomate website japanese layout musics

Samurai and Dragons

samurai rpg video game website layout

D3 Publisher Inc.

d3 publisher inc company website layout

Bandai Namco

bandai namco website ui layout inspiring

Summon Night

japanese video game summon night website

Rune Factory Frontier

rune factory website layout inspiring

Dragon Quest X

dragonquest x website layout ui interface

D-Game

japanese website layout dgame interface inspiring

Dragon Quest 3DS

dragon quest ds nintendo japanese website

Kingdom Hearts HD

playstation ps3 video game website squareenix kingdom hearts

DemonGaze

demon gaze website japanese video game inspiring

Rune Factory 4

marvelous interactive video game japanese company

Accel World Channel

accel world channel website ui design

Luigi’s Mansion 3DS

luigi mansion 3ds nintendo website layout

Project Diva

ps vita japanese website layout project diva

Okami

gaming interface design ui branding okami

Atlelier Ayesha

atelier ayesha video game japanese website layout

Animal Crossing

nintendo 3ds website layout inspiring dobutsu no mori

Ragnarok Odyssey

ragnarok odyssey website layout ui design interface

One Piece Romance Dawn

one piece japanese dawn video game website

One Piece 2

anime video game website layout onepiece japanese

Jikkyou Pawafuru Puroyakyu 2012

sports baseball japanese website layout design

Lost in Blue 2

konami website lost in blue layout interface

Everybody’s Golf 6

everybodys golf video game japanese website

Harvest Moon: A New Beginning

japanese harvest moon new beginning video game layout

Harvest Moon: Hero of Leaf Valley

harvest moon bokumono hero leaf valley website

Final Fantasy X | X-2 HD

ffx ffx-2 hd remastered website japanese video game

SNK Playmore

video game playmore website inspiration japanese

Twine Brave

tales of twin brave website layout inspiring

Nameko Daihanshoku

nameko daihanshoku website japanese video game

Totomono

totomono acquire website japanese video game publisher

Ragnarok Online

ragnarok online website japanese video game

Noora Atlus

noora atlus website japanese video game inspiring

Gloria Union

atlus gloria japanese website layout design videogame

Ocarina of Time 3D

legend of zelda ocarina of time remake nintendo 3ds japanese

Starfox 3D

japanese video game starfox website interface

Pokemon Mystery Dungeon

mystery dungeon gates to infinity website japanese 3ds

Portal 2

portal2 website ui video game japanese interface

The Last Promise

jrpg japanese website layout last promise inspiration

PlayStation mk2

inspiration website design layouts playastation sony interface

Fairy Tail

fairy tale website japanese video game

Yu-Gi-Oh! Nightmare Troubadour

yugioh nightmare troubadour website interface japanese

Monster Farm Channel

tecmo website japanese monster farm rancher

Gamepot

inspiration website layout gamepot japanese ui

Final Fantasy XIV

square enix final fantasy 14 realm reborn website layout


Advertise here with BSA


Russian oligarch buys $100 million stake in Apple

Russian billionaire, Alisher Usmanov, who counts a 30% stake in Arsenal FC among his portfolio of investments has spent $100m on Apple stock, according to Bloomberg.

The Uzbek-born oligarch, said to be Russia’s richest man, with a fortune in excess of $18bn, made a 10-fold return on an investment in Facebook and is confident that he’ll profit from his most recent outlay.

‘I believe in the future of this company even after Steve Jobs,’ said Usmanov in an interview with Bloomberg. ‘When the company lost $100 billion of its market value, it was a good time to buy its shares, as the capitalization should rebound.’

The Russian business magnate’s vote of confidence in Apple will be a welcome boost for CEO Tim Cook, who has had to endure a 40% drop in the value of the company in the space of six months.

Usmanov’s investment may also have been prompted by Apple’s recently-announced plan to significantly increase the amount it will return to shareholders over the next few years. ‘For the next three years I believe Apple is a very promising investment, especially given large dividend payments and buybacks,’ he told Bloomberg.



RandMcNally Brings Its Classic Road Atlas to iPad

Randmcnally

Feed-twFeed-fb

Before everyone had a smartphone in their pocket, a good road atlas was found in every car’s glove box, with many of those created by Rand McNally.

A staple in the space for the past 90 years, the Atlas creator celebrated its 90th birthday this week with the release of an ebook version of its 2014 Road Atlas as well as an interactive iPad app.

The digital version of the Atlas includes updated maps for all 50 states as well as Canadian provinces, Mexico and Puerto Rico, and detailed inset maps for larger cities and national parks. Much like its analog predecessor, the digital version can be used anywhere once you download it, and doesn’t require a data connection. Read more…

More about App, Map, Ipad, Tech, and Apps Software


Social Media Tips From Gary Vaynerchuk

This is a guest article contributed by Tom Jones.

Vayniacs near and far would all agree. Tacking a sticky-note of your favorite social media tips from Gary Vaynerchuk on your computer screen can help you crush it online — whatever your “it” may be.

For Vaynerchuk, the first “it” he crushed was wine.

Gary Vaynerchuk

From the wine, out poured a whole new passion for social media and what it can do to turn an all-consuming interest into a cash-generating online career. CEO and co-founder of his social media brand consulting firm, vaynermedia.com, Vaynerchuk first earned his online claim to fame as an outspoken, offbeat wine review and advice video blogger. Offline, he co-owned and directed operations of a retail wine business.

Currently a public speaker on all things wine AND social media, he authored the book, Crush It! Why NOW Is The Time To Cash In On Your Passion. The book earned him a spot on both the New York Times and Wall Street Journal bestseller lists.

But as most Vayniacs know, it’s the Stellar Sticky-Note Status he’s earned from his now “lifelong friend connections” that really sticks with his followers over time. So what does Mr. Vino and his Vayniacs do with all their passion?

Here are seven all-time favorite sticky-note social media tips from Gary Vaynerchuk to help his Vayniacs crush it online:

1. Be Happily Flawed

“Be happy with who you are…. Be you… Be every flaw.”

Too many people start with a false idea that if they just do “this” thing… then “that” will make them happy. They need to start being happy… period.

If it takes courage to be happy, just for the sake of being happy, then take courage. If it takes courage to just “be you” without first making major improvements, then take courage and just be you. If it’s too scary or embarrassing for you to embrace ALL your flaws, then find a way to take courage, to discipline yourself to embrace every scary, embarrassing flaw.

The point is… NOW is your time. Now is your time to be happy.

Now, at any given moment, is all you ever have. History’s gone. Tomorrow’s not here yet. Now is it.

Be happy with who you are, be you, and be every flaw. This is Vaynerchuk’s leadership. This is how you lead yourself to being happy now. Lead yourself with this example until it sticks. In time, others will follow.

2. Create Content, Conversation & Cash

“It’s about putting up good content, creating conversation, and spending ten percent of your time working out how to make money.”

Getting caught up in shiny-object cycles, being distracted at every turn, letting your lack of knowledge in certain areas consume and displace your passion and expertise in what counts, counting money before it’s earned… can all turn a promising online career into a nightmarish black-cashless-hole.

If you focus ALL your efforts on putting up excellent content and creating honestly helpful and interesting conversations, you’ll soon have that 10% extra time to figure out how to monetize the good works you’ve created.

This will give you the following and momentum you need to propel your passion forward with increasingly less effort and stress. The point is… create content and conversation first, then monetize.

Crush It Book

3. Create Connections

“Your job is to create a connection.”

You can talk, talk, talk all day long and never make one honest, real connection with another human soul. But you’ve only got one real job online… and your job is to “create” a connection. Your job is to find the connection between you and that “one” follower at a time, heart-to-heart, soul-to-soul.

If you focus on that one connection until it clicks and sticks, then others will watch, listen, and follow you, too. Your only real job is to find, create and nurture that one connection. Once connected, simply do it again… and again…

4. Continue Lifelong Conversations

“Induce conversation at every turn for the rest of your life.”

Once you create those connections, just keep starting conversations with your connections… again and again… for the rest of your life. No kidding. But if you’ve truly connected and clicked with your followers, you’re making friends… lifelong friends.

And the funny thing about lifelong friends who you share a passion with is that you can always pick up your conversation where you left off… no matter how long it’s been between conversations. Your job is to turn connections into friends with whom you’ll have lifelong conversations about something you’re both passionate about.

5. Listen Up & Pay Attention For Life

“Answer every single email and every single comment on your blog for the rest of your freaking life.”

There’s a saying about the best way to “pay a compliment” to someone you care about and that is to just “pay attention” to them. So another part of your job is to simply listen up and pay attention to those who reach out to you in emails and comments by responding to them in return. And, of course, responding to each and every email and comment sent to you for the rest of your life.

And as Gary so passionately expressed it, listen up and pay attention “for the rest of your freaking life.” In other words, just be the kind of friend you want to have… a freaking lifelong friend.

Friends

6. Concentrate on Your Strengths & Outsource Stress

“If you’re not good at monetizing, get a business partner that can do that. You do what you do and bring in others who can do the other stuff.”

Whatever causes you stress — including any monetization task — just outsource it. Creating and sharing your passion through great content, making lifelong connections, listening up and paying attention to your followers all should bring you joy, not stress.

Whatever doesn’t bring you joy, but instead brings you stress, simply outsource it.

The process of monetizing your business is an essential prime goal; however, if that is not your expertise, then outsource this task to someone who has a passion and talent for monetizing online businesses. That’s a priority lifetime connection worth your investing time, attention, and money.

7. Brrrand It!

And finally, while not a direct quote, a seventh takeaway could easily be added here on branding. From his Wine Library TV to his Daily Grape video channel to all his Vayniac followers, there’s no denying this blogger’s been a master at branding — faux pas, foibles, flaws and all.

So add a “Brand It” sticky-note to your list of social media tips from Gary Vaynerchuk… if there’s still room on your computer screen… then grab your passion and go crush “it” online, fellow Vayniac, whatever your “it” may be.

More Social Media Articles

Guest post contributed by Tom Jones on behalf of make-a-web-site.com – Click here for more information on making a website. Tom is a freelance writer who enjoys writing for a range of sources. Image credits: shopify.com, boagworld.com.


© This article is copyright of JUST™ Creative and should not be found elsewhere.


Analytics Pros Best Practices Conference: May 2, San Francisco

The following is a guest post contributed by Caleb Whitmore, founder of Analytics Pros and the BEST Practices Conference, Google Analytics enthusiast, and aspiring mountaineer.


Join us on May 2nd in San Francisco to learn about the best practices for Google Analytics. At this interactive conference you will be engaged, learn strategy for Google Analytics and be trained in using and optimizing the tool.
We think about our conference like this:


 Looks like useful fun, right?  We promise it will be well worth your time.  
A side note, just in case you were wondering: my prior conference, GAUGE (now “retired”) was an initiative to bring together users across the Google Analytics community to learn from each other. The BEST Practices conference series builds on this legacy and delivers hands on tutorials and interactive sessions.
Look forward to hear from thought leaders in the Google Analytics space, including Google’s Jesse Nichols, Andrew Wales and Ian Myszenski.  We are excited to have Dan Siroker from  Optimizely and I will weigh in with my latest finds and processes as well.  We will talk and work with you on Universal Analytics, Multi-Channel Funnels, Attribution Modeling and more tips and tricks that we apply to our use of GA. 
Our San Francisco conference includes:
  • An after-party event hosted by the Google Analytics Premium team at the San Francisco Google office
  • Hands-on sessions and workshops led by top GA experts
  • Interactive “Table Topics” lunch session, including teaching and roundtable discussion on Universal Analytics, Google Tag Manager, Mobile Strategy and more
  • Opportunities to interact with digital analytics peers and experts
  • Insights into the Google Analytics strategies of leading companies
  • An amazing conference venue that allows for big-picture thinking, the Jewish Contemporary Museum
Join us in San Francisco on May 2nd for our Spring event.  Use discount code BESTAnalyticsBlog for a 20% discount off the Conference Pass. We also offer a 50% discount for government, non-profit employees and full-time students.
And don’t forget to check out other BEST Practices conferences as we storm the country. We’re headed to Boston on October 3rd and back to the Pacific Northwest in Seattle on November 14th – don’t miss out!
To keep up to date on what’s coming, follow our team at @analyticspros and @BEST_con to hear about the latest speakers, locations and events. As a bonus, this video should provide a good introduction to our event if you’ve never been to one in the past:
We hope to see you in San Francisco this Spring. Happy analyzing!
Posted by Caleb Whitmore, Google Analytics Certified Partner


This Is How Far North Korea’s Missiles Can Reach


North-korea-missiles

Feed-twFeed-fb

North Korea on Friday reportedly moved two mobile missiles believed to be of intermediate range to the country’s east coast, potentially putting them within striking distance of Japan and American bases in Guam. If the reports are accurate, it’s the latest escalation in an increasingly tense situation which may result in a military conflict.

North Korea’s threatening language towards South Korea and the United States is becoming increasingly bellicose, going so far as to approve the use of nuclear weapons should a military conflict break out on the Korean peninsula. Propaganda videos from North Korea have claimed the country could turn Seoul, Washington and other cities into a “sea of flames” — but North Korea is notorious for outlandish provocations that simply aren’t supported by reality. Read more…

More about World, North Korea, and Us World


A Thorough Introduction To Backbone.Marionette (Part 2)


  

In the first part of this series, we discussed Backbone.Marionette’s Application. This time around, we’ll discuss the module system that is included in Backbone.Marionette. Modules are accessible through the Application, but modules are a very large topic and deserve an article dedicated to them.

What Are Modules?

Before we get into the details of how to use Marionette’s module system, we should make sure we all have a decent definition of a module. A module is an independent unit of code that ideally does one thing. It can be used in conjunction with other modules to create an entire system. The more independent a unit of code is, the more easily it can be exchanged or internally modified without affecting other parts of the system.

For this article, that’s about as much as we need to define modules, but if you want to learn more about writing modular code, plenty of resources are on the Internet, of which the “Maintainability Depends on Modularity” chapter of Single Page Apps in Depth is one of the better ones out there.

The JavaScript language doesn’t currently have any built-in methods for defining modules (the next version should change that), but many libraries have arisen to provide support for defining and loading modules. Marionette’s module system, sadly, doesn’t provide support for loading modules from other files, but it does offer some functionality that other module systems do not have, such as the ability to start and stop a module. We’ll cover more of that later. Right now, we will just start with defining a module.

Module Definition

Let’s start with the most basic of module definitions. As mentioned, modules are accessible through the Application, so we need to instantiate one of those. Then we can use its module method to define a module.


var App = new Backbone.Marionette.Application();

var myModule = App.module(‘myModule’);

That’s pretty simple, right? Well, it is, but that’s the simplest module we can create. What exactly did we create, though? Essentially, we told the application that we want a barebones module, with no functionality added by us, and that it will be named myModule (according to the argument we passed into module). But what is a barebones module? It’s an instantiation of a Marionette.Module object.

Module comes with a bit of functionality baked in, such as events (through EventAggregator, which we’ll discuss thoroughly in a later article), starting with initializers (just like Application has), and stopping with finalizers (we’ll go over that in the “Starting and Stopping Modules” section).

Standard Module Definition

Now let’s look at how to define a module with some of our own functionality.


App.module("myModule", function(myModule, App, Backbone, Marionette, $, _){
    // Private Data And Functions
    var privateData = "this is private data";

    var privateFunction = function(){
        console.log(privateData);
    }

    // Public Data And Functions
    myModule.someData = "public data";

    myModule.someFunction = function(){
        privateFunction();
        console.log(myModule.someData);
    }
});

As you can see, there’s a lot of stuff in there. Let’s look at the top line and work our way down. Just like before, we call App.module and provide a name for the module. But now we’re also passing a function in, too. The function is passed several arguments. I bet you can figure out what they are, based on the names I’ve given them, but I’ll still explain them all:

  • myModule is the very module you’re trying to create. Remember, it’s already created for you, and it’s a new instance of Module. You’re probably going to want to extend this with some new properties or methods; otherwise, you might as well stick with the short syntax that doesn’t require you to pass in a function.
  • App is the Application object that you called module on.
  • Backbone is, of course, the reference to the Backbone library.
  • Marionette is the reference to the Backbone.Marionette library. It is actually available through Backbone, but this allows you to alias it and make it a shorter name.
  • $ is your DOM library, which will be either jQuery or Zepto (or possibly something else in the future).
  • _ is a reference to Underscore or Lodash, whichever you’re using.

After that, you can actually pass in and use custom arguments. We’ll go over this in a bit.

Normally, I would say that most of these arguments are unnecessary; after all, why wouldn’t you already have access to these references? However, I could see these being useful in a couple of situations:

  • A minifier can shorten the names of the arguments, saving some bytes.
  • If you’re using RequireJS or some other module loader, you only need to pull in the Application object as a dependency. The rest will be available through the arguments given to you by Module.

Anyway, let’s get back to explaining the rest of what’s going on in the code above. Inside the function, you can utilize the closure to create private variables and functions, which is what we’ve done. You can also expose data and functions publicly by adding them as properties of myModule. This is how we create and extend our module. There is no need to return anything because the module will be accessible directly through App, as I’ll explain in the “Accessing a Module” section below.

Note: Make sure that you only try to add properties to your module variable and do not set it equal to something (for example, myModule = {…}), because when you set your module variable to something, that changes what the variable’s name is referencing, and none of the changes you specify will show up in your module later.

Earlier, I noted that you can send in custom arguments. In fact, you can send in as many custom arguments as you want. Take a look at the code below to see how it’s done.


App.module("myModule", function(myModule, App, Backbone, Marionette, $, _, customArg1, customArg2){
    // Create Your Module
}, customArg1, customArg2);

As you can see, if you pass additional arguments to module, it will pass those in to the function that you are defining your module in. Once again, the biggest benefit I see from this is saving some bytes after minification; other than that, I don’t see much value.

Another thing to note is that the this keyword is available within the function and actually refers to the module. This means you don’t even need the first argument, but you would lose the advantage of minification if you didn’t use the argument. Let’s rewrite that first code using this so that you can see that it’s exactly the same as myModule.


App.module("myModule", function(){
    // Private Data And Functions
    var privateData = "this is private data";

    var privateFunction = function(){
        console.log(privateData);
    }

    // Public Data And Functions
    this.someData = "public data";

    this.someFunction = function(){
        privateFunction();
        console.log(this.someData);
    }
});

As you can see, because I’m not using any of the arguments, I decided not to list any of them this time. It should also be obvious that you can skip the first argument and just use this.

Split Definitions

The final thing I’ll mention about defining modules is that we can split up the definitions. I don’t know exactly why you would want to do this, but someone might want to extend your modules later, so splitting up the definitions might help them avoid touching your original code. Here’s an example of split definitions:


// File 1
App.module("myModule", function(){
    this.someData = "public data";
});

// File 2 
App.module("myModule", function(){
    // Private Data And Functions
    var privateData = "this is private data";

    var privateFunction = function(){
        console.log(privateData);
    }

    this.someFunction = function(){
        privateFunction();
        console.log(this.someData);
    }
});

This gives us the same result as the previous definition, but it’s split up. This works because in File 2, the module that we defined in File 1 is being given to us (assuming that File 1 was run before File 2). Of course, if you’re trying to access a private variable or function, it has to be defined in the module definition where it is used because it’s only available within the closure where it is defined.

Accessing A Module

What good is creating modules if we can’t access them? We need to be able to access them in order to use them. Well, in the very first code snippet of this article, you saw that when I called module, I assigned its return value to a variable. That’s because we use the very same method to both define and retrieve modules.


var myModule = App.module("myModule");

Normally, if you’re just trying to retrieve the module, you’ll pass in the first argument, and module will go out and grab that module for you. But if you pass in a function as the second argument, the module will be augmented with your new functionality, and it will still return your newly created or modified module. This means you can define your module and retrieve it all with a single method call.

This isn’t the only way to retrieve modules, though. When a module is created, it is attached directly to the Application object that it was constructed with. This means you can also use the normal dot notation to access your module; but this time, it must be defined beforehand, otherwise you’ll get undefined back.


// Works but I don't recommend it
var myModule = App.myModule;

While this syntax is shorter, it doesn’t convey the same meaning to other developers. I would recommend using module to access your modules so that it is obvious you are accessing a module and not some other property of App. The convenience and danger here is that it will create the module if it doesn’t already exist. The danger comes if you misspell the name of the module; you won’t have any way of knowing that you didn’t get the correct module until you try to access a property on it that doesn’t exist.

Submodules

Modules can also have submodules. Sadly, Module doesn’t have its own module method, so you can’t add submodules to it directly, but that won’t stop us. Instead, to create submodules, you call module on App, just like you used to do; but for the name of the module, you need to put a dot (.) after the parent module’s name and then put the name of the submodule.


App.module('myModule.newModule', function(){
    ...
});

By using the dot separator in the module’s name, Marionette knows that it should be creating a module as a submodule of the module before the dot. The cool (and potentially dangerous) part is that if the parent module isn’t created at the time that you call this, it will create it along with its submodule. This can be dangerous because of the same potential for misspelling that I mentioned earlier. You could end up creating a module that you didn’t intend to create, and the submodule would be attached to it, instead of to the module you intended.

Accessing Submodules

As before, submodules can be accessed the very same way they are defined, or you can access them as properties of the module.


// These all work. The first example is recommended
var newModule = App.module('myModule.newModule');
var newModule = App.module('myModule').newModule;
var newModule = App.myModule.newModule;

// These don't work. Modules don't have a 'module' function
var newModule = App.myModule.module('newModule');
var newModule = App.module('myModule').module('newModule');

Any of these methods of accessing the submodule will work equally well if both the module and submodule have already been created.

Starting And Stopping Modules

If you read the previous article in the series, about Application, you will know that you can start an Application with start. Well, starting modules is the same, and they can also be stopped with stop.

If you recall (assuming you’ve read the previous article), you can add initializers with addInitializer to an Application, and they will be run when it is started (or will run immediately if the Application has already started). A few other things happen when you start an Application. Here are all of the events, in order:

  • fires the initialize:before event,
  • starts all of the defined modules,
  • runs all of the initializers in the order they were added,
  • fires the initialize:after event,
  • fires the start event.

A Module behaves in a very similar way. The number of events and some of the names of the events are different, but overall it is the same process. When a module is started, it:

  • fires the before:start event,
  • starts all of its defined submodules,
  • runs all of its initializers in the order they were added,
  • fires the start event.

The stop method is also very similar. Instead of adding initializers, though, you need to add finalizers. You do this with addFinalizer and by passing in a function to run when stop is called. Unlike with initializers, no data or options are passed along to each of the functions. When stop is called, it:

  • fires the before:stop event,
  • stops its submodules,
  • runs its finalizers in the order they were added,
  • fires the stop event.

Initializers and finalizers aren’t only meant for use by others. In fact, they are quite helpful when used inside the module definition. This way, you can define a module inside the definition without actually creating any objects to be used, but then write your initializers to start creating the objects and setting them up, such as in the example below.


App.module("myModule", function(myModule){
    myModule.startWithParent = false;

    var UsefulClass = function() {...}; // Constructor definition
    UsefulClass.prototype ... // Finish defining UsefulClass
    ...

    myModule.addInitializer(function() {
        myModule.useful = new UsefulClass();
        // More setup
    });

    myModule.addFinalizer(function() {
        myModule.useful = null;
        // More tear down
    });
});

Automatic And Manual Starting

When a module is defined, by default it will automatically start at the same time that its parent starts (either the root Application object or a parent module). If a module is defined on a parent that has already started, it will start immediately.

You can set up a module to not start automatically by changing its definition in one of two ways. Inside the definition, you can set a module’s startWithParent property to false, or you can pass an object (instead of a function) to module that has a startWithParent property set to false and a define property to replace the normal function.


// Set 'startWithParent' inside function
App.module("myModule", function(){
    // Assign 'startWithParent' to false
    this.startWithParent = false;
});

// -- or --

// Pass in object 
App.module("myModule", {
    startWithParent: false,

    define: function(){
        // Define module here
    }
});

App.start();

// myModule wasn't started, so we need to do it manually
App.module('myModule').start("Data that will be passed along");

Now the module won’t autostart. You must call start manually to start it, as I did in the example above. The data that is passed to start could be anything of any type, and it will be passed along to the submodules when they’re started, to the initializers, and to the before:start and start events.

As I said, data isn’t passed along like this when you call stop. Also, stop must be called manually, and it will always call stop on submodules; there is no way around this. This makes sense because a submodule shouldn’t be running when its parent isn’t running, although there are cases when a submodule should be off when its parent is running.

Other Events And Built-In Functionality

I mentioned that Module comes with some baked-in functionality, such as the EventAggregator. As discussed, we can use the on method on a module to watch for events related to starting and stopping. That’s not all. There are no other built-in events, but a module can define and trigger their own events. Take a look:


App.module('myModule', function(myModule) {
    myModule.doSomething = function() {
        // Do some stuff
        myModule.trigger('something happened', randomData);
    }
});

Now, whenever we call doSomething on the module, it will trigger the something happened event, which you can subscribe to:


App.module('myModule').on('something happened', function(data) {
    // Whatever arguments were passed to `trigger` after the name of the event will show up as arguments to this function
    // Do something with `data`
});

This is very similar to the way we do things with events on collections, models and views in normal Backbone code.

How We Might Actually Use A Module

The modules in Marionette can definitely be used to define modules very similarly to any other module definition library, but that’s actually not how it was designed to be used. The built-in start and stop methods are an indication of this. The modules that Marionette includes are meant to represent somewhat large subsystems of an application. For example, let’s look at Gmail.

Gmail is a single application that actually contains several smaller applications: email client, chat client, phone client and contact manager. Each of these is independent — it can exist on its own — but they are all within the same application and are able to interact with one another. When we first start up Gmail, the contact manager isn’t up, and neither is the chat window. If we were to represent this with a Marionette application, each of those sub-applications would be a module. When a user clicks the button to open the contact manager, we would stop the email application (because it becomes hidden — although, for speed, we could keep it running and just make sure it doesn’t show in the DOM) and start the contacts manager.

Another example would be an application built largely out of widgets. Each widget would be a module that you can start and stop in order to show or hide it. This would be like a customizable dashboard such as iGoogle or the dashboard in the back end of WordPress.

Of course, we’re not limited to using Marionette’s modules in this way, although it’s difficult to use it in the traditional sense. This is because Marionette’s modules are fully instantiated objects, while traditional modules are “classes” that are meant for instantiation later.

Conclusion

Phew! That’s a lot of information. If you’ve made it this far, I commend you (although it was much easier for you to read this than for me to write it). Anyway, I hope you’ve learned a lot about the way that Marionette handles defining, accessing, starting and stopping modules and submodules. You may find it to be a very handy tool, or you might choose to completely ignore its existence. That’s one of the great things about Backbone and Marionette: most of their features are largely independent, so you can pick and choose what you want to use.

Credits of image on front page: ruiwen

(al) (ea)


© Joseph Zimmerman for Smashing Magazine, 2013.


  • Pope Moore
  • Newsletter Subscription

    Subscribe to our free weekly newsletter.

    Our strict privacy policy keeps your email address 100% safe & secure.

  • Copyright © 1996-2010 Blogs-design.com. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress