• Albert Bennett

Get Gud : Dry/ Kiss

Updated: Feb 10, 2021

First of I'm not asking for something. I mean as of writing this my number is on the site, and I am single so... nothing stopping you.

Both DRY (Don't Repeat Yourself) and KISS (Keep it Simple Stupid) are software design principals. When followed they can lead to better designed and easier maintained code. Now with adhering to any principals, I have found that they each have a time and a place and that time isn't every-time. The reason I say this is that there can be situations when following them to strictly can lead to unnecessary complexity or even OVER-KILL (think trying to swat a fly with a bazooka). We don't want that, it is also why I believe that there are so many different variations of each principal but, you'll see that same few concepts keep coming up over and over again.

DRY some might have seen it as WET (Wasting Everyone's Time). To say that something is dry is to make sure that the code written, is as reusable and small as possible. Code re-usability can be better achieved by introducing abstractions, and by refactoring the code into smaller more manageable pieces. The overall goal should be to reduce, reuse, recycle. The benefits of this is firstly to make the code look better designed, and two easier to maintain. Also it helps to reduce the number of bugs in your software, and should help with identifying where bugs are if any occur. Again it is possible to make something overly DRY by abstracting an already small object, so watch out!

KISS actually flows well into more clean code principals. Essentially, keep methods small <20 lines. Also each method should do one thing, and only one thing(single responsibility). The benefits of using KISS is that it, again makes your code easier to maintain and also helps with

readability. The simpler, more Englishly reading your code can be the better. You are coding so that someone else will read it after all. Easier to read code == easier to maintain. Also for the love of all things codey, watch out when using magic strings/ numbers. I'd avoid them altogether if you can. And that methods at most have 4 parameters in them, anymore and it is clearly is doing more than what it needs to be.

In conclusion each principal should be used where appropriate, and each of them should be in the forefront of your mind when developing/ maintaining software.

28 views0 comments

Recent Posts

See All