Creative Meat Blog
Development

Oneupweb : OOP Naming Conventions

Posted by Robert in Development, Opinions, Tutorials on January 18, 2012 - 6:10 pm

While working with different Object Oriented Programming (OOP) languages and frameworks, I’ve seen quite a few approaches on how to format various items. The line between personal preference and “best practices” has become blurry when dealing with naming conventions.

I have no idea what I'm doing: dog on a computer.Some decent advice on that subject is to adapt to the style of the current environment. However, even within languages it’s not uncommon to find inconsistencies. For example, take a look at the concatenated acronyms in XMLHttpRequest for JavaScript. XML is all uppercase, while Http is mixed upper and lowercase. There is no clear text treatment, making it unintuitive and more difficult to remember.

For this reason, it is a good idea to treat acronyms as words. While not immediately clear, it eliminates the guess work when attempting to recall a particular class, method or attribute; especially since acronyms tend to evolve. For example, the phrase “Away From Keyboard” eventually became “AFK” and is commonly typed as “afk”. By treating it as a word, you won’t have to guess which casing to use, just follow your chosen convention.

So, what if you have the chance to write your own library from the ground up? Perhaps something portable that shouldn’t be married to one particular language or uses many languages; what naming practices should you follow then? Of the examples I’ve seen and used in the past, here is what I personally prefer on a basic level.

class ClassName
{
  public static const MAX_USERS = 15;

  public var variable_name = "foo";

  private var _variable_name = "bar";

  public function methodName()
  {
    // do something
  }

  private function _methodName()
  {
    // do something
  }
}

ClassName

Classes use upper camel case, meaning each concatenated word begins with a capital letter followed by lowercase letters.

class ClassName
{
  // stuff
}

methodName

Methods use lower camel case, meaning the first word is all lowercase, while each additional word begins with a capital letter followed by lowercase.

public function methodName()
{
  // do something
}

variable_name

Variables use lowercase words, separated with underscores. They are dynamic objects that are usually defined on a per instance basis.

public var variable_name = "hello world!";

CONSTANT_NAME

Constants use uppercase words, separated with underscores. They are unchanging values and are typically also static (accessible directly from a class).

public static const CONSTANT_NAME = "foobar";

// accessible through the containing class without a need to instantiate.

var variable_name = ClassName.CONSTANT_NAME;

_private_variable and _privateMethod

Private variables and methods are prefixed with “_” (underscore). They are accessible only from within the object instance in which they are used. By placing an underscore before the name, the scope is instantly recognizable, keeping them separate from public variables and methods.

private var _variable_name= "foo";

private function _methodName()
{
  return "bar";
}

There are other considerations that play even deeper into personal preference, such as curly-bracket “{}” placement for functions vs loops vs if-statements. Spacing for within and around parentheses “()” is equally preferential. How you format your code is ultimately up to you and how you find it the most readable.

Again, what I mentioned above is very generalized and won’t necessarily stand well in some languages. Adapt to your environment and please, do leave comments below. I enjoy reading other programmers thoughts and opinions.

GD Star Rating
loading...
Fresh Meat

Oneupweb : ROSI trax™—The Value of a Like

Posted by Robert in Fresh Meat, Tools on December 1, 2011 - 9:01 pm

ROSI trax™ is a new service that Oneupweb offers to its clients to measure the ROI generated from social networking. There are two major components; one is a URL shortening service, and the other deals with social buttons. This article will describe the button aspect of the service.

Setting the stage for ROSI trax:

For this demonstration we will refer to an imaginary company named Mootropolis; a business which sells frozen dairy treats on their eCommerce site.

They serve a plethora of unique flavors and have incorporated Facebook as a means to spread the word. Each product has its own Facebook “Like” button, enabling their customers to easily tell friends and family what their favorite flavors are.

Our customer today is Sally, who happens to be an ice cream enthusiast with a Facebook account. She has just received her first order from Mootropolis and is discovering many new flavors that she just couldn’t be more excited about; her favorite being The Great Moodini.

Naturally, she returns to the Mootropolis website with a goal to further satisfy her taste buds.

How social buttons work without ROSI trax:

Sally enjoyed the Moodini so much, that she decided to tell her friends about it. During her next order she clicks the Like button from the product page and writes a short blurb.

The blurb, along with a description of the page and an icon, appear on Sally’s wall for her friends and family to see.

Some of her friends click the link, and a few even place an order.

Word-of-mouth brought business to the website, and it was made easy through the click of a Like button on the Mootropolis website.

That sounds great! So what’s the problem?

While Facebook provides basic statistics for button clicks, it does nothing with the traffic generated as a result. Furthermore, there is no concept of a conversion or sale.

So while the number next to the Like button may have increased, the value of that number is lost.

How social buttons work with ROSI trax:

With a little bit of wizardry, the value of a Like can be measured accurately in real-time with ROSI trax™.

When one of Sally’s friends finds their way to Mootropolis through her post, ROSI trax™ will record the visit.

When a purchase is made by one of her friends, it records the sale and associates it with the Facebook Like button that Sally originally clicked.

Sounds simple! But what does ROSI trax provide?

ROSI trax™ has comprehensive reporting that includes the total and unique visits, number of conversions, and total and average sales over a given time period. The stats can be organized in a variety of ways to get results meaningful to your goals, allowing you to effectively measure the value of a Like.

But it doesn’t stop with Facebook! The whole process can be implemented on any social network, including Twitter and Google+.

Great! Sign me up!

ROSI trax™ is simple to implement and is only available to Oneupweb clients. Contact a member of the Oneupweb sales team to discuss the possibilities today! Request a Proposal »

GD Star Rating
loading...
Design

Oneupweb : Before and After—Halloween 2011

Posted by Robert in Design, Freebies on October 31, 2011 - 8:47 pm

Oneupweb celebrated Halloween with a costume party this past Friday. Over half of the employees dressed up for the event which included pizza, games and a costume contest; the winners of which received a gift certificate to a delicious local restaurant named Trattoria Stella (usually referred to as Stella’s).

To express my excitement for the return of the Arrested Development series (and new movie), I dressed as Tobias Funke, who as a reoccurring joke is painted as a member of the Blue Man Group.

Below is a group photo of us, followed by an identical photo with some alterations.

Can you find all seven changes? (click photo to enlarge)

Give up? Click here to see the alterations.

GD Star Rating
loading...
Design

Oneupweb : Before and After—State Volunteers

Posted by Robert in Design, Opinions on September 8, 2011 - 9:02 pm

Once per month the fine individuals at Oneupweb volunteer their time to bring joy and happiness to the entire Earth. Well, maybe not the entire Earth. Okay, so I’m exaggerating.

Never the less, the evening attendees of the Traverse City State Theatre are very appreciative. The majestic, one screen movie theatre, located in downtown Traverse City depends on its volunteers in order to stay functional everyday.

To honor my fellow coworkers, I have decided to feature them in one of my Before and After photo searches.

Can you find all seven changes?

Give up? Click here to see the alterations.

GD Star Rating
loading...
Opinions

Oneupweb : Black Bieber

Posted by Robert in Opinions on July 7, 2011 - 2:46 pm

Once upon a time there were two Oneupweb employees. They got along rather well, until one day one of them decided to manipulate the other one’s photo in a blog post. The offended one sought his revenge, however mild it was. After all, the original post was not intended to harm, that was only his perception.

The two were able to draw a truce and went on their merry little ways, coexisting in perfect workplace harmony.

Then one day a dark ninja employee leaped from the shadows and struck a critical blow to both of their egos. One screamed in terror, the other shrieked in agony. The two who once played a friendly battle of pride had found a common enemy and must now unite to smite their foe.

The bar has risen from playful to hostile. So then, without further ado, I give you the media heyday event of the year…

BLACK BIEBER: Just Duet 4 Luv

Rebecca Black and Justin Bieber…a deadly strike indeed, but will he recover to counter the attack? Only time will tell!

GD Star Rating
loading...