I’m struggling through a project at work these days which involves adding some new functionality to an existing application that I’ve never worked on before. It’s particularly frustrating because of the extra (unnecessary) abstractions that have been added.
It got me thinking about design patterns, and software architecture.
There have been times when I took the mantra “program to interfaces not implementations” as the best way to do things. Now I completely disagree.
Over the last 2 years I have come to appreciate conciseness of code more than “perfect design”.
At work we have a Data Access Layer that abstracts out the database stuff from our application code. It’s a valid use of abstraction in that it helped us transition from one database to another relatively quickly, and that query optimizations can happen in one place and immediately everyone benefits. However the design of this layer has been pulled apart and abstracted so much that it’s nearly impossible to figure out what query will actually run for a given request. The added complexity means that using it, or adding to this Data Access Layer is difficult. As a result, one of the key benefits to properly designed code (code reuse) goes out the window.
In two cases other teams have been shown how to use this library to access data from the database. In both cases those teams have given up on trying to understand it and went for a more straight forward solution. The learning curve was too much.
Code bloat is a real problem, and Java doesn’t make any attempt to deal with it. One of my real annoyances with Java is there is just too much infrastructure code. Every line you add to a piece of software is another one to maintain. It means thinking of meaningful names for every class which seems to always change from what the class actually does. Does it really give you more power?
What got me on this is an abstraction on time series data in the application I’m looking at. On top of the Data Access Layer which already provides a time series data type return value, internal to this application there is it’s own TimeSeries interface, and Abstract time series data class which implements it and then some implementations. It’s hundreds of lines of code spread out over 10s of files just to provide the ability to cache data, and convert the frequency of the time series.
With all these interfaces, and inheritance it’s taking forever to figure out the flow control of the application.