Skip to main content

Posts

Showing posts from February, 2016

Why you need a Developer Diary

After eighteen months of use, I can safely claim how useful a a developer diary is, and why you should start using one if you don't already. ChangesUsing a single file grew too large as expected. Instead each grouping is allocated an individual file. While some of these are small, the ability to navigate easily is not lost. The simplest thing to do here is just point a browser at the directory. Navigation and searching is then built in. Each week I actively split the main file file into separate files or merge to existing content.UsesI'm increasingly finding regular needs and uses to refer back to notes. In some cases it is quicker than searching online, simply hit the bookmark and start typing.Adding notes works great when reading books or watching videos. All content recorded ends up in the same location.Do ItKeeping a developer diary is without doubt one of the most useful changes to my development process. Encouragingly others are doing similar things too, but under slight…

Gaining Ten Extra Hours a Week

For a long time my work life balance has gone through phases. Some weeks I would spend hours after work writing code. This would exceed to well beyond midnight in some cases. This phase was not sustainable but it appeared to be the norm.My other hobbies such as reading and gaming were also neglected. These too suffered from weeks of focus, followed by quieter periods.Over the course of a typical year this cycle would generally balance out, but never feel comfortable. There were always areas that lacked focus. One of my common complaints which I have shared with many other developers is around the lack of time to do anything additional to the day to day job. There always seemed to be a sacrifice.MorningsThe book Soft Skills recommends taking the first hour or two out of your weekly day to focus on important goals. This piece of advice was not going to work for me I thought. I was not a morning person.Sometime after I discovered an article from the Art Of Manliness (AoM) which gave tips…

The N+1 Problem

The N+1 problem is when multiple queries are executed against a persistent store when a reduced amount could serve the same purpose. This degrades performance, uses more memory and can cause complexity to be added to the code that processes the results. Most sources of the problem come from the poor use of ORMs or developers thinking procedurally instead of in terms of how the underlying database operates.ExampleConsider a collection of posts that each contain zero or more comments. Post Comment Comment Post Comment Comment Comment Comment Comment Post To retrieve a selection of ten posts including their comments, one option would be to query all posts then perform a query for each individual posts' comments. This would result in a total of eleven queries. While this solution works it is far from ideal. Disturbingly this solution is easily introduced when developers execute queries against databases using loops or misconfigured ORMs.SolutionsSolut…

Sproc vs ORM vs Inline vs Polyglot

With relational databases the common data access patterns tend to fall into three core options.Direct access via inline SQLStored procedures using the standard libraryORM frameworks or librariesIndividually these have both pros and cons, often leading to heated debate and discussion.InlineLeaky abstractions.Dangerous in places via SQL injection.Quick and dirty solution.Non testable by default.Useful for integration testing where dynamic input is required and safe.Stored Procedures (standard library)Can be clunky and low level to use in places.Non testable by default.Allows the use of DB specific features internally.Easy to tune and optimize as long as interface is stable.Developers can optimise the execution of queries.ORMsTestable by default.Complex, large and difficult to use correctly.Leaky abstractions.Optimisation is harder, especially for DB engineers.Mini or lightweight alternatives exist, with less of the downsides.Polyglot PersistenceThe actual decision of which data access m…