Category Archives: Coding

Namespace in PHP considered harmful

Coding

I’ll give you a rant about PHP 5.3’s “latest” addition of namespaces. I think this is a harmful concept in PHP, a “new” feature that needs to be understood correctly before using. My short advice for all PHP developers is: DO NOT USE NAMESPACES. I’ve seen many PHP developers in our own company and customer projects, who have started to use namespaces just fort the sake that they are new, and not knowing what they are really doing. With my background as a Java developer I can give a better perspective.

In Java there is an actual use for namespaces. Java features package visibility, which I nowadays favor over public or protected (and protected over private) because package visibility (and namespaces) can be used to create nice unit tests by putting the tested class and unit test in the same namespace. In PHP there is no package visibility, so there is no need for namespaces.

In Java, the namespaces (packages) are a very rigid system that cannot be configured in any way. However, the greatness of PHP is that there is a very dynamic and powerful mechanism called autoloader, which can be used to configure your “namespaces” as you wish. A typical legacy way to build PHP package-like -structures was for example in ZendFramework a convention to put conceptual modules in separate directories, and have an autoloader to load the classes from the corresponding directory.

However, now when an actual namespace is implemented in PHP core, many developers like to give it a try and start to use it everywhere. The outcome is that all good parts of PHP start to fade away. The classes start to get polluted with useless boilerplate just for the sake of having namespaces. Useless, hard-to-read and difficult to write use-statements have appeared to PHP classes from C and Java (and other legacy 3rd generation low-productivity languages). This is clearly bad at least from project management and productivity perspective.

When you are using PHP namespaces, all changes to everything become difficult. You are also lacking IDE tools from Java that would auto-generate your “use” statements. Since there is no real benefit in using namespaces, you will just shoot yourself in your own leg by using namespaces in PHP.

The only legitimate use of namespaces that comes in my mind is when you develop some open source, abstract, non-concrete (see http://stackoverflow.com/questions/1031135/what-is-abstractness-vs-instability-graph ) library software that would be included to your composer.json by thousands of other projects. However, if you are developing your own, concrete, non-library software for your customer or own use, all classes that you define should be in your “root namespace” and adding any other namespaces will just make you hurt. You are not probably going to offer your software publicly available to the Internet, in which case there is no need to publish a public namespace to the world, and slow your development work by adding all the boilerplate required to do so. In 99% of the cases you are doing the first, and you don’t need any namespaces for you own software.

So, DO NOT USE NAMESPACES IN PHP, unless you know what you are doing.

 

Published by:

Jeff Sutherland on Scrum – if you follow the flight plan you will be taken down

Video

Coding Management Software Engineering

Jeff Sutherland explains how Scrum was originated.

Key to the success: Make work visible

Every morning, there’s a bullet coming at you with your project’s name on it. If you follow the plan, you will be taken down. Most of the project managers don’t get out of the way. 84% of IT projects are failures.

In the daily meeting we need to debate what is the next item in the sprint backlog that we would implement that touch which component that would cause the biggest impact in the system that would emerge a new capability. The minimal change to push the capability forward.

The whole team needs to know the architecture of the system and they all needs to argue about where they touch the system to systematically produce the feature in the shortest time possible.

Conway’s Law: the culture of the organization reflects in the system architecture – you need to create an object oriented organization

Jeff Sutherland

Jeff Sutherland on Scrum

 

 

 

Published by:

gordon: the simple chef workflow

Coding Devops Linux Open Source

Nikolas Lahtinen, one of our top full-stack devops developers, wrote on his blog http://nikolas.ninja/gordon-simple-chef-workflow/

I was working on provisioning some Docker containers with Chef.

After finding the knife commands to be verbose to a degree of extreme annoyance and knife not managing the simple task of unpacking it’s own groceries, I decided there was need for an actual Chef so I called Gordon Ramsay over!

XVnCYozNo more annoying fumbling with the knife as you try to remember whether it was cookbook site download or site download cookbook or whatever. No more combing through metadata.rb and metadata.json files for dependencies. Need to create new repository? “Where was that example repo again? I swear I had the url somehere in my emails…” Don’t worry, Gordon has got you covered!

Gordon – the apt-get of Chef

To be clear, gordon is a scaffolding app used to get you out up and running in matter of minutes. Perfect for kickstarting the provisioning files for chef-solo environments such as the virtualized kinds Docker and Vagrant provide. At the moment gordon has no abilities to communicate with Chef server other than generate static files.

 

 

Read more from:

http://nikolas.ninja/gordon-simple-chef-workflow/

 

Published by:

PHZ.fi Values

Careers Coding Company Management Strategy Work Psychology

At PHZ.fi we have found a better way to develop sustainable software by following the core values of Agile Manifesto
http://www.agilemanifesto.org

Jeff Sutherland, the inventor of Scrum has elaborated the meaning of values further.
https://msdn.microsoft.com/en-us/library/dd997578.aspx

We should Individuals and interactions over processes and tools

Our core value is teamwork, which enables Collective Code Ownership and continuous learning. The sysadmins will pair with frontend developers and customers with the backend developers, trainees with senior developers. Studies have shown that when all communication obstacles have been removed, the team will perform up to 50x better than the industry average.

  • Respect for the worth of every person
  • Truth in every communication
  • Transparency of all data, actions and decisions
  • Trust that each person will support the team
  • Commitment to the team and to the team’s goals

Working software over Comprehensive documentation

By constantly refactoring the software by doing Test Driven Development, the best documentation for the software is 100% passing automated tests.

  • Define acceptance tests when defining the feature
  • Implement features serially and in priority order
  • Run acceptance tests on each feature as soon as they are implemented
  • Fix bugs that are identified as highest priority as soon as possible

Customer collaboration over contract negotiation

We have found out that the Truth doesn’t reside in our office, but we should go out of the building and find out the real customer. Since it is difficult to get the customer to come over to our office, we normally nomadically roam on-site at customer premises.

  • When the team cannot work on-site with the customer (such as consumer projects), the team must appoint a customer proxy, product owner, who is always available at the office

Responding to change over following a plan

  • It is better to adapt to change quickly rather than agree and follow a fixed contract or a plan. We have found out that even a 2 week iteration might be a too long period to fix on a certain plan, customer typically wants to change the plan even faster especially on consumer services that are in production maintaned by PHZ.fi Devops.
  • At PHZ.fi we unfortunately do not excel at fixed price and scope projects, but try to avoid them. Instead we provide an agile team for an hourly rate, and the customer can decide on the scope, priority and the length of the project flexibly. By prioritizing the highest value and highest risk customer stories to be implemented first and released frequently (daily or weekly), the highest business value can be delivered quickly and the total project risk diminishes quickly towards the end of the project.

Summary

The core PHZ.fi values are

  • High Skill
  • Teamwork
  • Feedback
  • High Quality
Published by:

Rise of PHP

Coding

Ben Ramsey provides a look at the rise of PHP, the one-time ‘silly little project’ that has transformed into a Web powerhouse, thanks to flexibility, pragmatism, and a vibrant community of Web devs. “Those early days speak volumes about PHP’s impact on Web development. Back then, our options were limited when it came to server-side processing for Web apps. PHP stepped in to fill our need for a tool that would enable us to do dynamic things on the Web. That practical flexibility captured our imaginations, and PHP has since grown up with the Web. Now powering more than 80 percent of the Web, PHP has matured into a scripting language that is especially suited to solve the Web problem. Its unique pedigree tells a story of pragmatism over theory and problem solving over purity.”

http://www.infoworld.com/article/2933858/php/php-at-20-from-pet-project-to-powerhouse.html

Published by:

Remote teams versus On-site teams

Coding

Ville Välimäki wrote:

In the recent years the speculation weather remote teams work better than on-site teams has kept growing and growing. There are many factions with conflicting opinions about this matter and I want to share my opinion about this topic as well.

Some of my background about this before starting: I’ve had alot of experience about this subject in different companies and I’ve been involved in many of different aspects of this subject personally. I’ve worked on-site with a local team developing our own product. I’ve been developing remotely with a team for a client. I’ve also worked on-site with our own team for a client. During this time I’ve learned many of the up- and downsides of both worlds.

Read More:
http://vjvalima.com/remote-teams-versus-on-site-teams/

Published by:

Path to the Dark Side

Coding

In coding not doing test automation leads you to the Dark Side. Yoda says the path to the Dark Side starts from Fear.

“Fear leads to anger.

Anger leads to hate.

Hate leads to suffering.”

Fear

In software development the path to the dark side starts also from fear of introducing new bugs. As a coder you start to fear that when you do a change to the system, you will break something (as often you actually do). I calculated once that for every 3 new lines of code, I introduce at least 5 new bugs. Generally speaking I’ve been observing that roughly 20% of all work is related to rework (in accounting, marketing, system administration, also software development) for a “professional team” that is experienced and knows their trade well has not done any special efforts to improve quality, such as Six Sigma or Zero Quality Control. I observed the defect-work ratio of my own work in Nokia, and for my surprise I was unable to introduce any improvement for over 2 years (when not doing any special effort to improve, other than just measuring).

The management fears that their new system does not work, or the customers won’t buy it once introduced, and thus postpones the launch dates to fix a few more “major” bugs and to introduce a few more “critical” new features. This management fear slows down the the go-to-market times, creates waste of excess non-released inventory of unfinished work, and slows down the big wheel of adapting the company and products to always changing market demands, which can be fatal especially for start-ups.

Anger

In agile projects, Fear prevents you from doing Refactoring causing ever increasing Technical Debt, which will cause project failure typically within 18 months (according to my experience). You start to feel angry about the huge piles of the spaghetti, bad coding practices and architecture, and also the exponentially increasing number of bugs and time to fix the quality problems. Management feels angry about the steeply increasing operational costs, bad feedback from the customers and lack of progress in new “business critical” functionality.

You notice this when somebody starts to talk about the so called Version 2.0 (i.e. complete rewriting of the application, because reasons x,y and z). Throwing away your previous work effort is a large scale waste.

Hate

If you are angry enough about your bad quality code, you will start to Hate it enough that you start to consider restarting from a clean slate as a better alternative. However, unless you fix the original reason for Fear, you will just repeat the same cycle within the next 18 months. You start to hate your work, hate your management, hate your co-workers.

Suffering

In the end you suffer and feel miserable about your life, but this is how the software development has been always done before. You are trapped into the chaos of Dark Side without way to escape the corruption and cycle of project failure.

Remedy

At PHZ.fi we fight the Dark Side of coding by embracing Behaviour and Test Driven Development (TDD, BDD) and test automation. Having a high test coverage and 100% passing unit tests, run constantly by the Continuous Integration server helps you to release from the fear of doing change. Actually you can start to Embrace the Change to achieve happiness both personally and professionally, and also create Sustainable Software with longer than a few months life-cycle (we target projects that stay maintainable for decades).

Published by: