Dependency Injection via Factory

Refactoring
Dependency Injection via Factory
Image generated by ChatGPT (DALL·E)

You know, when coupling is not loose, components depend too much on each other. It makes your entire architecture fragile and immobile. You can check how loose the coupling is by making a unit test for a component. If you have no problem substituting dependencies by e.g. mock objects then everything is ok. Let take a model class. It depends on DB connection, here Lib_Db_Adapter_Interface instance. We cannot just create DB adapter instance within model constructor, because it depends on configuration data which don’t belong to the model. We can pass to the model constructor a settings array with DB configuration data.

MVC on command line

PHP
MVC on command line
Image generated by ChatGPT (DALL·E)

If you work with Zend Framework, you likely tried ZF Console (Zend_Tool on command line). But have you tried to extend it? Why? To have common interface for all your Cli-scripts related to ZF-base project. How do you find the idea to program Cli-scripts in MVC? Zend Framework provides us with the tool to do it.


From Chaos to Control: Improving Your PHP Error Handling Workflow

How to
From Chaos to Control: Improving Your PHP Error Handling Workflow
Image generated by ChatGPT (DALL·E)

However fondly you treat your application, errors happen and they happen often when it is being developed. That’s obvious you want to get all the tracing information during the development stage and something like ‘Application Error’ page if the error occurs on the production.

Everybody knows error handler can be set in PHP through set_error_handler. The same about exceptions for which set_exception_handler is used. But it really works only for user-defined errors and uncaught exceptions. It doesn’t affect any of fatal error for instance. Well, PHP has such stuff as register_shutdown_function to deal with them. We can create ErrorHandler class and subscribe the handlers in the beginning of the script

Source Code Analysis: Code Sniffer

How to
Source Code Analysis: Code Sniffer
Image generated by ChatGPT (DALL·E)

In the previous article we examined the only way of code analysis – PHP tokinizer. But digging deeper you’ll find many of options. Well-known expert of the subject Sebasitan Bergmann points out following.

As far as you see, with such a set of tools you can do whatever you want. But here we are going to discuss the only application, which is known as code sniffing.

Ok, you have some team, working on the projects and, obviously, you have some code convention to adhere. The lead, making code review, checks the compliance with standards by sight. Common, tell me you are not fond of it. There is an amazing tool but again by Sebastian Bergmann so-called PHP CodeSniffer.

From Code to Content: Measuring Translation Coverage in Your Project

How to
From Code to Content: Measuring Translation Coverage in Your Project
Image generated by ChatGPT (DALL·E)

Let’s assume our application has a UI translation module. We created dictionary and use terms from there within the code of application components. Everything is clear so far. But one day we begin to suspect that not all of the terms presented in the dictionary are really used within the application. Besides, probably some of terms which are used in components are not available in the dictionary. So we need a script to traverse all the source code files searching translation module use occurrences. Having the list of all encountered terms the script can compare it with the terms of the dictionary.


Sapid CMF reload

CMS
Sapid CMF reload
Image generated by ChatGPT (DALL·E)

Eventually I reincarnated my personal site using alpha version of Sapid CMF 2. I’m still in progress refining the CMS release, but actually the only what I brought from old version is its name. So, what is going to be?

How to Create Facebook Applications

Social Web
How to Create Facebook Applications
Image generated by ChatGPT (DALL·E)

Has it ever occurred to you to fancy about all Facebook applications are simple and similar per se? All of these virtual hugs, gifts, greeting cards, wishes, likenesses, poke, smiles, karma-exchange and other psychological “stroking” differ only with the form, in which user get their portion of attention. Thus this niche is always open for persons interested to test their own ideas. Facebook applications enroll the audience in the way viral marketing works. Users invite their friends to use the application, those friends invite new user the same way. You see, if you have a worth idea, theoretically you can obtain the audience which works out at 20 millions of Facebook users. So there is nothing surprising in that some amateur Facebook applications are sold for tens of thousand dollars.


Aspect-oriented Software Development and PHP

Refactoring
Aspect-oriented Software Development and PHP
Image generated by ChatGPT (DALL·E)

Aspect Oriented Software Development (AOSD) is a methodology meant to implement new aspects in software component using external components, but without altering the code that implements the core functionality.

The AOSD concept was applied originally by Java developers. They developed a compiler that implements the AOP (Aspect-Oriented Programming, an implementation of AOSD) white box approach, i.e. the compiler the merges the code that implements the software components core functionality with the necessary code alterations to implement the new aspects where necessary.

This paper provides an introduction into the paradigm of aspect-oriented software development (AOSD). It includes a multitude of practical examples, provided with a view to objectify such abstract approach as AOSD, as well as to help the reader easily grasp its essence and advantages. The paper is primarily intended for programmers working with PHP. Its aim is to demonstrate a way of applying AOSD in PHP-based projects already today.


Interactive Grid with Your Own Hands

JavaScript
Interactive Grid with Your Own Hands
Image generated by ChatGPT (DALL·E)

I am sure being accustomed to desktop applications GUI, users find interfaces of web-applications as extremely uncomfortable. Their notes, probably unexpressed, are timely within AJAX Age. Besides, it is not so difficult to make web-applications more user-friendly.