Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You clearly misunderstood the use of Value Object's. A Value Object does not contain an identity. Value Object's are to keep your domain model simple while still being able to fully encapsulate your model (and not breaking the client contract in the future). Eric Evan defines a Value Object as:
  2. ignace

    PHPTAL

    In most cases it are PHP (junior) developers who convert PSD documents to HTML/CSS not the designers. Ask a designer for the DOCTYPE and he'll answer you ".html". A (junior) developer knows PHP, SQL and possibly HTML, CSS, and JS as these are part of the basic skill set. Only few also know DTD and XSLT hence why I said there's a learning curve.
  3. Only to those developers that don't think before they act. A framework is not a one-size fits all (in contrary to what you would believe of a framework), the framework designers had a few goals in mind and these may or may not conflict with your project, prototyping a framework prior to development is generally a good idea. This surely is an advantage however it's harder for other people to join your team (lack of documentation, possibly even tests)
  4. subscribe-feed.php $sql = 'INSERT INTO point_system_actions (user_id, action_name, action_taken_on) VALUES (' ... if(mysql_query($sql)) { $sql = 'UPDATE point_system SET points += 10 WHERE user_id = ' .. login.php $sql = 'INSERT INTO point_system_actions (user_id, action_name, action_taken_on) VALUES (' ... // unique idx_action (user_id, action_name, action_taken_on) if(mysql_query($sql)) { $sql = 'UPDATE point_system SET points += 10 WHERE user_id = ' ..
  5. IMO there is only one bible: Expert PHP and MySQL
  6. So these 9 lines are harder to comprehend then your 30-40 lines of code? if(upload_exists($_FILES['file'], 'directory')) { echo 'Upload already exists.'; } else if(!upload_is_valid($_FILES['file'])) { echo 'Invalid upload.'; } else if(!upload_store($_FILES['file'])) { echo 'Could not store the file.'; } else { echo 'File successfully created.'; }
  7. If you have trouble understanding your code or someone else's consider re-factoring the code: if(upload_exists($_FILES['file'], 'directory')) { echo 'Upload already exists.'; } else if(!upload_is_valid($_FILES['file'])) { echo 'Invalid upload.'; } else if(!upload_store($_FILES['file'])) { echo 'Could not store the file.'; } else { echo 'File successfully created.'; } function upload_is_valid($upload, $valid_mime, $valid_ext) { if($upload['error'] != UPLOAD_ERR_OK) return false; $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime)) return false; if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext)) return false; return true; } function upload_exists($upload, $directory) { $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename); } function upload_store($upload, $directory) { $upload = upload_create($upload); $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename); } function upload_create($upload) { // re-create the image return $upload; }
  8. Sure, but what prohibits them to just strip it? To a basic user... that buys a script from you somehow knowing his server runs PHP and performs all required installation instructions?
  9. ignace

    PHPTAL

    In contrast with Smarty it presents a learning curve as the markup is somewhat complex to understand and follow. You also will have to deal with learning yet another "language".
  10. LOL nice RIP I actually like the RIP better
  11. I'm currently at the part where you write PHP extensions but I do not publish them as these are custom to the company I work for. A good book for everything PHP/MySQL is Expert PHP and MySQL
  12. I think their may be a problem: Internal Server Error
  13. 1. Create 8 files with distinct names - register.php - login.php - dashboard.php - ... 2. Write the required code in each page and include() the common sections: $headTitle = ''; $headDescription = ''; include 'html/head.php'; include 'html/menu.php'; // code include 'html/foot.php';
  14. You can only learn PHP by practicing it. Buy a PHP cookbook this will give you some stuff to practice. Buy a book about PHP best practices to correct whatever the cookbook wrongfully told you or display your examples on these forums (people will tell you what you should and shouldn't be using). Push your boundaries by trying out new and more difficult problems. Retrieve 2 year old code and re-factor it without actually re-writing it and make sure it still works after your done. Keep doing this for all your code. This will also be an indicator of your progress. This will make you a competent PHP programmer not an expert PHP programmer. To take the final step you should start with expert training like Zend Certified Engineer, this will make sure you know of everything that PHP gives you. Next, start writing extensions and hacking the PHP core. You are an expert PHP programmer when your extension gets published and comes pre-bundled with PHP, by that time you'll have many years under your belt and are probably already consulting for companies that deploy PHP applications. Good luck
  15. Do not make it too difficult, too complex and unmaintainable: updateAge('forum_posts', 'foo'); // doesn't make sense but is currently possible in your design $db = mysql_connect('localhost', 'root'); if($db === false) { trigger_error('Failed to connect to the database server.'); } if(!mysql_select_db('test', $db)) { trigger_error('Database test does not exist or could not be accessed.'); } function person_create($data, $db) { if(!person_is_valid($data)) { trigger_error('Invalid user data. User has not been created.'); } $sql = 'INSERT INTO users (user_name, user_pass) ' . 'VALUES (' . db_input($data['user_name'], $db) . ',' . db_input($data['user_pass'], $db) . ')'; mysql_query($sql); return mysql_insert_id(); } function person_is_valid($data) { $data = array_merge( array('user_name' => '', 'user_pass' => ''), $data ); return !empty($data['user_name']) && !empty($data['user_pass']); } function db_input($input, $db) { return "'" . mysql_real_escape_string($input, $db) . "'"; }
  16. LOL I overwrote my own post
  17. Or if you have it laying around, an hydrogen bomb.
  18. ignace

    Keywords

    Only XHTML had the space + forward slash while the space was actually only for backwards compatibility with older browsers that would not understand XHTML. The forward slash is used in XML to note that it doesn't have a closing tag. XHTML is pretty much obsolete, XHTML2 has been discontinued in favor of HTML5 and XHTML1.x has never been supported by IE. Either use HTML4.x or 5 using for example the boiler plate code from Paul Irish
  19. I found a few issues layout-wise when viewing the website with Firefox 3.6.8: - Shop by category: The arrows are on the next line instead of in front of the text, the border-top has a nasty jumping effect. - Language: the language icon is below the language selection box - Mailing list: the text box does not expand to it's full width Other issues I found: - I can't add a product to basket directly - Do NOT prohibit basic functionality to keep working, I can't add something to the basket because I have JS disabled. Another reason for providing backwards compatibility is when by accident you upload something or wrong logic executes and that breaks your JS.
  20. As you clearly have had sufficient practice it becomes obvious you need to seek other ways to advance, consider training or books. "Practice without theory is blind, theory without practice is mere intellectual play" -- Unknown
  21. When they open it and... read it. You can stop at when they open it.
  22. Base your website on one currency and store the conversion rate in a currencies table.
  23. No, you don't. Open/Closed Principle Due to the Shopping_Cart design (or lack thereof) this becomes more difficult to implement as an item alone should know how much it costs. You can solve this by using the Proxy Pattern: class Shopping_CartProxy extends Shopping_Cart { function getItemPrice($order_code) { $db->query(..); return ..; } } Use the proxy as if it is the Shopping_Cart (if you use a Factory Method to create the Shopping_Cart you'll only have to modify the Factory Method) public function someFunction(Shopping_Cart $sc) { .. } $proxy = new Shopping_CartProxy(); .. $o->someFunction($proxy); class ShoppingCartRepository { function purchase(Shopping_Cart $sc) { $db->query(..); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.