An iterator is simply an object that is used to traverse a data structure. Unless you are working on an old Java code base, iterator patterns are going to be few and far between. Although rare, many of the features we take for granted exist because of this pattern. It’s…
Factory Pattern Explained Simply
Creational patterns abstract the instantiation process, because sometimes using new is just not cool enough. This is because instantiation can often times lead to coupling problems. Coupling problems are not cool. When you see “new”, think “concrete”. – Head First Java While this is a play on words, it is…
Clean Code 101: Error Handling
Error handling is a balancing act. Too much and unnecessary errors will drive you insane. Too little and you have a terrible user experience. When things go wrong we are responsible for making sure that our code works. Use Exceptions Rather Than Return Codes Exceptions are new in the world…
Clean Code 101: Functions
Computers can do 2 things: store data and do things with data. Functions are what we do and describe actions we take with the data we already have (or want to create). Consider this code: Can you figure out what this function is trying to do? Probably not. This is…
Clean Code 101: Naming Conventions
Clean Code is a controversial book. When something reaches the popularity levels that book has reached, it goes from book to cult. BUT naming is one of the most overlooked, important topics of software development I think. Everyone should take so time to sit down and learn good naming conventions….
Refactoring 101: If/Switch Statements
We’ve all written if/else statements that we are not proud of lol. Sometimes we try to play god in our code and handle everything! This creates if statements that contain endless chains of nested logic. This is even compounded more by OOP where single if/else is used throughout the entire…
Primitive Obsession Code Smell: How To Spot and Fix
Primitive obsession is slang for “you use too many simple types like numbers and strings to store data”. With classes, it’s harder because you must think more intently about what you want. It’s very easy to just start adding primitives to our code and things can get out of control…
“Program to an interface” Explained Simply
“Programming to an interface” is likely one of the most followed principles in software. Why? Because we use interfaces everywhere in software without really thinking about it. In fact, you can technically program to an interface using an abstract class. Programming to an interface simply means programming to a supertype…
Many-To-Many Relationships in EF Core Explained Simply
A many-to-many relationship is conceptually similar to two many-to-one relationships connected to each other. While the history of of many-to-many relationships (or who created them) is a mystery, my theory is that the creators saw the limitations of one-to-many. A one-to-many can ONLY have exactly what it says: one parent…
Interfaces Explained Simply
Understanding what interfaces are and why we use them can be a real issue when first starting to code. The real reason we use interfaces is because (like any other programming concept) we are trying to stop duplication. Interfaces are way better at stopping duplication compared to inheritance; hence why…