I had my interview and unfortunately I did not got picked but the director if the company was impressed of my will.
So basically I got a REAL simple assignment but it required OOP.
I made the test at my best and had the idea I could not change anything so it told them and we stopped.
Then I came home and got another bright idea what I had before.
So I recreated the assignment and tried to make it again at my best OOP.
Maybe so but this time it is not about being creative.
This was an assignment in a field where I have lite to no experience.
So being creative can come at a later time.
So my question to you, is this oop in a good way or meh oop ?
And yes I know it can always be better.
Well to be honest I think halt hat is a horrible way to tell whether someone knows oop. Having said that I can write up a quick something tomorrow to show you what I would of done.
I think it’s a really good idea to post at a forum and ask about the code you wrote :- ) That’s a good mindset to learn new things, I would think.
IMO the code makes too many assumption: it assumes that the person is going to have a name. That it needs a separate head field, but not fields for arms and legs?
The head field is an array, right? (I don’t know PHP but looks like an array.) That means it can have many heads?
Details like nose, mouth and ears shouldn’t be included, IMO, unless asked for.
I think: Add as little code as possible, nothing more than what you know for sure will be needed.
Two examples: (in Scala)
class Person { val bodyParts: List[BodyPart] }
+ some class/interface BodyPart { ... } I suppose. And to model a person with only one leg, exclude a leg from the List[BodyPart].
or: (this might be more like what they had in mind)
Thanks for your reply.
Reason I made an array of the head is because they wanted to have a array returned with as much details of the person.
I know that maybe I should made a bit clearer.
Second it’s quite hard to understand oop because people all have the same mindset but often do things differently.
You said, I think: Add as little code as possible, nothing more than what you know for sure will be needed.
While some other people say, at least make sure you have all the variables needed for your object.
So I am not trying to say you are wrong and I am right but I am just asking why as little as possible?
With as little as possible, I mean that you should indeed add all the variables needed for your object. And nothing more :- )
I didn’t realize they actually did want the details. Then it makes sense I suppose, since they did ask for it
Usually in programming people add stuff they think will be needed later, it later turns out it wasn’t needed. Howerer all assumptions about what will be needed in the future, later on forces all code in the future to be built in a certain manner, and then, when the time comes to actually add new features, doing so is a lot harder, because of all assumptions made in the past.
I haven’t seen any single tutorial that goes from beginner to advanced in one go. That would be a lot to cover in one tutorial. There are quite a few for beginners, intermediate and advanced. Just google for them.