Modern Programming - part I

If you're using a modern higher order language to build applications then it will support OOP. But are you using OOP correctly? Maybe you should look at the high level OOP concept SOLID and see if any of it resonates with you.

S
Single Responsibility. Each class should have a single responsibility. Probably the best way to understand and employ this principle properly is to look at a framework. For instance a framework that has a text field component will have many methods and properties acting on that component. The single responsibility is to the text field, not a single method performing a single task.
O
Open / Closed. A class should be open for extension, but closed to modification. Of course you can make changes to your class for bug fixes etc, but the crux of this is not to break the implementation. This idea is not new, in fact I have had an article published on this very concept.
L
Liskov substitution principle. Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. Makes perfect sense and it is an area that I cover when I teach OOP. It is also this principle that allows many behavioural patterns such as the Strategy Design pattern to work.
I
Interface Segregation. This is basically a rehash of the single responsibility - only put what is needed into your interface.
D
Dependency Inversion. High level objects encapsulate low level objects to build functionality, and what this principle aims to do is decouple the dependency between the high and low level objects. This could be done with contracts to abstract classes and to some extent implementing the Adapter pattern.

I've covered 5 key principles of OOP, but what about application development? How does your development stack up against the principles of LUCID?

L
Logging. You application should log information
U
Unit testing. Your application should have unit (and functional) tests
C
Configurable. You should be able to configure your application
I
Isolate Features. Along with the SOLID principle, when features are isolated it makes it much easier to add/remove/extend
D
Documentation. Your application code should be documented

If your OOP programming doesn't utilize SOLID or you're not covering the principles of LUCID with your application development then you haven't progressed to being a modern programmer. The good news for me is that I have evolved to modern standards. The SOLID principles have been ingrained for over 10 years and the LUCID principles falling into place (as the tech became available) over the same time frame. My choice of programming language and framework allows for LUCID development, and with logging already built-in I'm proud to say that I now cover all 5 aspects of LUCID development. But how about you? How do you or your programming language stack up?

If you enjoyed this article, you might also find my discussion on Lean Principles interesting too. In my next article I will continue my modern programming series and discuss various tools that can help with the different aspects of project development.

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.