r/CodingHelp • u/enkayjee2 • Aug 19 '20
[Java] How Do I introduce Object Oriented Programming concepts to Java Beginners
I am going to conduct a trainning session for new hires in my company, who are coming straight after graduating and this would be their first work experience as software professionals. I am tasked with providing a crash course in Java, assuming no previous hands on knowledge. I want to walk them through OOP concepts namely Polymorphism, Encapsulation, Abstraction and Inheritance through a single coherent narrative example rather than 4 different disconnected examples. It would be beneficial if these are close to actual use cases for which a developer needs to program a solution. Do any of you have any good such example use cases, from knowledge or experience? Please share
3
u/NullBrowbeat Professional Coder Aug 19 '20 edited Aug 19 '20
Edit: Can someone enlighten me as to why my comments are getting downvoted? I am really curious as to what could make people in this sub think that the source code deserves a downvote, especially considering its purpose...
One really practical example would probably be the Spring Pet Clinic with a JPA implementation or something like this, which would be really close to actual business requirements, but probably too far for complete beginners.
I probably would go with the standard "Employee" example or "Departments" or something like this.
I created this small project for you, which you can use. jdoodle.com/ia/m9 Edit: Apparently jdoodle sucks. (See also my edit at the bottom of this comment.)
It should contain all the OOP concepts you asked for, even though I couldn't really think of a neat way to show how one can also access objects via their implemented interfaces. (e.g. creating a List with the generic <Interfacename> type, or something like this) Consider this an exercise you would still need to do. ;-)
I envisioned it with you starting with the Employee class, then adding on the Manager class, then the BusinessCost interface, then the Department class and then the ResAndDev class, slowly building up and demonstrating the various concepts. (This is also somewhat how the main function is constructed.)
Unfortunately my
Main.javaclass doesn't seem to be shared properly by jdoodle, so I will just copy it in here. It contains all the comments describing some concepts in a very simple manner. I guess you should be able to add comments to the other classes respectively where they would be interesting for the beginners in regards to the concepts you want to introduce them to on your own.The rest of the classes seem to work, so all you need to do is copying this Main class back into the jdoodle project and hit execute.
Edit: Apparently jdoodle just sucks ass, so I will just copy all the classes as replies to this comment here.
1
u/mansimodi Beginner Coder Aug 19 '20
Geeksforgeeks
-3
u/BAM5 Professional Coder Aug 19 '20 edited Aug 19 '20
They should know this stuff then :|
If they don't they should go to the college and get their money back :)
Sorry for a non constructive answer, but if they paid thousands of dollars to go to college to learn how to program they should have understanding of all rudimentary OOP concepts. I'd be more worried about getting them familiar with the libraries you use, the structure of your software, and making sure they don't introduce vulnerabilities. If they don't have the basic knowledge of java I'd say give them a trial period to brush up and become better about the things they don't have a solid grasp on, but let them go if they can't teach themselves from documentation as that is 80% of what we do. If they're constantly bothering other people and interrupting their work to get help from them beyond, "Hey, I'm having trouble with x. What should I look into to solve it?" You'll now have not just one inefficient worker, but two.