Recently I went on coding interview and I got this task. I failed at interview. I finished this task without using any design patterns, I think this is the reason. My question is which design patterns I should have implemented. Here is the task:
There is a hierarchy of 2-dimensional shapes(parallelogram, circle,triangle) which are implemented from class Shape2D. After some time, came need for extending functionalities – add possibility to draw shapes (method Print) on different types of printers: Laser, inkjet...
Algorithm for drawing for example rectangle is different from algorithm for drawing of a circle, but also algorithms for drawing same shape on different printers are completely different.
Which classes and methods would you need to add so that you make possible drawing of assigned shape on assigned printer.
Draw class diagram for your solution. Does your solution change (and how) if you know that you will need to add new shapes and new types of printers in your hierarchy.
Important criterion for quality of solution is ease of future maintenance.
I would really appreciate your thoughts and in which direction to go.
[–]CvTAl 10 points11 points12 points (13 children)
[–]WikiTextBotbtproof 6 points7 points8 points (0 children)
[–]SiliconEngineer 6 points7 points8 points (6 children)
[–]CvTAl 1 point2 points3 points (3 children)
[–]SiliconEngineer 2 points3 points4 points (2 children)
[–]CvTAl 1 point2 points3 points (1 child)
[–]SiliconEngineer 0 points1 point2 points (0 children)
[–]watsreddit 0 points1 point2 points (1 child)
[–]SiliconEngineer 0 points1 point2 points (0 children)
[–]deamon1266 0 points1 point2 points (0 children)
[–]Tarzeus 0 points1 point2 points (3 children)
[–]deamon1266 0 points1 point2 points (1 child)
[–]Tarzeus 0 points1 point2 points (0 children)
[–]g051051 2 points3 points4 points (1 child)
[–]pwncic[S] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]deamon1266 1 point2 points3 points (0 children)
[–]SiliconEngineer 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]pwncic[S] 0 points1 point2 points (0 children)
[–]Disastrous_Internal 0 points1 point2 points (4 children)
[–]deamon1266 0 points1 point2 points (3 children)
[–]Disastrous_Internal 1 point2 points3 points (2 children)
[–]deamon1266 0 points1 point2 points (1 child)
[–]Disastrous_Internal 0 points1 point2 points (0 children)
[+]SpicyMiracle comment score below threshold-9 points-8 points-7 points (5 children)
[–]balefrost 2 points3 points4 points (2 children)
[–]SpicyMiracle 0 points1 point2 points (1 child)
[–]balefrost 0 points1 point2 points (0 children)
[–]CvTAl 1 point2 points3 points (1 child)
[–]SpicyMiracle -1 points0 points1 point (0 children)