While writing code, especially when working on a new subject, you write codes that will save the day without fully understanding the subject. And these codes start causing you trouble in the future. The problem gets bigger and bigger, and you won’t be controlling it in the end. Here, I encountered this problem in these two weeks and it was not possible for me to move forward without solving this problem. In my case, this problem was to define all objects (triangle, plane, and triangle) individually, call the hit and shadow functions separately for each and calculate the coloring one by one. This has led to a situation that both eats a lot of time and confuses the codes too much. (It has almost 3000 lines of code and unfortunately, it cannot do exactly what it needs to do) To solve this problem, I created a Generic Hittable class and invoked all objects in this class. I also started to create a new generic class and use all material properties in that class. As soon as I did this, the render times I received started to shorten noticeably. After I managed to collect the values I received in one general class, it was time to solve the lighting problems. First of all, there was no shadow in the scene and I created a function under the Ray class called ShadowRay to add the shadow. In fact, you can think of it as a structure that works in a structure similar to hit and only finds shadow. Below you can find the code snippet that does this for a sphere.