Nice work but I think the builder pattern could be worked on.
The BrickHouse class expects arguments in its constructor (like width height etc) in the builder class you call new BrickHouse and these are not set. This would throw an exception. You should set types on these params also. Like string, int.
You are also mutating BrickHouse class properties from the builder class. This means that BrickHouse properties are public. Think encapsulation here.
It would be better to have the builder set some properties of its own class using methods like setHeight() setWidth() etc then call a build method which creates a new instance of BrickHouse with the inputted objects. Now you can make your BrickHouse properties private and you cannot create a new instance of BrickHouse without using the builder (or passing the properly required params)
Those are all fair criticisms. I'll look at the builder pattern and some other examples to see if I can update it for a later edit of the post. Especially the ones about encapsulation, that's definitely bitten me before with other code I've written 🙃
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice work but I think the builder pattern could be worked on.
The BrickHouse class expects arguments in its constructor (like width height etc) in the builder class you call new BrickHouse and these are not set. This would throw an exception. You should set types on these params also. Like string, int.
You are also mutating BrickHouse class properties from the builder class. This means that BrickHouse properties are public. Think encapsulation here.
It would be better to have the builder set some properties of its own class using methods like setHeight() setWidth() etc then call a build method which creates a new instance of BrickHouse with the inputted objects. Now you can make your BrickHouse properties private and you cannot create a new instance of BrickHouse without using the builder (or passing the properly required params)
Those are all fair criticisms. I'll look at the builder pattern and some other examples to see if I can update it for a later edit of the post. Especially the ones about encapsulation, that's definitely bitten me before with other code I've written 🙃