Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. class PostOfficeService { public function send(Email $email, User $to) { $email->addTo($to->getEmailAddress()); $email->send(); } } Neither User nor Email now need to know about the other, providing greater flexibility in your design.
  2. Your design is FUBAR! You are assigning Email properties to your User. In DDD, when you have 2 objects that should work together, but passing either object to the other is awkward, use a Service. I'm not for the make all Email methods static approach as it creates a hard dependency between either User and Email or vice versa.
  3. No, but it certainly would be funny! Thank God for not open-sourcing his source code, who knows what I may have done with DNA or Atoms EDIT: I need to get off those meds..
  4. haven't you heard? IE is the good browser now, since IE9?
  5. If it only takes one line of code in Pascal, then use Pascal. And let PHP communicate with your Pascal program as if it were a service. It's been a few years since I programmed Pascal, but it should be possible to call it through something like: exec('pascalexe parameter1', $output, $return_var);
  6. Good practices, are called good practices for a reason. Sure, you can cut corners, build shortcuts and bridges in your software. But as these come from people who have 10x the combined experience you have, they must of had a motivation somewhere in their lifes, that I believe you will share in the near future.
  7. DRY (Don't Repeat Yourself) is pretty much what it says, if you have a piece of code that repeats, wrap it in a function. An explanation of MVC can be found at: http://www.phpfreaks.com/forums/index.php?topic=327837.msg1543224#msg1543224
  8. Overwrite go-pear.phar, download it from http://pear.php.net/go-pear.phar Go one directory up click go-pear.bat, follow the instructions
  9. @OP It's not necessary to learn OOP but it's a nice asset, because like you said, more and more companies are asking for it. You don't need OO to write MVC And you can't apply DRY to procedural?
  10. Just imagine what happens when player's leave, new ones are recruited. You would be constantly updating the sprite.
  11. If you are on a shared host or host with a "low" number of concurrent connections you'll find users unable to visit your website due to no available connections.
  12. Use Image Lazy Loading: http://engineering.slideshare.net/2011/03/faster-page-loads-with-image-lazy-loading/
  13. MVC stands for Model-View-Controller and like Zyx pointed out it's an architectural pattern. MVC is an example of good Separation of Concern (SoC), each part has a clear responsibility. For the View this is rendering the interface, and communicating changes to the Model (at least in it's original design, for PHP this will be the Controller due to the View being remotely manipulated). The Model does the actual work. For example, I am typing this text in this textarea and when I submit it, the text will be passed to the Model and in turn will insert it into some data store. And upon you visiting this page, will retrieve it. The Controller ties the Model and the View together in order to handle a request. For example, when you open Excel and choose File > Open a dialog appears, the Controller handled the request (I want to open a file), the Model loaded the files under a certain directory and the View rendered the dialog (when you click on a directory, the View will communicate this change to the Model and it will load the new directory contents). In PHP this would be that you visit /user/edit/1 which indicates you want to edit a user with ID #1, the Model will retrieve the user from the database with ID #1, the View will render the form. And when you submit it will be passed back to the Controller, which passes the POST data to the Model to store it in the data store. Like I said earlier, the MVC is different for local and remote apps.
  14. I doubt there is such a function, but you can use: function strtolower_first_word($str) { $words = str_word_count($str, 1); if(empty($words)) return $str; $words[0] = strtolower($words[0]); return implode(' ', $words); }
  15. Your C++ code uses unsigned integer's. Quite possibly all this fails due PHP and MySQL being run under a x32 architecture. If you have x64 system, uninstall and install the x64 version, and try again. EDIT: under x64 drop floatval()
  16. 1) Post your PHP code. 2) Open PHPMyAdmin, run your code, return to PHPMyAdmin and execute SHOW WARNINGS; or write SET @@global.sql_mode='TRADITIONAL'; before you execute your PHP code (make sure to catch any error).
  17. Show us the PHP code you wrote based on the C++ decoder function.
  18. Objects are always passed by reference, so you don't need the & unless you are passing some other data type like array and you make changes to the passed variable contents. It's best to avoid references in your code, not all programmers understand them and if you are like me you don't work long at one place.
  19. Try HeidiSQL I use it all the time!
  20. When writing lesser known abbreviations, write it at least once in full. Smart Development Environment (SDE) is an enhanced IDE and thus not a framework.
  21. My mind tricked me Just to be clear: you add models to cities like: INSERT INTO model_in_city (model_id, city_id) VALUES (1,1), (1,2), (1,3), (1,4); Places model 1 in cities 1,2,3, and 4.
  22. You can't enforce any hard constraint at table-level but you can do that at the application-level. You could use a trigger ON BEFORE INSERT though.
×
×
  • 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.