Tuesday, December 1. 2009Dependency Injection with PHPSince Java is a little more static than PHP from a language construct standpoint, the Java Community have adopted the concept of Dependency Injection (DI) a couple of years ago (for example in the Spring framework). Now PHP is getting more mature and people are wondering how to best decouple components in big projects in order to prevent interdependencies. Originally coming from the Java world, i found DI very interesting from the beginning on. When i contributed my first (and only) code to Zend Framework, i tried to use dependency injection there. This is why you can still "inject" a Zend_Mail_Transport object to Zend_Mail when you want to send the email out: $mail = new Zend_Mail(...); ... $trans = new MyTransport(<arbitrary config options for my transport>); $mail->send($trans); But it seemed like this concept was not very popular in the PHP community. Obviously the more common approach to define which driver to use for a given Functionality is to make factory methods that take associative arrays as parameters: These days, there seems to be a new movement in the PHP community to evaluate DI. On the international PHP conference in Karlsruhe, Fabien Potencier has made an excellent presentation about how DI can help you in PHP and how to implement a container that helps to get most benefit out of it. Since i still like the concept of DI, i am very curious on how this develops further. DI: I love it! Thursday, November 26. 2009Upgrading to VMWare Player 3.0 on Ubuntu 9.10After all my struggle with VMWare Infrastructure 2.0 on Ubuntu (see below), i now upgraded the ubuntu version on my machine and also replaced the VMWare infrastructure with VMWare Player 3.0. And: Yes! Finally everything works as expected! No more Tomcat Java Server infrastructure, No more Java Applet to control the VMs. And most interesting: Now the shared folders do work. I can access certain folders in the host's system from within the VM. Security problem? Well, the VM guest is a development machine, so i don't care. But there were some problems also. #1: The machines would not start. They tried but then they were suspended right away. I found that it was because of access rights: The VMWare player is started by my user account, so requires the VM Files to be read/writeable by this user. The VMWare infrastructrue seems to have run under user "root" and thus, a lot of files were owned by this user. chown -R helped. #2: After initial success, the eth0 network device in my guest systems disappeared. After a little research i found that this was due to changing MAC addresses in the VMWare player. This can be solved by setting the addresses to a fix value in the .vmx file but if you want to be able to copy your image to other locations also, this might be too restrictive, especially if you use NAT and run the image more than once. A small change to the network config in the guest did the job finally. This way i also learned about /etc/udev/rules.d... Linux is so cool! I got my solution here, inspired by the german vmware forums Tuesday, November 10. 2009Web 2.0 changing the process in WebApp-DevelopmentThe cool thing in web application has always been (and will always be) that IT meets communications. Every Web-App is considered a communication platform, not a technical artifact that just needs to work. Nobody accepts the need for trainings or manuals for web apps. They need to be "intuitive". This is where the designers come in. And concept people. And the word "emotional". During the past 15 years of web history, certain processes of development have been defined that tried to align both, communication and technical aspects of the game. I have worked through at least 10 different approaches to this and they all failed. But eventually, tech-guys and creative guys have arranged and found a way to co-exist in a project without too many battles. Fortunately, the interaction patterns in the web used to be very limited: Click, load page, click again, load another page, fill in form data (wow, very complicated alreday), submit, see response (only positive response, error response was never considered by the graphics people Why was that? Most of the designers think in pictures. Static pages. They want to design advertising campaigns and feel generally handycapped when they are forced into tiny web design. You cannot even use the font you want to have... The developers are only interested in the general solution to a problem. They generally don't care about the look and feel and about all the thousands of tiny details that make their elegant base solution a mess of code in the end... Already during this time there was one area of work that was very complicated to tackle: Flash! No static images, but dynamic interaction. Only really good if mixed with actionscript coding. Up to now, there are only a few people who do this really good. Fortunately the use of flash is limited to a nice intro with some sound and flying characters, and there always is a SKIP button... And now: Another dimension! Web 2.0, Ajax, Javascript. All the processes and the split of responsibility needs to be thought over again. Suddenly, the whole web application is a big monster of unrestrained user interaction. Drag&Drop, animations, widgets, server communication, asynchronous processing, events. Not even the best programmers can really predict at the beginning of a project what will be possible and what cool feature might shipwreck due to browser shortcommings or other technical difficulties. On the other side, designers have a very hard time imagining all the user interaction that can be made possible and to consider all system behaviour and make designs for them. The graphic design suddenly already contains half of the techical design process also. Assumptions are being made, designs need to change in long ping-pong games between design department and developers. In short words: The arrangements need to be changed. The process of making designs first, then coding the application does not work anymore. Design and coding must go hand-in-hand, otherwise a modern application design ist not possible. This is going to be a challenge for all established customer/vendor relationships out there and for all full-service agencies that will need to build compelling web 2.0 apps in the future... Friday, November 6. 2009PhotoModel vs. WorldControllerOk, everybody is using MVC now. And everybody talks about the best template engine for the View and the best Implementation of PageController pattern or such. One thing that you find only very little definition about is the "M" in MVC. The Model. Sometimes it is referred to as a ActiveRecord or any other representation of a database row. This appears much too short-minded to me. MVC is about separation of concerns. Who is responsible for what? Clearly, the View should be responsible for visualization of Data. The Controller should control user interaction and page flow. I.e. it recieves all requests, and decides what to do and what do answer after the job is done. Now, my definition of the Model is: "Facade for the Business logic". This means not more or less than a small class that offers all the Controller needs to do his work. In my world, the Controller accepts input parameters (GET, POST, SESSION, COOKIE, whatever). It checks for correct syntax and converts into internal formats (example: date fields etc.). The Model will not check for correct number or date formats. The controller then makes a model instance and calls methods with very speaking names in this model. Each Controller uses only one Model. Multiple Controllers may use the same Model if they work in comparable area of concerns. The model now takes care about all the bits and pieces it needs to process a given task. It reads config, makes DB connections, DataAccess Objects, Entity-Objects (i dont like ActiveRecord, use a JEE-like Entity approach). In bigger projects, your business logic might consist of hundreds of classes, containing factories, singletons and whatever patterns you want to apply. But the Model abstracts this all away from the Controller. This way, the structure of the business logic can be completly changed without impacting the Controllers or even the views. Models then return all values in internal data representation (example: date as JDDate or PHP-Date). The Controller passes the results to the View. The view is then responsible for giving it the right output format. This way, also some other responsibilities become clear: - Syntactical Input Check (including locale aware conversion of typed input fields to internal data formats) happens in the controller - The Model will check the passed data for consistency - Output formatting and -escaping of typed data fields is done in the view - Template translation is done in the view (template engine etc) - Models (and everything they invoke) may not access $_GET, $_POST, $_REQUEST, $_SESSION, $_COOKIE etc. - a Model may not invoke any other Model (nor Controller or View). - Communication between Controller and Model works with internal data representation For example, the Controller might get the user-id out of the session and transfer it to the Model at initialization time. The model will create a DB connection and a user-object as singletons in the constructor. ... in the controller: $photoId = (int) $_GET['photoId']; $albumId = (int) $_GET['albumId']; $m = new PhotoModel($_SESSION['userId']); $m->removePhotoFromAlbum($photoId, $albumId); $res = $m->getAlbumContent($albumId); $this->view->album = $res; // will be rendered by a cool template afterwards ... in the Model: function __construct($userId) {
$this->conn = MyDBAbstraction::getConnection($userId); $this->user = User::getInstance($userId); } etc. This way, Models stay very lean, at the same time they clearly separate the business logic from the UI logic. What google knowsGoogle released the "Google Dashboard" lately. In this app it shows all information the different google apps store about a given user. Analytics, Groups and Wave are currently not listed there. But it shows all information about Contacts, Account info, Text and Tables, Web Protocol (search queries) etc. Seems like the "We are not Evil" benefit of google is not enough anymore and they need to show us how transparent they are about storage of personal data. Thanks Google, we appreciate it Wednesday, November 4. 2009Javascript: The good parts
I cannot get around it: Just started reading an interesting book about Javascript. And i must say: After my tendency to prevent Javascript wherever possible in the past, i actually start to like the language. It has a bad reputation because it is in 100% of cases used to do DOM manipulations and browser feature enrichment and the environment it finds in today's browsers is still quite undefined and often unstable. But the language itself is surprisingly well defined and it has a lot of interesting constructs.
My favorite sentence so far: "Javascript was built on some very good ideas and a few very bad ones.". And the most interesting fact i learned: Javascript is a functional language like Scheme or Lisp. It has nothing to to with Java. Fun... Saturday, October 17. 2009iPhone verloren: Telekom gibt aufJaja, ich bin manchmal ein Schussel, alles klar. Mir ist letzten Donnerstag mein iPhone abhanden gekommen. Vergessen, verloren, geklaut, ich weiss es nicht. Jedenfalls hat niemand es gefunden. Also hab ich mich mit dem Verlust abgefunden. Nun habe ich ja diesen iPhone Spezialtarif bei der Telekom. Und da bin ich heute mal zum T-Punkt gegangen, um zu fragen wie es da jetzt weiter geht. Meine Erwartung war eine Aussage wie: "Selber Schuld, dann müssen Sie sich ein neues iPhone kaufen, kostet 250 EUR". Vielleicht, so dachte ich, gibt es ja sogar ein bisschen Kulanz und weil ich so viel Gesprächsumsatz mache, kriege ich ein neues iPhone für nur 100 EUR oder so. Aber die tatsächliche Aussage der Telekom hat mich dann echt aus den Socken gehauen: "Da können wir nichts machen". Auf die Frage, was denn werden soll, sagte man mir: "Der Vertrag ist ja für 2 Jahre geschlossen und kann auf keinen Fall aufgelöst werden." Und: "Ein neues iPhone bekommen Sie bei uns nur mit einem neuen Vertrag". Und das macht mich jetzt echt sauer, muss ich sagen. Die gehen wirklich davon aus, dass ich meinen aktuellen 50 EUR/Monat bei der Telekom 1,5 weitere Jahre laufen lasse und weil es so ein Erfolgsmodell ist, noch einen zweiten im Wert von erneut 1000 EUR abschließe, damit ich ein neues iPhone bekomme? Auf mehrfaches Nachfragen gab es keine andere Antwort. Nur die Antworten kamen in zunehmend patzigem Tonfall. Sorry Telekom, auch wenn ich für Dich arbeite, hiermit hast du einen Kunden verloren. Und zwar dauerhaft... Saturday, October 10. 2009Cash flow analysis in MS-ExcelNow to something completely different: (might be trivial for Excel Professionals, so forgive me that i am so naive) My management asked me some days ago for the cashflow of my current project. I know basically how this needs to be calculated: You define a period of time, take all money that comes in and substract all money that goes out. You do this for every period and then you have a cashflow per period. Then you want to calculate an accummulated cash flow so you see, if you need to put money into a project or if it brings in all that it costs throughout the runtime. So far, so good. But how to do it automatically. What do i have? Incoming invoices (those which are already there and the forecasted ones) with due dates: 10,000.-- EUR on Oct 03 from XYZ 5,000.-- EUR on Oct 23 from BlaBla 20,500.-- EUR on Nov 05 from ABC etc. Then the invoices we send out with their respective due dates: 100,000.-- EUR on Oct 01 50,000.-- EUR on Nov 01
Assuming, the due date of the incoming invoices is in column E of a sheet called "invoices in" and the according amounts are in column D, you would calculate the incoming amount for a given month like this: =SUMPRODUCT((MONTH('invoices in'!$E2:$E200)=10) * (YEAR('invoices in'!$E1:$E200)=2009) * 'invoices in'!$D2:$D200) This will give you the sum of all amounts (column D) where the month of the due date is 10 and the year is 2009. You can also replace the 10 by a reference to another date field (Oct 1 2009) (in cell C5 for example) and then make a table with date fields in the header for each month and below this you just fill this formula in a slightly modified form: =SUMPRODUCT((MONTH('invoices in'!$E2:$E200)=MONTH(C5) * (YEAR('invoices in'!$E1:$E200)=YEAR(C5)) * 'invoices in'!$D2:$D200) This way you can count all incoming vs. all outgoing cash. All you then need to do is to subtract and there is your dynamic cash flow. What i added then was a nice diagram of course. Works well and looks good Friday, October 2. 2009SVN update client performance under windowsAfter i re-entered the open source version management area again (used Perforce for years and i know why While most others have no problems with update performance, it is horrible for me. Our repository consists of 8 GB and a couple of thousand files and our current revision number is 18644. So nothing specatcular (with perforce we were in the 1 Million change lists area). Now clicking on "UPDATE" on my nice Vista notebook takes up to 5 minutes before the first files are actually transferred. While there was only little network traffic, HDD is working like mad. I could not explain that and so i searched for reasons online. First i suspected Tortoise to be the bad guy. But after i had de-installed it and used command line SVN i learned that it is not the case (Tortoise has its oddnesses, but my bad update performance was obviously not linked to it). Also, our server is not the problem. It works fast for other clients. Eventually i found this blog post, that gives a hint: http://svn.haxx.se/users/archive-2009-09/0879.shtml Obviously SVN is using a lot of small files to lock the local copy. And under windows this kills performance especially on notebook-hdds. The statement seems to be: Wait for 1.7 and then the locking mechanism for SVN will be replaced by something more optimized for Windows Platform. In the meantime i will have a look for acceleration for handling of a lot small writes for NTFS... Update: I have now enabled "write caching" and "performance optimization" for the harddrive i use with SVN. Unfortunately that still does not do it. SVN UP still takes 5 minutes. What i see is 100+ page faults per second, but no significant network I/O and also not too much HDD throughput (1 MB/sec). Thursday, October 1. 2009Back inAfter 2 weeks in lovely Alghero i am back in the office. It is not as warm here and the sea is missing. But the internet is much faster. And no roaming. So be prepared, Mafia Wars players! I am back in the game Monday, September 14. 2009Monopoli City Streets
Ever wondered what Google Maps was for? Of course for fun! The old idea of Monopoli now goes web and world wide. Since September 9, you can buy any street worldwide and build houses in a massive multiplayer Monopoli. What a cool idea! http://www.monopolycitystreets.com/game.html#de
Namespaces in PHP 5.3, Webcast
Interested in an introduction to namespaces in PHP 5.3?
Zend has a webinar led by Stas regarding this topic tomorrow (September 15, 9 am PDT. According to my Outlook calender it would be 18:00 german time) Javascript editor currently broken, therefore copy/paste this link for more information: http://www.zend.com/en/company/news/event/webinar-namespaces-in-the-wild-with-php Javascript vs. PHP: RIA 1.0 and RIA 2.0?
On the weekend i attended the #phpunconf in Hamburg. We had a lot of very interesting discussions there with Michael Mayer, Johann-Peter Hartmann and Cornelius Weiss about PHP in the Javascript world. In these discussions we found that there are basically two approaches discussed at the moment:
Server side frameworks integrate JS widgets into their libraries now. They try to generate JS code from templates on the server side to control the user interface. This way, forms can be enritched with some special input fields that can provide nicer user interface (for example date-pickers, grids, tab controls, etc.). The widget structure that JS libraries like dojo or JQuery provide today seem to be targeted on this kind of usage. It appears to be a solution for sites with low user interface requirmements or for a transition period. Would that be RIA 1.0? However, a lot of applications will need much more. Users demand top-level interactivity also from web applications these days. That introduces a different approach to javascript (RIA 2.0?). The server only sends one page and a bunch of Javascript to the client. From then on, the application flow is controlled by the client (JS) code. The server only supplies data here and there and executes transactions triggered by the JS application. For this kind of application, more code structuring is needed on JS side. Fortunately, there are already frameworks for this approach. JavascriptMVC is one of them. It contains a special JS-adapted implementation of the MVC pattern and is completely event driven. It even has a template engine implemented in JS in order to separate code from html when the JS app renders data from the server into html fragments to insert in the DOM structure of the page. With this kind of structure elements, the Javascript code can be structured in a way that even big javascript applications can be built, maintained and automatically tested without losing overview. For the application we are currently building, this appears the only feasible approach. Especially functional testing with tools like Selenium becomes fundamentally critical when feature rich JS applications are built. There are too many details that can break and each change needs to be tested on different browsers to do it all manually. Personally, i believe there will be both models in the future. The first approach (JS enritched server controlled applications) will probably stay around for CMS sites with little user interaction. But the more interesting model for me is the second one. This model opens a whole new world of feature ideas but also technical design and architectural challenges for the next years. Friday, August 21. 2009Tamagotchi vs. Social Networking A few minutes ago, i accidentially found an old "Tamagotchi" i got as a present quite some years ago. When i thought about it, i saw an analogon to my current use of social networks: The Tamagotchi needs attention. It requires you to think about it all the time. You just needed to invest a couple of seconds every now and then, and if you did it right, you saw it grow and prosper. Now isnt that the same principle with you Facebook account? You log in 5 times a day, look what your friends are doing, give it some food represented by tweets or picture-uploads and then leave it alone. You see your network grow and prosper over time and just as a Tamagotchi, you build something up by investing just a minute here and one there. Does that thought lead to something? Deeper understanding? No. Probably not. But i gave my Blog-Tamagotchi a little food again...
« previous page
(Page 2 of 8, totaling 110 entries)
» next page
|
Calendar
QuicksearchArchivesCategoriesSyndicate This BlogBlog AdministrationArchivesTop ReferrersChoose Language |
|||||||||||||||||||||||||||||||||||||||||||||||||

A few minutes ago, i accidentially found an old "
