Category Archives: Coding

Fix ENOSPC error

Coding

When we were starting up our React Native project, we got the following error message:


ERROR watch /home/phz/workspace/react-mobile/node_modules/beeper ENOSPC
{"code":"ENOSPC","errno":"ENOSPC","syscall":"watch /home/phz/workspace/react-mobile/node_modules/beeper","filename":"/home/phz/workspace/react-mobile/node_modules/beeper"}
Error: watch /home/phz/workspace/react-mobile/node_modules/beeper ENOSPC
at exports._errnoException (util.js:1018:11)
at FSWatcher.start (fs.js:1443:19)
at Object.fs.watch (fs.js:1470:11)
at NodeWatcher.watchdir (/home/phz/workspace/react-mobile/node_modules/sane/src/node_watcher.js:144:20)
at Walker.<anonymous> (/home/phz/workspace/react-mobile/node_modules/sane/src/node_watcher.js:353:12)
at emitTwo (events.js:106:13)
at Walker.emit (events.js:191:7)
at /home/phz/workspace/react-mobile/node_modules/walker/lib/walker.js:69:16
at go$readdir$cb (/home/phz/workspace/react-mobile/node_modules/graceful-fs/graceful-fs.js:149:14)
at FSReqWrap.oncomplete (fs.js:123:15)

We found out that the problem is caused by having too few filesystem watches. See

http://stackoverflow.com/questions/22475849/node-js-error-enospc

The issue can be fixed by increasing the fs.

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Published by:

New Extreme Programming Adoption Record – 30.5 practices in just 6 weeks!

Careers Coding Company Software Engineering

The latest (disclosed) PHZ customer project working on-site at customer premises hit on the last week the record of fastest Extreme Programming (XP)-process adoption seen this far. The previous scores have been:

The latest record is to adopt 30 and a half practices in just 6 weeks! Our current Extreme Programming list of practices include for example Pair Programming, Test Driven Development, 100% Code Coverage and Continous Integration (to test and production environments). There are currently total of 37 practices, with the Lean 5S being the latest addition.

The benefit of having such a high XP -process maturity is that roughly after 25/37 practices the software engineering team starts to break even for the customer, i.e. they cost the same as they produce. At 30 practices the team typically produces more than they cost, and near 37 practices the team hits so called super-productivity enabling the delivery of world-class products at very high efficiency. This is the way how we claim our main sales proposition of delivering Sustainable IT Services where the life-time of the systems we deliver can reach decades compared to the few years or months when using more traditional practices.

Published by:

PHZ Full Stack pienensi bugien määrää -780%

Coding Devops

Benchmark:asimme hiljattain suurimpien toimittamiemme projektien tuottamia lopputuloksia, ja löysimme kestävän kehityksen ja korkean laadun ideologiamme tuottaneen asiakkaillemme rahassamitattavia ja huomattavia konkreettisia säästöjä.

Eräässä projektissa edellinen toimittajan tekemistä tehtävistä jopa 44% oli bugikorjauksia. Kyseisessä projektissa jossa PHZ Devops-tiimi vastaa kokonaistoimituksesta hyödyntäen testiautomaatiota ja jatkuvaa toiminnan parantamista, virheiden määrää on saatu tiputettua 5.7% tasolle eli lähes 8 kertaa aikaisempaa pienemmäksi. Laskiessa huonon laadun kustannuksia projektin kokonaiselinkaaren mitassa, uusi PHZ Full Stack Devops -toimintamalli on jo tähän mennessä tuottanut huomattavia säästöjä ja on nähtävissä että säästöt tulevat kumuloitumaan miljooniin euroihin. Samalla tuoteomistajat ovat voineet saada käyttöön jopa 8 kertaa aikaisempaa enemmän uusia ominaisuuksia, mikä on lisännyt myös palvelun käyttäjämäärää jopa 20%.

Ota yhteyttä sales (at) phz.fi tai myyntijohtaja Anne Lamberg 045 662 4501, jos haluat kuulla tarkemmin kuinka voisimme parantaa myös teidän yrityksenne ohjelmistokehitysprosessin tuottavuutta.

Published by:

Lean vs. Agile

Coding Software Engineering

There is a heated up debate going on among software development professionals about what is the difference between Agile and Lean software development? Are they rooted in the same principle or is there something fundamentally different between the two methods?

James O. Coplien explains the difference:
http://www.slideshare.net/jcoplien/20090513resund-agile

At PHZ.fi we are embracing both the methodologies, in particular Extreme Programming by the book, and eliminating the waste by reflecting on Kanban, Total Quality Management, Six Sigma and Shigeo Shingo’s Zero Quality Control.

Published by:

private considered harmful

Coding

Time after time I explain to the other coders that private visibility is harmful, 95% of coders tend to try rock hard claim otherwise. Unfortunately private is a harmful visibility level to use.

Personally I haven’t yet found any legitimate use case for private -visibility, but the opposite. Quote from the documentation of a unit testing framework:

Limitation: final, private, and static methods
Please note that final, private and static methods cannot be stubbed or mocked.

Using protected visibility instead of private by default has the advantage of leaving the opportunity for the future developers open to reuse and extend your code. Using private denies this opportunity and forces rewrite of your code. For test classes using protected is however clumsy, since you need to create a subclass to be able to mock or stub the methods or properties you want. Using dependency injection would be a better idea.

PHZ.fi has been conducting a range of code reviews for half a dozen large softwares with 150-600k lines of code. My surprising observation has been that in all the cases the code has been consisting 80% of public methods. The real life outcome thus seems to be that coders don’t really use encapsulation so often and limiting the visibility on class level is less common than using hidden interfaces (e.g. private). Of course a function is also an interface for encapsulation, and thus the one can also deduct that the coders are mostly hiding the implementation details inside one or only a few public methods rather than using large number of private methods.

In Java my best practice is to define all non-public properties and methods on package -visibility, meaning that there is no public, protected or private. If you place your test class in the same package, you can easily access also the non-public the methods or properties and for most of the time you don’t even need DI configurations.

Published by:

Responsive Image Cache features Liquid Rescale

Coding Company Frontend Start-up

Our Aalto University open source student project RIC developing a Responsive Image Cache system by using the Go language has released a couple of very cool features.

https://github.com/phzfi/ric

The project idea is to offer the ultimate solution for web responsiveness for the increasing variety of mobile devices. Instead of offering for example just 3 break points with a few different image sizes, or preconfigured image sizes, RIC automatically detects exactly the right view port size for each image and device, thus offering precisely the best possible image for each user.

For example, if you request the image asset id 123456, RIC automatically detects whether your browser supports .webp format. If not it will try the next best .png, and fallbacks to .jpg and .bmp images. See for example this image where, you don’t need to specify the format, RIC picks the best option for you:

a waterfall responsively resized

The latest two new features includes liquid rescale by adding ?mode=liquid to the img src url.

a waterfall liquid rescaled

Published by:

Rule of Two for Pair Programming

Video

Coding Software Engineering Work Psychology

SidiousVaderPromo“Always two there are. No more, no less. A master and an apprentice.” – Yoda

See a nice video on Pair Programming and Rule of Two. Pair work is not only a programming practice, but is a standard military practice ( https://en.wikipedia.org/wiki/Wingman and https://fi.wikipedia.org/wiki/Taistelijapari ) can be applied to any knowledge work such as sales and accounting, too.

Pair Programming is a agile practice with 2 people in front of 1 computer and keyboard. There are 2 roles: the Navigator one tells what to do, the Driver holds the keyboard and writes (“one police man can read, the other can write”). You switch the roles frequently. Seniors should be paired with Juniors, Customers with Coders and Sysadmins with Frontend Developers.

Pair Programming is a controversial practice where doing pair programming wrong is worse than not doing it at all. There is a vast amounts of scientific findings related to pair programming:

Programmers working in pairs usually produce shorter programs, with better designs and fewer bugs, than programmers working alone. See http://en.wikipedia.org/wiki/Pair_programming

  • Pairs typically consider more design alternatives than programmers working solo, and arrive at simpler, more-maintainable designs; they also catch design defects early.
  • Pairs usually complete work faster than one programmer assigned to the same task (but it takes 2x the effort, but this is better than well compensated by the improved productivity)
  • Programmers are less likely to skip writing unit tests, spend time web-surfing or on personal email
  • Additional benefits reported include increased morale of the team.

While Pair Programming works for the Sith, it is known to be kryptonite for

  • incompetent introverts
  • control freaks
  • super hero programmers
  • cowboy coders

See http://blogs.atlassian.com/2009/06/pair_programming_is_kryptonite/

More pair programming information is available from

Published by:

Y2038 and Sustainable Software

Coding Testing Work Psychology

Today we were fixing some old unit tests for our large marketplace software, when I stumbled upon a peculiar test case. The test, written in 2005 assumed that a suitable date far in the Future would be 2015-01-01, and was now failing.

We fixed the test case by the DoTheSimplestThingThatCouldPossiblyWork and extended the future date until Y2038.

Anyway, the morale of the story is that at least at PHZ.fi, where we endeavor to build Sustainable Software, let’s expect that our software will be used for more than 10 years, before somebody rewrites it! In our case we are still using more than 10 year old software, but since we have unit tests (that now pass 100% again), it can still produce (a lot) business value. For a developer building sustainable software over building low quality, throw-away software, makes a big difference on the impact you contribute to the world.

 

Published by: