develpreneur podcast

Test-Driven Development – A Better Object Oriented Design Approach

Testing and Design are often at opposite ends of the software development life-cycle.  However, test-driven development is an excellent way to drive our design.  It can help us build better classes and improve re-use.  This episode focuses on TDD and how it can point us to full-featured classes with better error handling and messages. Test-Driven Development For Design We previously looked at unit testing and class-level quality assurance.  While those are important tasks once we get the class implemented, they are better incorporated into the design process.  When we do, it ties our testing (validation) more directly to requirements.  Thus, we have goals for each bit of code to achieve.  We drive our implementation by the tests we need to... Read more

develpreneur podcast

Testing Object-Oriented Code – A Better Design Approach

We have spent a lot of time on the core concepts of object-oriented design and programming.  However, testing object-oriented code is at least as essential to our practical approach.  We need to ensure that our code is written with a quality that makes it worth re-using.  Otherwise, it is a better use of time to write new code instead of wrangle low-quality code with the idea of re-use.  We have all seen these situations where it is easier and faster to start from scratch than building on previously written code. Testing Object-Oriented Code Through Design We will focus on test-driven development in the next episode.  However, our implementation and approach to a solution can be improved with the inclusion of... Read more

develpreneur podcast

Destructors And Cleaning Up An Instance: Object-Oriented Design

When we get to the end of our use of a class instance, we need to clean up after ourselves.  This is where destructors come into play.  They are similar to constructors in a mirror fashion.  While a constructor creates an instance, a destructor removes an instance. Destructors And Resource Release Many languages have a default destructor, much as they have a default constructor.  These methods likely free up some pointers behind the scenes.  However, we also have resources and properties or even notifications that may be needed as part of this process.  That leads us to a process that effectively undoes the creation and initialization steps.  We first release resources (reverse the initialization).  Then we remove the instance from... Read more

develpreneur podcast

Constructors And Initializers In Object-Oriented Design

When we create an instance of a class, we often need to do some initialization.  Constructors and initializers achieve this goal.  These are two different ways to get our data into an instance and are an essential part of our design.  In this episode, we examine the design decisions we need to make as we decide how to use these common methods. Constructors And Initializers – The Distinction A constructor and an initializer method can be thought of in very similar ways.  However, there is one particular trait that differs between the two approaches.  A constructor returns an instance of a class, whereas an initializer sets values on an instance.  This may seem to be a minor difference.  It is... Read more

develpreneur podcast

Static Attributes And Methods In Object-Oriented Design

In this episode, we look at how to use static attributes and methods in our class design. These are important but can be over-used.  They can even be a supported way to break the object-oriented nature of our program.  We can “static” our way into a design that can not be extended.  Therefore, we need to use these sparingly and with consideration about how they may limit our solution. Static Attributes It always helps to set the stage for these types of discussions.  Static attributes and methods are not supported by all languages, nor is that always the proper terminology.  For our purposes, a “static” is a class level value or function.  Thus, there is only one version of these... Read more

develpreneur podcast

Software Design – Finding Balance With Coupling And Cohesion

We have spent a few episodes looking at cohesion and coupling.  Now it is time to find balance in these two software design approaches.  Each approach has strengths and weaknesses.  Therefore, our best approach is to combine the strengths while offsetting the weaknesses.  This best-fit approach is not as difficult to achieve as it may seem. Cache The Main Data The large object approach allows us to access data and methods quickly.  We have a short path to get to these items as the layers of abstraction have been minimalized.  The greatest value of this approach is when we have data or methods that are often used.  There is little value to this efficiency for items we rarely utilize. For... Read more