OK, eu am incercat sa scriu niste cost, dar nu-mi dau seama (decat vag, a.k.a. via intuition_that_can’t_be_trusted) cu ce este mai nasol
[quote=“kilogrammer, post:26, topic:2376”]
Dar daca pentru alte functii, daca nu va mai fi asa, daca functiile au un alt flow in libraria cu care vrei sa inlocuiesti jQuery?
[/quote]Sa zicem ca tu vrei sa afisezi toate produsele pe o pagina.
Poti face asta cu vendor lock-in
vendor_locked.php
<?php
require_once('framework1.php'); require_once('framework2.php');
function show_product_details($i){
//product details
echo $framework1->get_details('item'.$i, 'name').
$framework1->get_details('item'.$i, 'price').
$framework1->get_details('item'.$i, 'image').
$framework1->get_details('item'.$i, 'detail1').
$framework1->get_details('item'.$i, 'detail2');
//price history for the last 30 days
echo $framework2->get_price_history('item'.$i, 30); // 30 days
}
function show_all_products(){
$nr_of_products = $framework->get_item_count();
for($i=1;$i=$nr_of_producs;$i++){
show_product_details($i);
}
decat
vendor_unlocked.php
<?php
require_once('framework1.php'); require_once('framework2.php');
function get_products_count(){
return $framework1->get_item_count();
} /* Anti_corruption */
function echo_product_detail($db_field_nr, $item_detail){
$item_nr='item'.$db_field_nr;
echo $framework1->get_details($item_nr, $item_detail);
} /* Anti_corruption */
function echo_product_price_history($db_field_nr,$period_in_days){
$item_nr='item'.$db_field_nr;
echo $framework2->get_price_history('item'.$item_nr, $period_in_days);
} /* Anti_corruption */
function echo_product_details($product){
echo_product_detail($product,'name');
echo_product_detail($product,'price');
echo_product_detail($product,'image');
echo_product_detail($product,'detail1');
echo_product_detail($product,'detail2');
echo_product_price_history($product, $period_in_days);
} /* Safe Code */
function show_all_products(){
$products_count=get_products_count();
for($i=1;$products_count;$i++)
echo_product_details($i, 30); // 30 days
} /* Safe Code */
Si ma refer scrict d.p.d.v. al anti-corruption-layer, nu al divide-et-impera…
Adica mi-e mai usor sa citesc codul de jos, si am impresia ca cel de sus kinda smells, dar nu-mi pot da seama, practic, why or how… desi instinctul imi spune ca acesta ar fi un exemplu cu ce este de dorit… A little help, please?
Vreau sa spun, ati dat exemple pe o functie sau doua, dar nu si cum functioneaza acele functii, intr-un A/B sheet of code…