Template Method Pattern in Ruby

When working as a software developer, knowledge of some design patterns is always welcomed. If you’ve never heard about design patterns, they are basically some general reusable patterns for common problems that developers run into. There’s a big list of these and knowing allĀ of them is a bit hard. Well, hard might not be the right word, but it takes a lot of practice to master them all. Lets take a look at one of the (in my opinion) easier patterns - the Template Method Pattern and implement it in Ruby.

AngularJS Services Part 4: Value and Constant

So far we saw the magic of creating AngularJS services using Provider, Factory and Service. In this post, we will look at two more types of services - Value and Constant. Value The Value service is basically a service that returns a single value, like, string, object, number or an array. For instance: (function(){ angular.module('app', []) .value("Number", 24) .value("String", "Hey, how are you?") .value("Object", { prop1: 'prop1', prop2: 'prop2' }) .

AngularJS Services Part 3: Service

So, Service is basically the same as Factory, it just has one key difference. Service treats the function as a constructor, meaning, the service will call new on the function and return the resulting object as a service object. Oh, if you haven’t yet read about Factory, check out AngularJS Services Part 2: Factory. Using Service Declaring a Service is easy. Lets look at an example. 1 2 3 4 5 6 7 8 9 10 (function(){ angular.

AngularJS Services Part 2: Factory

If you don’t know the basics of AngularJS service, I recommend you read the other article I wrote on AngularJS Services Part 1: Provider. Provider v.s. Factory Factory is a thin wrapper on top of Provider. While Provider provides us the ability to configure the service provider before injection (creating the service object), Factory lacks that ability. Although it is short of this functionality, most of the Angular devs use factories because they are, in my opinion, the easiest to use and really cover all the general needs that one might need from a service.

AngularJS Services Part 1: Provider

I started using AngularJS couple of months ago, when we got a new client that wanted us to help with building an app written in Angular. After couple of months of using it, I found myself struggling with uber-phat controllers and I started thinking of solutions about extracting knowledge out of the controller into separate entities. Also, having the ability to easily inject those entities back into the controller is a must.

SOLID Principles in Ruby

Regardless of your knowledge level, as a programmer you love to write awesome code. It’s what we do. We like it and we do it every single day. But, we all know that writing awesome code is not easy at all. So, how can we improve the code we produce every day? An awareness (or a reminder!) of SOLID principles is beneficial here. SOLID is a group of five principles that when applied correctly can help us produce better code.