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

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

Inviqa Blog:
How clean is your code?
June 13, 2014 @ 10:55:44

In this latest post to the Inviqa blog they ask the question "how clean is your code?" and offer a few tips to help it get that way (and stay that way).

During the Test Driven Development training (which includes Behat, and PHPspec) run by Marcello Duarte, I was particularly blown away by one of his many and funny analogies… "Would you have any surgery carried out by a doctor who does not wash his hands?" Everybody in the room shook their heads. Of course nobody would. There is too a high risk of complications. In software development 'infected' code can translate to bugs, bad user experience, poor performance and the complete failure of web applications.

He talks briefly about some of the lessons learned in this training session, pointing out that while it's not the easiest method to apply, it pays off in the long run of your code's "hygiene". He points out that the [Inviqa] group's success rate with TDD/BDD has reflected in the bottom line of their enterprise clients too.

0 comments voice your opinion now!
testdrivendevelopment tdd code hygiene training bdd

Link: http://inviqa.com/blog/how-clean-is-your-code/

SitePoint PHP Blog:
Autogenerate CRUD Apps with Phreeze
May 30, 2014 @ 12:45:02

On the SitePoint PHP blog today Taylor Ren has shared a tutorial about using Phreeze to easily create CRUD applications for a MySQL backend. Phreeze is made up of three parts: an MVC handler, an ORM for database interaction and the "Phreeze Builder" to generate the application code.

Back in the times of Symfony 1.x, the framework had a powerful backend module to help the developers and site administrators create a good enough app and provide necessary CRUD features to manage the database (and save us from using PHPMyAdmin). [...] In this article, we will take a look at Phreeze, a simple and easy to use PHP framework that can help us generate a MySQL CRUD backend app. I will use my book collection test site as the underlying database. Please refer to my Data Fixtures in Symfony2 article for more details on the database structure.

He walks you through the installation of Phreeze (downloaded from GitHub) and what the first page should look like when pulled up in a browser. The wizard helps with the database setup and lets you pick the tables to generate models for as well as a few other application options. He shows how to integrate this generated code with a simple Symfony2-based application and easily allow for working with the database contents. He modifies the Symfony2 code to handle some additional options to pass into the generated code and talks some about the API interface Phreeze generates automatically.

0 comments voice your opinion now!
phreeze generate code application symfony2 integration

Link: http://www.sitepoint.com/autogenerate-crud-apps-phreeze/


Community Events





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


podcast release unittest list testing install language series community refactor code introduction framework developer interview wordpress opinion laravel threedevsandamaybe api

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