Posts

Showing posts with the label maintenance

Next generation refactoring with syntactical grep and patch from pfff

Image
Refactoring of PHP methods is often difficult: syntax errors or non-existing methods are only detected during runtime wrong method calls or uninitialized variables are only detected during runtime wrong order of parameters often remains undetected not enough unit tests to validate the changes not many resources for refactoring (time + money) We can solve most of these issues by using a few tools for syntactic analysis. You might have already worked with grep to search your code: # find a function in all PHP files (and sub-directories) grep -rin "SomeFunc(" *.php This also finds "doSomeFunc(" as well as strings or documentation containing "SomeFunc(". If you want to find all occurrences of SomeFunc() with exactly 2 parameters or at least 1 parameter, things get complicated. Happily, Facebook has released a few tools to run static analysis and source-to-source transformations on PHP code. The package is named pfff and is available on GitHub . Synta...

Applying Scrum to legacy code and maintenance tasks

There are some problems with Scrum that mainly occur when dealing with third party components or legacy systems: wrong estimations (time, impact, risk, complexity) bad requirements (inconsistent, incomplete, testable, conflicting, faulty) development involved in operations (bug analysis, data correction, deployment, hot-fixes) delays in development (bugs in legacy system, missing documentation) testing (quality/quantity of test cases, un-mockable interfaces, long running offline processes, performance issues, live and test system differ) General problems with Scrum: development (gold plating, rework, misunderstandings and bugs from collective code ownership) estimations (missing experience, excessive estimations for unpleasant stories) technical debt vs. velocity (architecture violations save deadlines) performance (stories are functional requirements, performance is normally no acceptance criteria, often only specified as "system should be fast and responsive") testing (t...

Disadvantages of ORM

ORM has attracted a lot of attention in the last years. So let's get a bit deeper into it. The biggest advantage of ORM is also the biggest disadvantage: queries are generated automatically queries can't be optimized queries select more data than needed, things get slower, more latency (some ORMs fetch all datasets of all relations of an object even though only 1 attribute is read) compiling queries from ORM code is slow (ORM compiler written in PHP) SQL is more powerful than ORM query languages database abstraction forbids vendor specific optimizations Other problems coming up with ORM compiling ORM logic from phpDoc instructions or XML files is slow, but can be cached ORM validates relations and field names outside the database, but can't keep relations consistent ORM libraries are often used in projects without making a benchmark before ORM libraries are often used because the documentation of the library says it is very fast ORM libraries are often used by default with...