R Stewart

Greenhorn
+ Follow
since Mar 22, 2017
UK
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by R Stewart

Is the code you posted copied and pasted?
If so I see 2 compile time issues:
Both classes are public and a file can only have a single public class
The package statement must be the first line in the file.
I'm not sure why the book claims the program runs, if above is accurate to the example in the book
3 years ago
Answered my own Question:

I created a bean as follows:


Then Added the following wherever needed:


Hope this might be useful to others!
3 years ago
I always found the best way to learn is to play about with it, and follow forums such as these.
I also found the mala gupta certification books to be a great source of knowledge.
3 years ago

Jesper de Jong wrote:

stewart ie wrote:Inheritance is something you are (you inherit your appearance from your parents), ...

Inheritance is the concept of children inheriting common traits from their parents.
Using the example we have above:

Both recruiters and managers are employees. Employee is their "parent".


One thing to be careful with, with regard to the concept of inheritance, is not to confuse the meaning of inheritance in biology with object oriented programming.

Too often people are talking about "parent classes" and "child classes", and comparing inheritance in programming to biological inheritance (inheriting traits from your parents).

This can be confusing, because inheritance in programming really does not mean the same thing as inheritance in biology.

In object oriented programming, inheritance means: specialization.

stewart ie wrote:To remember it I always thought about it like this: "A manager IS AN employee"


That's a much better way of thinking about inheritance in programming. There is indeed an "is a" relationship between a subclass and it's superclass; an instance of a subclass is a (special kind of) an instance of its superclass. So, a manager is a special kind of employee. It inherits the traits of its superclass Employee, and adds / implements these traits in a way that is specific for managers.

Note that in biology, inheritance does not mean specialization. A Child is not a Parent; I am not a specialized version of my father.



That's a much better way of putting it.
3 years ago
Hi guys,

I was wondering if anyone has any experience with task scheduling in Spring?
I understand you can schedule for a fixed time period or interval using annotations
https://spring.io/guides/gs/scheduling-tasks/
But I was wondering if anyone knows how to do this using dynamic user input at runtime.
For example a user schedules an email to be sent at 5:02pm exactly, is there a way add a new task dynamically using that as a time?

Thanks.

PS. I've been using this forum without an account for a while, and its a great resource, thanks to everyone who contributes!
3 years ago
The short and sweet answer:
Inheritance is something you are (you inherit your appearance from your parents), an interface is something you promise to do (you carry out the duties as a shop worker when you need to)

A longer example:
Think of an interface as a contract that an object promises to adhere to.
For example: you might have a 'Manger' object with behaviours like "writeRota()", "leadMeeting()".
you might have another object called 'Recruiter' with behaviours like "headHunt()" and "readCV()"

Both of these objects from time to time hold job interviews, and for the purpose of the interview they are both seen as "inverviewers" even though in any other light they are completely different. (as an aside, this is known as polymorphism)

So the question is, How do you get these two completely different objects to both "act as an interviewer" when needed?
You create a contract of what an interviewer is expected to do (an interface) and both Manager and Recruiter objects agree to implement the behaviours set out in the interface when needed.

An interviewer has the behaviours of "asksQuestions()" and  "makeHiringDecision()"

These are abstract behaviours meaning the interface simply tells Manager and Recruiter that they must ask questions and make a hiring decision, but doesn't detail how they should do it. That's up to the Manager or recruiter to decide individually.



Inheritance is the concept of children inheriting common traits from their parents.
Using the example we have above:

Both recruiters and managers are employees. Employee is their "parent".
Every employee regardless of role has the behaviours of "goToWork()", "collectPay()", "complainAboutJob()" etc. and attributes like "name", "address" "date of birth" etc.
So if the recruiter object inherits (or extends) Employee then it gets the traits above for free without having to implement them.

To remember it I always thought about it like this: "A manager IS AN employee"
3 years ago
I've used springboot with hibernate, JSP and websockets for some time and find it well supported by the community, very flexible and extensible.
But what you choose depends on what your needs are. If all you will be doing is sending ajax requests from your frontend to your backend with some DB persistence then any of them will work.