Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. ignace

    PHPBenelux

    So, I had a great time at the conference and learned a lot especially the oo functional programming talk by Michael John Burgess was really inspiring.
  2. I don't know how employment works in America, but in Belgium when you fire someone (unless it's for something extreme) he stays on for another 6 weeks to allow him to find new employment and not suddenly find himself without a flow of income. So they are more careful before firing you because they'll be paying you while you technically no longer work there. Not something that inspires productivity. Also firing someone is bad for the morale which is why in most companies I've worked after someone is fired an e-mail is sent around for anyone with questions about the let-go be answered. Sort of psychological assistance. More often then not they simply re-task you. One time I've seen this was when a sales person no longer could make his quota a few times in a row was put in administration.
  3. I know the feeling all too well. Been there myself, and swore then that I would NEVER do it again. A while back it seemed I would have to violate what I had sworn to never do again when the project manager requested an estimate for a rather big change in some existing software we wrote a half year ago, I knew what I had to do, which tests to write, and what to refactor, and how the new model would have to look, I told him it would take 5 days but they couldn't sell that to the client and forced me to reduce it to 2. I agreed physically. When I had to execute the work I set out for the work on my original estimate 5 days. At the start of the 4th day the project manager requested to speak to me privately at which point he realised what I had done. We argued and I told him you have 2 options: you either let me do my job or fire me. I don't do half-work. And I am still employed, and they now listen when I give them an estimate. Employers are not fans of puritans, they like rapid succession of successes at the cost of those that do the work. Don't expect to be ever thanked by them, but your colleagues will praise you. Like when we had this new hire who told on his review that he is amazed of not having to deal with shitty code with older projects as he had to on previous jobs, these are the moments that the project manager is glad to have you on his team.
  4. I am at the PHPBenelux conference if anyone wants to meet-up.
  5. We understood it correctly, you misinterpreted. My solution solves that problem. Simply assign a color to each person in the chat.
  6. It's easier if you set the colors specific from the user's perspective. So each user sees his own messages with a green background, while they see all other's messages in different colors. This also means you only need a few colors versus one specific color for each member.
  7. Make it private. class IamNotDolly { private function __clone() {} }
  8. The wonders of the internet: https://github.com/hay/markov
  9. Looking at Author and making the implicit explicit we get: class Author { .. public function say($comment) { $this->comments[] = $o = new Comment($this, $comment); return $o; } }Your code is then: if ($_POST) { $author = new Author($_POST['name'], new Email($_POST['email'])); // or find it: $author = $repo->findByEmail(new Email($_POST['email'])); $comment = $author->say($_POST['commentcontent']); // depending on the type of ownership you persist either $author or $comment $repo->persist($comment); $repo->flush(); }
  10. Why do you need to do this? Is it part of a requirement? If so, then you are looking at an unidentified domain object or you are exporting business logic from the domain. Who holds the values (ie array1)? Perhaps it's as simple as creating a new operation on one of your domain objects: class DomainObject { private $array; public function isLessThan(DomainObject $o) { $comparator = function($a1, $a2) { return $a1 < $a2; } return array_search(false, array_map($comparator, $this->array, $o->array), true) === false; } }
  11. Use the Data Mapper to write your changes back to the database but only if you have a complex object graph. Use a Repository otherwise.
  12. To expand on Kevin's explanation. Objects identify things in your application. For example a Comment. class Comment { }A Comment consists of a few things to regard it as such:- the author; - the date it was written; - what was written; - and if it was a reply, to which comment it was replied. A class thus groups related information and functions. class Comment { private $author; private $createDate; private $text; private $replyTo; public function __construct(Author $author, DateTime $createDate, $text, Comment $replyTo = null) { .. } }An Author is also a thing in your application with it's own information. class Author { private $firstName; private $lastName; private $emailAddress; private $websiteUrl; public function __construct($firstName, $lastName, Email $email, Url $websiteUrl = null) { .. } }We can continue further down this path and identify Email and Url, because we want both of these to be valid and avoid having to check their validity inside Author, where it does not belong. class Email { private $value; public function __construct($email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new Exception('Email is invalid.'); } .. } } class Url { private $value; public function __construct($url) { if (!filter_var($url, FILTER_VALIDATE_URL)) { throw new Exception('Url is invalid.'); } .. } }You may notice that we did not create classes for $text, $firstName, and $lastName. We could, but because there is nothing interesting about them we simply leave them as strings.
  13. What is production? I am running my clients websites from my laptop using XAMPP.
  14. Composer is standard these days. Make it compliant and load your dependencies through it instead of dumping the entire ZF and Twig in one your directories and then put it under version control. You could have at the very least used git submodules for that. Symfony is just as capable to have utf8 routes as your framework. So why bother writing it yourself?
  15. A shopping cart is an item used on an e-commerce. The shopping cart holds the user's orders just like you have in the mall, you know, this thing:
  16. Learning by doing is the best way to learn to program. However, you should be realistic in your goals. Scraping a website touches on some of the hardest concepts to grasp for new programmers: Array's and Regex. My advice to you, is to start small. - Read the contents of a file and display them in HTML. - Create a form with 2 input fields and add the numbers when the form is submitted. - Create a form with only 1 input field and let the user guess the random number you set in the session and count his attempts. - Create a database table using phpmyadmin, and fill it through PHP, list the records and allow to edit, delete them. For extra points: -- auto-generate the table from SHOW COLUMNS <table> -- and allow to select multiple records using a checkbox and delete them.
  17. Single responsibility does not mean do only one thing. You are a developer and your responsibility includes: - write code - anlyse code - write tests - estimate issues - update issues - etc.. This is your reponsibility as a Developer.
  18. I would simply pass the DB object through the constructor and let Trip define the default method implementations. You simply refine steps inside PackageA and PackageB. class Trip { private $db; public function __construct(DB $db) { $this->db = $db; } protected function getDb() { return $this->db; } } This one. I don't think you know what a Gateway is. A Gateway is to provide access to an external system. Not call local classes and parse it's output, like: class TwitterGateway { public function getTweetsBy($username, $count = null) { .. } }
  19. Most work locally I presume using Vagrant to have a "production environment" run locally.
  20. It's ugly. It's like Java trying to be Lisp and Python. A high-level programming language should reduce the amount of typing required to do a job, not increase it. Otherwise we can all start programming Assembler again.
  21. If you have an algorithm for each website, but only one or two steps differ you can use: http://sourcemaking.com/design_patterns/template_method
×
×
  • 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.