develpreneur podcast

Flexibility in OOP – Build in hooks for change

One of the essential concepts to understand is flexibility in OOP.  A good design requires the ability to extend it.  There are ways to do this.  However, they require us to incorporate mechanisms for validation and growth.  That means we need to find a balance between the core to our functionality and what can be altered as an enhancement. Flexibility in OOP – Many Options There are multiple ways to build flexibility into your object-oriented design.  We can use parameters that determine functionality, check for class types, or even plugin commands.  These are critical for an effective design as we want to keep our solution flexible enough to grow.  Anything rigid is also going to be fragile to some extent. ... Read more

develpreneur podcast

Code Consistency – Critical For Practical Polymorphism

One of the challenges of good polymorphic design is code consistency.  We are building a way to communicate with developers.  Therefore, our language or syntax needs to be easy to understand.  Likewise, we need to set and meet expectations properly. Code Consistency In Results The most common error I find in this area of coding is found in the values returned.  When we stick to native types and numbers, it tends to be easy enough to stay consistent.  However, strings and structures lend themselves to issues. For example, an address can have many properties and formats.  We may be able to start with an output of: “address line, city, state zip.”  However, addresses vary.  What happens when we want to... Read more

develpreneur podcast

Polymorphism Without Side Effects – Object-Oriented Clarity

We discussed in the previous episode how polymorphic behavior gives us a form of a common language for objects.  Thus we need to consider the idea of polymorphism without side effects, so we have clear and concise commands.  There is also a consistency required for this to be an approach that is truly useful. What Is Polymorphism Without Side Effects As always, we should start with a definition of terms.  In this case, our goal is clarity.  Polymorphism is a way to give a command each object responds to.  That means there should be similar results for each one.  As an example, if I tell several people to “get the mail,” I should be able to assume they either check... Read more

develpreneur podcast

Polymorphism Overview – Reducing code size and a better user experience

We start the next series of episodes with a polymorphism overview.  This is a core concept for proper object-oriented design.  Likewise, we will dig into several practical ways to use this. Polymorphism Overview – A Definition As with many topics, it seems best to start with a definition from Wikipedia. In programming languages and type theory, polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types. For our purposes, that symbol that is referred to can be considered a name.  The name can be a method, class, or property name. Class Vs. Object It is worth clarifying the difference between a class and an object. ... Read more

develpreneur podcast

Data Hiding – Practical Accessors

We have discussed the accessor levels of our data.  In most environments, the three levels are public, protected, and private.  In this episode, we go deeper into these concepts and a practical approach to data hiding. The Private Access Level This level of access should be our default.  It can be considered the critical step in data hiding.  Private hides our data and methods.  I find a physical example often works best for the goal of this approach.  When we purchase a physical device, we prefer fewer buttons and interface widgets over more.  The Apple iPod was a perfect example of this.  There were very few controls, so the interface was easy to understand.  Our software should follow the same... Read more

develpreneur podcast

A Practical Approach to Data Encapsulation

We have developed many bad habits over the years as OOP has proliferated frameworks and tools.  In this episode, we look at the practical side of data encapsulation and access levels like private, protected, and public. Tools Are A Beginning Modern frameworks and tools provide ways to generate a general object-oriented solution quickly.  Therefore, the tools will give us a start, but not the best solution.  There are too many details the tools are not privy to that are essential to the best solution.  We will make the best use of tools when we remember this fact.  That means we can not only move forward with generated code.  We must review what is provided and extend or remove details to... Read more