Neo4J 2 – Understanding Collections

Neo4J 2 – Understanding Collections

In Cypher, to fetch a Person with their email addresses and phone numbers, you might write a straight forward query like this:

MATCH (person:Person)
MATCH person-[:HAS_EMAIL]->email
MATCH person-[:HAS_PHONE]->phone
RETURN person,
       collect(distinct email),
       collect(distinct phone)

In this article, we will try to get a better understanding of collections in Cypher. At first, we will look under the hood to see how this query is run, understand why it is an expensive job and finally, how we can optimise it and avoid this undesired behaviour in the future.

Continue reading “Neo4J 2 – Understanding Collections”

Advertisement

Neo4J 2 – Joins in Cypher

Neo4J 2 – Joins in Cypher

The OPTIONAL MATCH clause is a way of fetching related data off a node, without affecting the main query. It allows us to perform some joins similar to the ones we know from SQL, see image below. We will discuss in detail how MATCH and OPTIONAL MATCH clauses can lend themselves towards constructing the joins.

Note: We will not be covering right joins as they are costly to perform in graph database, it is much more efficient to swap the sides and perform a flavour of left join. We also are not going to talk about Self Join.

Continue reading “Neo4J 2 – Joins in Cypher”

Software Quotes

Software Quotes

Here are some software quotes I came across and very much agree with and (try to) follow:

  • The trick is to fix the problem you have, rather than the problem you want. — Bram Cohen
  • The purpose of software engineering is to control complexity, not to create it. — Pamela Zave
  • When you feel the need to write a comment, first try to refactor the code so that any comment becomes superfluous. — Martin Fowler
  • Premature optimization is the root of all evil in programming. — C. A. R. Hoare
  • Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away. — Antoine de Saint-Exupéry
  • One of my most productive days was throwing away 1000 lines of code. — Ken Thompson
  • There is nothing more unproductive than to build something efficiently that should not have been built at all. — Milt Bryce
  • The ultimate management sin is wasting people’s time.  T. DeMarco and T. Lister
  • The fastest algorithm can frequently be replaced by one that is almost as fast and much easier to understand.  D. Jones
  • Successful software always gets changed.  Frederick P. Brooks
  • You’re bound to be unhappy if you optimize everything. — Donald E. Knuth
  • A clever person solves a problem. A wise person avoids it. — Albert Einstein
  • Everything Should Be Made as Simple as Possible, But Not Simpler. — Albert Einstein
  • Knowing is half the battle (the other half is doing). — G.I. Joe
  • When everything is connected to everything else, for better or worse, everything matters. — Bruce Mau

Future of Presentation Layer

Future of Presentation Layer

In the past, I developed desktop applications in C++, Java, Delphi, C# and Visual Basic. Across all the languages and the frameworks, the development paradigm was quite straight forward. There is a Window (a.k.a. Form) with some controls on it and you wire up the actions for them. Those actions might perform calculations, access a database, a file or all of the above. So to sum up, a single desktop application will contain the logic for user interface, business rules and data access inside it. The down side of such stubby applications (a.k.a. thick clients) is, that the storage (database or file) has to travel with it. So sharing this application with multiple users is cumbersome, generating reports is not fun and puts pressure on the local network. 

Continue reading “Future of Presentation Layer”