DBTechCon – Spring 2011
DBTechCon starts today. If you are registered to attend, be sure to check your schedule for the live High Definition Streaming presentations.
Do you write SOLID code?
SOLID is an acronym from Robert Martin defining five basic principles of object oriented programming. If you are writing code in any object oriented languages such as Java, C++, C#, VB.Net, LISP, Delphi, Visual RPG (just testing with Visual RPG to see if you were awake…there is no such thing) the principles are universal, applying to all.
Here are the five principles of SOLID:
- Single Responsibilty
- Open/Closed
- Liskov Substitution
- Interface Segregation
- Dependency Inversion
The goal for applying these principles to your software development practices is that you will write software that is stable, robust, and extensible over time. For the next few editorials we’ll explore these principles at a high level. Today let’s talk about Single Responsibility.
Single Responsibility is one of the points in the Acronym that pretty much means what it says. An object has one responsibility. Applying this practice you code begins to be much more granular. This is the easiest principle to grasp…but sometimes the principle often abused.
I remember Martin Scolaro, a C++ Genius, saying, “The best method in C++ has one line.” He was not completely serious…but the point was that too many objects do too much with long run-on methods.
Smaller, more compact objects can result in more code re-use. A library of single purpose objects can be used in many projects. Each object can be tested independently of other objects much more easily than a complex object with many code paths.
Think of this as a kind of normalization of Objects instead of database tables. An object has one purpose for existence. If it looks like some other object, then use an interface or abstract class for the common aspects.
Are you a software shop using SOLID principles? Why not share with our readers the impact this practice has had for you? Send your comments to btaylor@sswug.org.
Cheers,
Ben
$$SWYNK$$
Featured Article(s)
SQL Server 2008 Linked Servers Optimization Tips
In this article, you can find some useful tips to use SQL Server 2008 linked servers.
Featured White Paper(s)
Upgrading to Microsoft SQL Server 2008 R2 from Microsoft SQL Server 2008, SQL Server 2005, and SQL Server 2000
More than ever, organizations rely on data storage and analysis for business operations. Companies need the ability to deploy… (read more)