Translate

Archive for the 'Geeklife' Category

5 Object Oriented Programming Principles learned during the last 15 years

Wednesday, February 1st, 2012

It was about 15 years ago when I first created my first class.

I went from thinking of Object Oriented programming as this awesome paradigm I should know about, I remember having all these mental models of what objects where and learning all this new vocabulary that I really didn’t fully grasp until years later when I was designing and implementing bigger more complex systems.

At first I remember looking at objects as a collection of functions that kept a common reference to keep internal states and missing out on all the great features of inheritance and abstract classes. Looking at “interfaces” and using them like a recipe without really knowing their true power, I look at the past and I was so limited, hopefully I’ll look at this post 15 years from now and think the same.

There’s lots of books out there on best programming practices you should follow, on this short post I’ll share with you 6 principles that I follow that I promise you will make your code behave really well, less bug prone, simple and elegant when it comes to Object Oriented design. This advice will probably apply better if you code in a language like Java or C#, I’m not sure if you can say these principles will apply 100% to other OO languages (for instance those that allow multiple inheritance)

1. DRY principle.
This is one of the most preached ones, and I will also preach it. DO NOT REPEAT YOURSELF. Really, don’t. It ALWAYS comes to bite you in the ass if you have repeated code. Only repeat yourself if it’s too hard to not do so or if you’re absolutely sure that you won’t repeat yourself a third time, but I promise you that third time will come if it’s not for you for the next guy maintaining that code.

The obvious benefit of not repeating yourself is that you get to maintain code only in one place, the added benefit will be that your code will almost start being written by itself like a perfect equation as it grows. DRY code will be reusable, maintainable and the other principles I’ll talk about are related to the DRY principle in one way or another.

2. Keep the scope at the minimum, be as private as possible.

Keep your variables as close to your local scope as possible. This will save you many headaches, will protect you from bugs in logic because you did something to a variable in place where it shouldn’t have been in the first place, and it will keep things simpler.

This also tells you that your classes should expose as little as possible. Keep your variables local, if they can’t be local, try to keep them as private members, if they have to be used by extending classes keep them private, only use public when you really know it’s ok to make something public and that nobody is going to break the behavior of your object if they play with things at any point in time.

Keeping scope at a minimum can also prevent issues on longer lived objects like singletons that might be accessed by different objects. If you abuse the use of object properties you could have one object changing the internal state of the object while another tries to do something and you’ll get unexpected behavior, this tends to happen a lot in multithreaded environments where programmers are not careful and forget objects might be accessed by different threads/clients at the same time, tight scopes will protect you.

3. Be functional
Sometimes you’ll be tempted to be lazy and not pass parameters on a method and think that you’re so clever by changing an internal property of an object so that another function in the object will then get it. Big mistake buddy. This can be equivalent to that advice from functional programming languages where you’re told that using global variables are a bad idea.
Yes, we have object properties for several reasons, but if the logic of a method depends on the state of a variable, you might as well be explicit and pass it in the method.

This is in a way related to keeping scope at the minimum, and to some extend related to the advice some give of keeping your objects as immutable as possible.

4. Only abstract classes are worth extending.
If you have control over the class you are about to extend (if it’s in your codebase) before you extend that class take a look and make sure that it’s an abstract class. Abstract classes are MEANT to be extended, so you can be safe that you’re doing the right thing here.

If you’re extending a non abstract class, you should probably be composing it instead. If you don’t have access to the code of the class you are extending, things could not behave as expected when you extend, not all programmers are as thoughtful as you are.

5. Keep Object lifetime as short as possible.
This goes back to keeping scopes tight and trying to avoid singletons as much as possible (as convenient as they might be), in the case of java the JRE has a better time collecting garbage and will save you from memory leak headaches. Put those factories to work.

Feel free to disent and share your favorite principles, If you’ve coded long enough I’m sure you tend to think about these things too and I’d love to learn from your experiences.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

#IWasThinking S01E04 Making our own “Secret” Society

Tuesday, January 10th, 2012

Thanks for watching! Unlike Uslar Pietri’s “Invisible Friends” on YouTube you don’t have to be invisible! Send a video response or leave a comment below.

On this episode
Wish I was part of a secret society, a great unconditional support network.

Let’s form our own, only smart folks looking to change the world for the better should be in. Thoughts about free energy from the earth’s magnetic field (what would’ve Tesla done if he had wikipedia). Thanks to the 60 to 90 people who watch, I’m not talking to an empty room, yay.

Come to think about it, some religions are just that (powerful brotherhoods in the open), they just have a mythical pretext to come together.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Photography/Photoshop homage to music video “First of the year” #skrillex

Thursday, January 5th, 2012

First of the year
Miami, FL
December 2011

Here’s my homage to Skrillex’s “First of the Year” music video, one I think will be remembered forever as a cult music video for Dubstep as it started crossing the mainstream frontier.

The model is my daughter who started joking with her fingers right after she saw the music video, which rang a bell in my head, and here we are.

In case you have not seen the music video yet, I’ll save you the Googling
First Of The Year (Equinox) – Skrillex [OFFICIAL]

This picture is Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Why philosophy is important (the movie)

Saturday, December 31st, 2011

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

How to fix Samsung HD TV from making movies look like British Mistery Soap Operas

Sunday, December 25th, 2011

So you got a new HD TV from Samsung and when you’re about to watch that Bluray or stream that 1080p HD stream, movies and tv shows look like they were shot with an amateur camera… Here’s the fix.

1. Menu
2. Picture: Mode [Enter]
3. Picture Options [Enter]
4. Auto Motion Plus, set it to “Clear”

Voila.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Photoshop: How to Convert a Path into a Shape

Friday, December 16th, 2011

So you wanted to create a Custom Shape on photoshop but you started drawing a path because of the nature of what you were doing (or because you forgot to change the pen mode to Shape) and now when you want to right click > “Define Custom Path…” it’s disabled in the menu.

Here’s the solution:

1. Select the path with the path selection tool.
2. Go to Layer > New Fill Layer > Solid Color. (Or use the Create new fill or adjustment layer button in the layers palette)
3. You have turned a path into a new shape layer.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Update de DiccionarioChimbo.com – Ranking de Noviembre 2011

Wednesday, November 30th, 2011

Top 10 jugadores de DiccionarioChimbo.com [Noviembre 2011]

Ranking actualizado Wed Nov 30 20:50:26 EST 2011

1. @ninja_gayden Total Score: 2230 – Content: 610 – Social: 75 – Bonus: 1545

2. @gubatron Total Score: 1350 – Content: 150 – Social: 1155 – Bonus: 45
3. @HelyPuerto Total Score: 1015 – Content: 670 – Social: 15 – Bonus: 330
4. @Davidilusionist Total Score: 520 – Content: 100 – Social: 0 – Bonus: 420
5. @Arrastra0 Total Score: 475 – Content: 10 – Social: 0 – Bonus: 465
6. @KevinAlej Total Score: 470 – Content: 110 – Social: 0 – Bonus: 360
7. @pachecogeorge Total Score: 355 – Content: 220 – Social: 0 – Bonus: 135
8. @Erika_Pellman Total Score: 275 – Content: 140 – Social: 0 – Bonus: 135
9. @Jhuvens Total Score: 210 – Content: 180 – Social: 0 – Bonus: 30
10. @kthy93 Total Score: 195 – Content: 60 – Social: 0 – Bonus: 135

Lanzamiento Tentativo, 2da. semana de Diciembre

Ya tenemos una API, con la cual hemos estado capturando y estabilizando durante los ultimos meses para calcular todos estos rankings, y organizar las palabras y definiciones que han enviado.

Tenemos Logo, y diseño web listo. Tambien tenemos el home page listo.

Que falta?

- La pagina de Palabra, donde mostramos una palabra y todas las definiciones.
- La pagina de Usuario, donde se muestran todas las palabras y definiciones que ha creado un usuario. A futuro aqui tambien tendremos “achievements”
- Búsqueda.

- Otras paginas como Politica de privacidad, Terminos de Uso, Acerca de, etc, pero podemos lanzar sin estas.

No quiero mostrar nada aun para poder sorprenderles. Apenas respire mato todo eso.

Mientras tanto sigan jugando!, @ninja_gayden felicitaciones por ser la ganadora de este mes, aunque no prometimos ningun premio igual te vas a ganar algo :)

Trabajo

Una vez que lanzemos el sitio vamos a estar contratando personas en diferentes areas dependiendo de como se desarrolle todo. Estaremos buscando programadores, diseñadores gráficos, online-socialites, community managers, business developers y vendedores.

Interesados deben tener cuenta PayPal (para recibir sus pagos), pueden estar en cualquier parte del mundo, y pueden enviarme una carta a gubatron@gmail.com diciendome pq quieren y deben ser parte de diccionariochimbo.com. Si aplicas para la posición de business developer esperamos creatividad y algo de tu visión de negocios sobre que se puede hacer con diccionariochimbo.com (ten en cuenta que tenemos pensando en decenas de modelos de negocio desde hace mas de 10 meses)

Stay tuned, it is happening.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Exit 66 – Fort Lauderdale

Sunday, November 13th, 2011

Exit 66
Fort Lauderdale, November 2011

Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Seasteading and Blueseed – are international waters the fast lane to mankind’s future?

Friday, November 11th, 2011

Every aspect of the world evolves with technology except political systems.

If government was an industry (which it is) it’d be the largest most inefficient one. If you saw countries as companies and citizens as customers it’d be one lousy industry, one on which some companies get to even kill their own customers.

How would the forefathers have designed our government system if they had the internet? (I can give you some ideas for that)

It’s an industry that doesn’t allow for new companies, therefore it’s stagnated and the world is in major dudu.

In this talk they propose to use the sea as the place to experiment new forms of politics, medical care, entrepreneurship.

My only concern is, how do you protect those from countries and from pirates?

Blueseed,

Also make sure to checkout Blueseed a project to create the first Incubator Vessel 12 nautical miles west of California, out of the jurisDICKtion of the US, so that entrepreneurs from all over the world can come without having to apply for a stupid work VISA. This is not a project to employ foreign worker, this is a project to empower entrepreneurs that want to have an impact in the US economy and create the jobs we need in the US. Pretty sick idea, specially what they reveal about their business model: rent + equity of every startup on board, the potential to make billions, so basically a technologically nurturing environment at sea, the sea startup incubator.

The world needs to move forward, and lawyers politicians seem to be in the way of it all. This is a very cool example how creative minds tackle problems.

Related Links
http://www.blueseed.co/
http://seasteading.org/about-seasteading/introduction

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

How babies watch cartoons in 2011

Thursday, November 10th, 2011

Baby watches polish cartoons for free, on demand, on YouTube, on a Tablet, on WiFi - Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Here’s my 18 month old, watching Polish cartoons on YouTube right after waking up. Think of all the technology* that had to come together to make this happen and how technology helps to preserve and spread culture.

Just 10 years ago this wasn’t possible. She would’ve had to be in Poland or we’d have to buy a special cable package with a polish channel (which would probably not be available in South Florida since there’s not that many polish people down here). If we had gotten a polish channel, we’d probably have to have her watch tv at a certain time and the cartoon she’s watching is probably too old to be aired.

She’s able to watch Polish cartoons and her mom is happy to know her daughter is having a similar cultural experience as the one she had during her childhood, to reinforce the language.

I’m able to teach her so many things with a few creative YouTube searches or with Google/Bing image search (for vocabulary and object recognition exercises), my baby’s cognitive development and language development eclipses mine probably by 3 fold when I was that age.

Her vocabulary is not only far larger than mine at that age, she knows most of it in spanish, polish and english (there’s just no other way for her to interact with the grand parents). She’s probably listened to more music since she was in the womb than all the music I heard up until age 4.

I think we should all be making our babies consume as much knowledge as possible, the rate of change they will have to go through during their lifetimes will be brutal, and they’ll need the tools to handle it and stay current. It will be amazing to see what these babies will be able to do for the world once they grow up.

High level Technologies worth mentioning for this to happen.
C, C++, Linux, Android, High Speed Inter networks and all of their stack which is too big to mention (the internet), WiFi, Dual Core cpus (and all the technology to make that happen starting from nanoscale transistors), Flash Memory, capacitive touchscreen, lithium batteries, Liquid Cristal Displays, Video Codec Technology, YouTube.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)


  • Categories

  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • October 2009
  • September 2009
  • July 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004