Skip to content

Instantly share code, notes, and snippets.

View metasansana's full-sized avatar
🕺
Wine on a buffer.

Lasana Murray metasansana

🕺
Wine on a buffer.
View GitHub Profile
@metasansana
metasansana / no-setters
Created July 2, 2013 22:00
No setters please (unless necessary).
//One of the popular concepts in OOP style programming is the concept of loose coupling.
//Your objects should have everything they need to carry out their duties from the time you instansiate them (new Object).
//Failing that, you should be able to inject any missing dependecies into your classes whenever necessary.
//This does not mean you go and create a whole bunch of setters.
//Wrong!
dog = new Animal();
dog.setColor('blue');
@metasansana
metasansana / gist:5912763
Created July 2, 2013 20:21
Parasitic inheritance and constructors without the new keyword in JavaScript.
var ns= {};
ns.Object = function () {
var that = {};
that.toString = function () {
return 'I am an Object!!';
}
/*The Great Dependency Injection.*/
//This is psuedo code. Screw the syntax rules!
//No dependency injection.
class User {
private Database db;
private String email;