Alejandro G. Carlstein Ramos Mejia Blog



var Book = (function(){
    // Private
    var _name;
    var _price;
    var priceChanging = [];
    var priceChanged = [];

    var updatePriceChanging = function(_this, value){
        for (var i = 0; i < priceChanging.length; ++i){
            if (!priceChanging[i](this, value)){
                return true;
            }
        }
        return false;
    }

    var updatePriceChanged = function(_this){
        for (var i = 0; i < priceChanged.length; ++i){
            priceChanged[i](_this);
        }
    }

    //Public
    return {
        factory(name, price){
            _name = name;
            _price = price;
            return this;
        }
        ,name: function(){
            return _name;
        }
        , price: function(value){
            if (value !== undefined
                && value != _price){
                var isPriceTooHigh = updatePriceChanging(this, value)
                if (isPriceTooHigh){
                    return _price;
                }
                _price = value;    
                updatePriceChanged(this);
            }                
            return _price;
        }
        ,onPriceChanging: function(callback){
            priceChanging.push(callback);
        }
        , onPriceChanged: function(callback){
            priceChanged.push(callback);
        }

    }

})();

var book = Book.factory('Lord Of the Rings', 23.99);

console.log(book.name());
console.log(book.price());

book.onPriceChanging(function(book, price){
    console.log('Changing book price to $' + price);
    if (price > 100){
        console.log('-> [X] Price ($' + price + ") is too high. No changing price");
        return false;
    }
    return true;
});

book.onPriceChanged(function(book){
    console.log("The book '" + book.name() + ' changed price to $' + book.price());
});

book.price(19.99);
book.price(200.00);
book.price(99.01);

Output:

Lord Of the Rings
23.99
Changing book price to $19.99
The book 'Lord Of the Rings changed price to $19.99
Changing book price to $200
[X] Price ($200) is too high. No changing price
Changing book price to $99.01
The book 'Lord Of the Rings changed price to $99.01

 

Share

If you wish to create a read-only domain object that insure that no body is allowed to write to the database through your domain object, then add these even listener at the end of your domain object file:

transient beforeInsert = {
throw new RuntimeException('insert not allowed')
}

transient beforeUpdate = {
throw new RuntimeException('update not allowed')
}

transient beforeDelete = {
throw new RuntimeException('delete not allowed')
}

 

Share

NOTIFICATION: These examples are provided for educational purposes. The use of this code and/or information is under your own responsibility and risk. The information and/or code is given ‘as is’. I do not take responsibilities of how they are used.

Introduction To Network : The Internet

Share

PrimeFaces is already shipped with the jQuery bundled; therefore, there is no need to include the jQuery script.

However, when in a page there are no PrimeFaces components that use jQuery then jQuery will not be automatically included.

Share

 

 

Share

http://www.noodle.org/publish/wp-content/uploads/2013/09/ted-talked.jpgIf you stop for a second and watch the TED talks about education, you will witness professionals talking about the issues we have in education and ideas on how to solve them. All of them provide a wonderful argument and their ideas are marvellous; however, they all fail to point an important piece for this educational revolution to succeeded which is asking where to start doing these changes. Most speakers in TED talk about changes from kindergarten up to High School; however, they do skip the level of education at university level. From these levels of education is were we must start the educational revolution, not the other way around. Here are the two main reason why we should start from there:

  1. Lets assume you have an student who had grow up in this new educational system. What would happen to that student when he goes to the university and encounter that they teaching using the old methods of education? Is he going to be able to adapt?
  2. Most of the educators that are teaching in schools today, they learned how to teach when they were students at the universities. If the classes at the universities do not use these new methods of education then how do you expect to see them applied at the schools?

The universities are the parents of the educational system. They must provide the correct example if we wish for the children, the schools, to follow. If we keep this current old system running in our universities then any hopes for an educational revolution is wasted. The educational revolution must start in our universities now if we wish to see any changes at our schools in the near future.

Share

NOTIFICATION: These examples are provided for educational purposes. The use of this code and/or information is under your own responsibility and risk. The information and/or code is given ‘as is’. I do not take responsibilities of how they are used.

Before we begin talking about encryption, decryption, and ciphers related topic, let go over some terminologies to have in account:

Share