News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Check Your Code's Quality with SensioLabs Insight
August 07, 2014 @ 12:25:20

On the SitePoint PHP blog today there's a new post by Peter Nijssen introducing you to the SensioLabs Insight service and how it can improve your code quality (including locating security concerns).

The quality of your code is as important as testing your application. Recently, we have seen multiple articles which hopefully helped you on your way to providing a more stable application. Today, we are going to have a closer look at SensioLabs Insight. If you used Symfony or Silex in the past, you are probably familiar with SensioLabs, since they are the main sponsor of the Symfony framework.

He quickly introduces the service, mentioning what it has to offer and how to get your account all set up (free for open source libraries but it requires the results to be public). He includes some screenshots showing what the setup and scan results of your project might look like. He shows how to get more detail on the findings and how they can easily be exported to your bug tracker for fixing. He also covers some of the configuration you can do (through a YAML file) to tell Insight things like: php.ini settings, directories to exclude and specific rules to run during the scans.

0 comments voice your opinion now!
sensiolabs insight introduction service scan code quality

Link: http://www.sitepoint.com/check-codes-quality-sensiolabs-insight/

SitePoint PHP Blog:
Legacy Code is a Cancer
August 04, 2014 @ 11:08:45

In the latest post to the SitePoint PHP blog Bruno Skvorc proposes the idea that "legacy code is a cancer" that can influence decisions and technology choices that shy away from the new and possibly more functional alternatives.

This might come out controversial, but I firmly believe there is no room for legacy code in modern systems. Allow me to elaborate before you sharpen your pitchfork and light your torch. What I mean by that is: there should be absolutely zero reason to keep implementing the functions you're adding to the new version retroactively into the old version, just because some people are still using it, even if the people using it are a vast majority.

He talks about the "support everything for as long as we can" ideal and how it can come back to bite you in the end. He suggests that, at some point, the v1 users have to "be discarded" and dropped for the upgraded version of the application. He talks about failure potentially brining around success and compares applications versus libraries and components and the upgrade path for each. He ends the post with a suggested upgrade path to move the system itself away from legacy support and into the new, latest version.

0 comments voice your opinion now!
legacy code cancer maintenance upgrade support users

Link: http://www.sitepoint.com/legacy-code-cancer/

Expert Developer:
Install PHP CodeSniffer on Windows Machine
July 29, 2014 @ 10:33:45

On the Expert Developer site there's a new tutorial showing you how to get the PHP CodeSniffer tool up and working on a Windows installation. PHP CodeSniffer provides functionality to enforce standards and best practices in your application's development (providing code quality).

In this article we will focus on improving Code Quality. Very first step towards improving code quality is to maintain coding standards across developers. [...] Here we will talk about PHP CodeSniffer, which help us to maintain coding standard across multiple developer. Dealing with CodeSniffer is much easier: create rule set, validate your file against your rule set and get the result immediately. It will immediately show how many mistakes you have made in terms of following coding standards and eventually all developer will start coding as per coding standards you have defined.

There's two main parts to the article: first is getting PEAR installed (a package manager for PHP) and then using it to install CodeSniffer. Complete instructions and commands are included as well as a few screenshots along the way.

0 comments voice your opinion now!
install tutorial codesniffer windows code quality

Link: http://www.xpertdeveloper.com/2014/07/install-php-codesniffer-on-windows-machine/

SitePoint Web Blog:
Code Manifesto Words to Live By
July 28, 2014 @ 12:45:29

The SitePoint Web blog has posted an interesting article sharing something called The Code Manifesto. The "code" referenced here isn't so much related to the actual code developers write as it is the conduct they follow in their relationships with others (on a professional level).

The tech industry has a rather bad reputation. Stories of discrimination, disrespect, sexism and outright mistreatment aren't exactly hard to come by. [...] In an industry ostensibly aimed at helping everyone to reach their potential, it's clear that when it comes to issues of equality and respect, the tech world has a long way to go. Kayla Daniels is one person working to try to change this situation. A North Carolina PHP developer, Kayla is behind The Code Manifesto, a list of values she hopes can be a small step in the right direction.

Among the points made in the manifesto are things like:

  • Discrimination limits us.
  • We are our biggest assets. None of us were born masters of our trade.
  • Respect defines us. Treat others as you wish to be treated.
  • Reactions require grace.

The Manifesto was born out of the frustration felt by Kayla in her work in technology. The six points are designed to help with two main things: respect and equality and contributing to the community...all as equals.

0 comments voice your opinion now!
code manifesto values advice conduct technology

Link: http://www.sitepoint.com/code-manifesto/

Inviqa techPortal:
"Your code sucks" - Tips on giving feedback
July 25, 2014 @ 12:15:21

If you're a part of a development team anywhere, chances are at one point or another you've asked for someone else to take a look at your code and give their opinions. Maybe it was you looking over a coworker's latest addition and it was...somewhat lacking. How can you say it in a constructive and nice way? The Inviqa techPortal has some suggestions.

Feedback on performance matters. It not only maintains quality, refines and hones performance, but it can also improve morale and trust, and build relationships. It can stop minor problems from escalating into major capability issues. It's something that every people manager or team leader should be doing as standard, and yet it's so hard to get right. For some people, giving good feedback is easy. [...] Delivering negative feedback can be a tricky process so how do you give negative feedback, or (as the much hackneyed phrase would have it) "constructive" feedback?

The post includes a list of six things to think about as you provide feedback to other developers (and even as a manager to your employees). The list suggests things like making it timely, listening to their side of things and setting a plan for resolving the issue.

0 comments voice your opinion now!
feedback tips code positive negative

Link: http://techportal.inviqa.com/2014/07/23/your-code-sucks-tips-on-giving-feedback-2/

NetTuts.com:
Refactoring Legacy Code Part 9 - Analyzing Concerns
July 24, 2014 @ 11:27:56

The NetTuts.com site has posted part nine in their series sharing helpful hints and methods for refactoring legacy code. In this new post they continue on with their example application and look at where methods should be moved to/created and mocking in their tests.

In this tutorial, we will continue to focus on our business logic. We will evaluate if RunnerFunctions.php belongs to a class and if so, to which class? We will think about concerns and where methods belong. Finally, we will learn a little bit more about the concept of mocking.

They show how to move some of the "Runner" functions from procedural to OOP, integrating them with some of the classes and methods that already exist. Tests are also included showing how it all links together. From there they get into concerns about the placement of functionality and how that relates to the work at hand. They also use Mockery to mock out some of the needed objects in their tests for the new structure.

0 comments voice your opinion now!
refactor legacy code series part6 concerns functionality mock unittest

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-9-analyzing-concerns--cms-21760

NetTuts.com:
Refactoring Legacy Code Part 8 - Inverting Dependencies for a Clean Architecture
July 10, 2014 @ 11:04:13

NetTuts.com has posted part eight in their series looking at refactoring legacy code - Inverting Dependencies for a Clean Architecture. In this latest post they move away from just refactoring the code and start to look more at fixing the architecture of the application.

Old code. Ugly code. Complicated code. Spaghetti code. Gibberish nonsense. In two words, Legacy Code. This is a series that will help you work and deal with it. It's now time to talk about architecture and how we organize our newly found layers of code. It's time to take our application and try to map it to theoretical architectural design.

They look at the current structure of the code (well, of their refactored version) and how to apply the Dependency Inversion Principle (part of the SOLID methodology) via interfaces. The code is included for the refactor as well as tests to add to their "Golden Master" test suite to ensure continued correct functionality.

0 comments voice your opinion now!
refactor legacy code series part8 inverting dependencies

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-8-inverting-dependencies-for-a-clean-architecture--cms-21659

NetTuts.com:
Refactoring Legacy Code Part 7 - Identifying the Presentation Layer
July 03, 2014 @ 12:57:39

NetTuts.com has posted part seven in their "Refactoring Legacy Code" series today, continuing on with the refactor of their example application to improve maintainability and testability. In this latest article they focus in on the presentation layer.

In this seventh chapter of our refactoring tutorials, we will do a different type of refactoring. We observed in the past lessons that there is presentation related code scattered all over our legacy code. We will try to identify all the presentation related code that we can and we will then take the necessary steps to separate it from business logic.

The tutorial starts with a look at the Single Responsibility Principle (part of the SOLID design principles) and how it relates to the idea of clean architecture. They continue down the path of separating out the business logic and isolating it from the presentation layer (the display* handling). They create an "Extract" class that combines the logic and presentation though combination functionality. They walk you through the code, showing the changes you'll need to make and the tests to match.

0 comments voice your opinion now!
refactor legacy code series part7 presentation layer isolating

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-7-identifying-the-presentation-layer--cms-21593

Codeacy Blog:
Your Greatest Code Quality Threats and How to Solve Them
June 23, 2014 @ 09:22:42

On the Codacy blog there's a recent post that looks at some of the biggest threats to code quality (six of them) and some brief advice on how you can prevent them. Code quality goes beyond just style guides and common coding practices too.

In the process of building Codacy, I've learned that software companies in different life stages have different needs in terms of code quality. Early startups have, for example, very different needs in comparison to digital agencies and freelancers. There is however a common ground that links them all together: code quality is not being taken seriously enough, regardless of the stage. If this resonates with you, take action today. Continuous improvement is the central piece of software engineering craft.

Among the six things in their list are suggestions like:

  • Using continuous integration
  • Living with broken windows
  • Heterogeneity (code styles)
  • Not using static code analysis

They also link to some tools that can help fix some of these suggestions including JSHint, some PHP static analysis tools and CSSLint for CSS.

0 comments voice your opinion now!
code quality threat suggestion opinion tools solve

Link: http://blog.codacy.com/2014/06/19/your-greatest-code-quality-threats-and-how-to-solve-them/

Derick Rethans:
Dead Code
June 18, 2014 @ 10:49:56

In his latest post Derick Rethans talks about something that plagues every project, PHP or otherwise, after its grown to a large enough size: dead code. He's been asked why his Xdebug tool finds this code in places where people don't expect, so he figured he'd answer it once and for all.

The explanation for this is rather simple. Xdebug checks code coverage by adding hooks into certain opcodes. Opcodes are the building blocks of oparrays. PHP converts each element in your script - main body, method, function - to oparrays when it parses them. The PHP engine then executes those oparrays by running some code for each opcode. Opcodes are generated, but they are not optimised. Which means that it does not remove opcodes that can not be executed.

He gets down to the opcode level and shows some output from vld on how things are being executed (and what's not). Using a simple "foo" function example, he shows the execution flow and how the "branches" of executions work through the code. In his case, the "dead code" marker is coming from the line with a closing brace from an "if" statement. He points out that it entirely depends on the lines executed as to what is marked as "dead code".

0 comments voice your opinion now!
dead code xdebug path flow branch vld

Link: http://derickrethans.nl/dead-code.html


Community Events





Don't see your event here?
Let us know!


configure threedevsandamaybe unittest library language list community series introduction code api developer interview install laravel podcast bugfix application release wordpress

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework