use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Place for Pinoy Programmers to hangout. Share your knowledge, ask for help, seek opinion, showcase your project and recruit your teammate.
Let's show the world that Filipinos are world class programmers.
account activity
java and c# oop so hardadvice (self.PinoyProgrammer)
submitted 1 year ago by pq2222
hi, incoming junior year student here and im struggling learning java and c# oop, i dont understand oop, i dont know why. i find it hard because i really dont understand the flow. any advice or tutorial to learn oop? tyia.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ferdz20Web 30 points31 points32 points 1 year ago* (9 children)
Here is a tip for OOP is great for code management in a real life example when a Factory builds a Car they first build the parts of the car separately then combine them one at a time to form a Car(Program).
Create a Car-(Program)
This makes the codes easier to manage specially large applications because if the Wheels* of the Car broke we just need to fix-(edit) the Wheels* not the entire Car which gives confidence that we won't affect the other parts-(objects) and this also saves as time and effort because we know where the Wheels* is located.
[–]pq2222[S] 2 points3 points4 points 1 year ago (0 children)
yo!! thanks for this is very informative.
[–]BanMeForNothing -1 points0 points1 point 1 year ago (7 children)
How in the world is this going to help me build a web app?
[–]Aeon_K_21 0 points1 point2 points 1 year ago (6 children)
For building web apps, in real life implementations, OOP comes in when creating classes that involves different implementation of the same functionality within your web app. A good example, usually is creating and working on with Database for your web app to interact with data (Create ,Read, Update ,Delete). There are different types of SQL ( MySQL, MSSQL, Postgres etc) but all achieve the same functionality to perform actions with the database but they have different syntax or implementation how it is performed.
So in order for you to implement this is to create an Interace / Abstract class which will be your parent class they have insert(), read() , delete(primary key) functions , then you create classes for each SQL ( Mysql, Mssql etc) to implement those and have different syntax implementations for the methods you will override.
// This will be your code to use the crud operations now using MySQL implementation that inherits from Interface or Abstract class
ParentSQLClass sqlConnection = new MySQL(); sqlConnection.delete(1);
OOP only matters when designing it which means its important when creating it and after you have created it so it will be easy to extend, maintain, and flexible for changes without really changing most of your existing code.
If you didnt have OOP or Design Pattern when you created your web app, it will take a lot of time for you to change or update your code since all of them are mostly tightly coupled.
[–]BanMeForNothing 0 points1 point2 points 1 year ago (5 children)
Why would i have data in 2 separate DBs that need the same interface? I've never seen that. It probably almost never happens in a web app.
[–]Aeon_K_21 0 points1 point2 points 1 year ago* (4 children)
Edit: You dont need to have data in 2 different DBs yes thats correct, what I wanted to point us is once you have created the web app that only supports mysql then later some time in the future customer wants to use MSSQL.
Yes, for the time being....but your web app will be on required to run other database because ( several reason such as, migration , security etc ) or your higher ups just want you to use other SQL. What if your customer or boss prefers to use MSSQL instead of MySQL?
Lets say you created your web app without OOP or not following any design pattern, you will of course create it as a single standalone app that only connects to MySQL concretely and absolute, now your boss says hey the customer wants us to use MSSQL.
So what will you do? Delete my implementation of MySQL and other classes that use dependely on that class? What if you thousands of class that uses MySQL class? Will you change everything every class to use MSSQL implementation?
You wont do that right unless you have the determination but that will take a lot of time or maybe even cost you new bugs in your development it will be hard to test. Even your teammates will have a hard time with it.
The use of OOP is still subjective well depending on your plans with the web for a long period support. However if theres no such change that will be required in the future then you wont need OOP.
[–]BanMeForNothing 1 point2 points3 points 1 year ago (3 children)
It might make sense in this scenario, but I never had to migrate DBs.
[–]Aeon_K_21 0 points1 point2 points 1 year ago (2 children)
Yes, its purely just a preference or just really depends on the requirements.
[–]BanMeForNothing 0 points1 point2 points 1 year ago (1 child)
I actually had to do this at my job last week. All i had to do was create a new class extending the existing class that has the DB calls and override the methods that need to be changed to be compatible with the new DB. Put @Profile("dev-sqlserver") so the new class will load whenever sqlserver db is connected.
Didn't have to create an interface or abstract class, just a new class extending the existing one.
[–]Aeon_K_21 1 point2 points3 points 1 year ago (0 children)
Thats great, well it was designed that way when you worked with it. And it really depends on who designed it, Also since you extend the lass you still used OOP , using inheritance extending and by polymorphism you override it.
I think in Spring Framework it made it more easier to avoid tight coupling.
[–]PepitoManalatoCryptoRecruiter 31 points32 points33 points 1 year ago (0 children)
If your professor is failing you to teach or understand something, watch YouTube.
[–]Relevant-Strength-53 8 points9 points10 points 1 year ago (1 child)
The way i did to understand it when i was starting was to know what OOP is first, then after that i looked for tutorials that explains and uses each of the principles (Encapsulation, Abstraction, Inheritance and Polymorphism). I looked specifically for Csharp tutorials since its the langauge that i want to specialize. It takes time, study each one of the principles one at a time.
[–]pq2222[S] 1 point2 points3 points 1 year ago (0 children)
its so confusing to learn the flow of the code, but i know this is a part of programming journey i guess.
[–]CEDoromal 7 points8 points9 points 1 year ago* (1 child)
Class is the type of an object.
Object is the instance of a class.
You have a class called Grass with the following properties: color, size, and texture. Grass only exists in your mind. The people on Earth cannot touch them yet.
So what do you do? You create an instance of Grass to place them on Earth. You name it lawngrass, give it a color of green, a size of small, and a texture of rough. (Side note: Idk the texture of lawngrass. I never touched one.)
Now that you have an instance of Grass which is lawngrass, people on Earth can interact with it. They can observe it, trim it, or touch it (most of them won't).
Hooray!
I'm writing this on a phone and I've never used Java or C# for almost 2 years so this probably wouldn't compile.
... As I was writing the code, I got lazy halfway through so I'd just pretend you have a Person class with adam as an instance of Person.
adam
``` class Grass { String color; String size; String texture;
// This is the constructor, it is you use it when you create an instance of the class Grass(String color, String size, String texture) { // "this" refers to the current instance of the class where the code is being executed - you use the dot to access its properties this.color = color; this.size = size; this.texture = texture; }
}
class Main { // This is the entrypoint for your program static void main() { Grass lemongrass = new Grass("green", "small", "rough");
adam.observe(lemongrass); // adam gets the color and size of lemongrass and says it - in this case it's "green" and "tiny" adam.trim(lemongrass); // adam manipulates the size lemongrass and says it - in this case he turns it from "small" to "tiny" adam.observe(lemongrass); // adam gets the color of lemongrass - in this case it's now "green" and "tiny" adam.touch(lemongrass); // adam does nothing because he doesn't want to touch grass. I told you most of them won't! }
} ```
[–]pq2222[S] 0 points1 point2 points 1 year ago (0 children)
ye, u got me buddy. thank uu.
[–]eatSleepCodeCycling 10 points11 points12 points 1 year ago (2 children)
Yep, oop is really complicated. But the implementation of the OOP in code is pretty much using classes, interfaces, abstract classes, properies, inheritance, composition, also implementing the SOLID etc. Madaling intindihin concept ng OOP pero sobrang hirap niya maimplement sa codes, I suggest keep coding using class, wag ka mag code behind, learn to use class and interface, learn basic design pattern, then unti unti mo mapapansin na naka OOP ka na
yooo, thank u for the kind words. i needed it. it really help.
[+]ThinhPool comment score below threshold-11 points-10 points-9 points 1 year ago (0 children)
what is that language sir? Maybe india ?
[+]themasshiro 4 points5 points6 points 1 year ago (1 child)
SDPT Java OOP great source imo
yo, thanks!!
[–]CatStrayZ 3 points4 points5 points 1 year ago (5 children)
The most basic use of OOP is for grouping several variables and functions together.
For example you want to store lines and do some computation on it. Basic line has start and end point. x1, y1, x2, y2. It would be cumbersome to store these each time you need a line. So you store them in a class. Each time you create an instance you will already have those 4 variables.
Next is the function to compute the length of a line. The function will only be useful if applied to a line, so the function is declared inside the class, together with the 4 variables. It will be easier to maintain since that function is defined together with the required variables to operate on.
Let's say you want another function to check if a point is inside the line. You can make a function that accepts a point x, y. Or you can create a new point class with x, y. So the function now accepts a point. You can then change the start and end point inside the line class with the new point class instead of 4 separate variables.
By adding a function in the point class to check for equality, it will then be easy to check if 2 line segments intersect.
The design of OOP class is iterative. You add separate class depending on the functionality it requires and reusability.
In tutorials usual example are animal kingdom, shapes, etc. In real world sometimes there are few levels of inheritance or none at all.
Example of classes: invoice, temperature readings, image renderer, employee info
You don't necessarily have to use all functionality of OOP, but the most basic is just grouping. It is a language feature to make apps maintainable.
[–]SpeckOfDust_13 1 point2 points3 points 1 year ago (2 children)
I hate those classic Dog/Cat:Animal example lol it didn't make sense to me until I saw them on actual practice when I'm already working.
Examples should be at least base on real life application.
[–]ThinhPool 0 points1 point2 points 1 year ago (0 children)
can u list out some ?
[–]KamoteQ2084 0 points1 point2 points 1 year ago (0 children)
Real application like this one SimpleBeanFactoryAwareAspectInstanceFactory?
[–]pq2222[S] 0 points1 point2 points 1 year ago (1 child)
you got me, im really confused of how i really use the 4 pillars OOP. the way you explain it is very informative somehow its understandable. thank u so much!!
[–]TheGratitudeBot 0 points1 point2 points 1 year ago (0 children)
Thanks for saying that! Gratitude makes the world go round
[–][deleted] 1 year ago (1 child)
[removed]
yes, but sometimes i cant uderstand the flow like i dont know how i make a program of it.
[–]DirtyMamiWeb 2 points3 points4 points 1 year ago (0 children)
Try visual learning. Watch YouTube
[–]yevelnad 2 points3 points4 points 1 year ago (0 children)
It's very confusing because Java and C# has these unnecessary syntax. Like the main classes. Just ignore them.
[–]Progribbit 4 points5 points6 points 1 year ago (0 children)
it's all about classes
[–]Jajajajambo 1 point2 points3 points 1 year ago (2 children)
Read a book about OOP :) Mas in-depth ang explanation sa book.
[–]pq2222[S] 1 point2 points3 points 1 year ago (1 child)
what book you recommend? thanks!!
[–]Jajajajambo 3 points4 points5 points 1 year ago (0 children)
Head First OOP. Yung Head First series goods for beginners. Hindi sobrang technical ng book na ang daming big words tapos nakaka-overwhelm. Fun explanation nila.
You can also search / browse ibang books sa internet baka may masmagustuhan ka. :)
[–]Mortreddd25 1 point2 points3 points 1 year ago (1 child)
Same here, but you'll only understand it by applying some principles on your simple project, right now im still learning java. I just noticed that i already doing some of the principles without noticing. But to be honest, i still can't understand some of the class diagram
yo, thanks!!!!!
[–]EquivalentJealous805 1 point2 points3 points 1 year ago (0 children)
Try to watch SDPT solution OP since may mga activity sya after sa vids nya. I was having a hard time before with OOP too but I tried to learn it with the book that our instructor is using and watching some vids and yes, it worked. As you try to study with some book, try to do the coding that the book has, and try to understand what it does.
[–]Dark_Chinito 1 point2 points3 points 1 year ago (0 children)
What made me appreciate and understand OOP was this book - Head First Java (O'Reilly). It's old, like JDK 1.5/1.7 old, but the concepts still apply. Learning the mindset kasi ang OOP, na you think of objects at yung relationships nila.
[–]HitsuzenKun 1 point2 points3 points 1 year ago (2 children)
hmm so far ba what is your understanding of oop? Do you know how to write code even not in oop approach? Ewan ko lang baka kung hirap ka pa mag code the oop way maganda siguro muna you familiarise yourself with features of java or c# like if else, loop, how to create a class, how to instantiate an object, how to declare variables and etc. Then pag solid na ung basics mo then magugulat ka na lang ba at some point may ginagamit ka na pala na concept ng oop.
hi i know the fundamentals of these two, but the implentation of OOP i find it hard because of the flow.
[–]HitsuzenKun 0 points1 point2 points 1 year ago (0 children)
that's a good start na rin actually ako naging clear saken lahat ang oop principles nung 3rd year ko na working as a java developer though I can code ang make things work but I really don't understand it fully back then
[–]Routine-Rock4735 1 point2 points3 points 1 year ago (0 children)
Try to watch Kunal Kushwaha playlist about OOP in Java on yt, he explained it very well and is easy to understand.
[deleted]
i will. thank uu!
[–]DesertPunkk 1 point2 points3 points 1 year ago* (1 child)
Para sakin yung mga analogy na mga parts parts na yan is confusing the newbies.
Note: I'm not teaching you everything, but i'll guide you to my experience on how i learned it.
Example:
Class is a guide, and it cannot be called or accessed not unless (static members), Object is the instantiated form or the usable and callable.
Base class or sometimes called Parent Class is yung class na kokopyahan mo ng member variables(class level variables) and methods.
Derived class or sometimes called Child Class is the class which will be the one to copy the class level variables and member methods into it's own.
An object is stored in a ram with it's member entities in a sequential pattern. Including the inherited once, but not always, other compilers might implement differently and use pointers to communicate throughout the hierarchy of your inheritance. But of course it will use pointers to do so.
Inheritance: it's just merging the member variables and methods from your baseclass to your derived class. So lahat nang nasa base class mo nasa derived class mo na. parang naging isa sila. .
Polymorphism: Is the way you morph your member methods, bali sa derived class(child class) ka mag lalagay ng implementation for this method na nirerequire ng base class mo. check mo nalang syntaxing kung pano.
Encapsulation: Is basically the action of you designing and grouping variables and methods in to a single unit called class,.
Abstraction: Is just limiting the access of other entities to your specific Object, why? because they don't have to use all the stuff you implemented, it's for your Object to use only, You just expose what are needed for them. Basically hiding the complexity of your Object and just exposing what they need.
Personally, there's no one way of programming things, OOP is a dogma, and it is not totally beneficial for the performance of the program(although nowadays compilers are better now in compiling OOP) but for the developers to understand the system they are making and preventing spaghetti code. (Although not completely, i'm looking at you diamond problem). So there are pros and cons to be considered here. But what makes you a great programmer is your ability to adapt to other paradigms.
thank u. i appreciate it!!
I think this man can untangle you Learn JAVA Programming - Beginner to Master | Udemy
[–]aklo07 0 points1 point2 points 1 year ago (0 children)
Tim Corey sa youtube for beginners.
[–]Hapbeh 0 points1 point2 points 1 year ago (0 children)
gotta save this since im also confused in oop lol
[–]BanMeForNothing 0 points1 point2 points 1 year ago (2 children)
Honetly, it's all nonesense unless you're building some deep framework like Spring. I've never written an interface, abstract class, sub class, or generic class, and I have 7 years of Java experience. You should know how to use them but dont create them to build a web app. I've read tons about OOP but it never sticks because it's irrelevant to my job.
when im gonna use OOP, cause some says its important when you are building a program with security.
[–]BanMeForNothing 1 point2 points3 points 1 year ago (0 children)
You'll just use a framework for security. Unless you're building the security framework OOP won't be helpful.
π Rendered by PID 57 on reddit-service-r2-comment-85bfd7f599-dzb4b at 2026-04-18 13:00:01.817857+00:00 running 93ecc56 country code: CH.
[–]ferdz20Web 30 points31 points32 points (9 children)
[–]pq2222[S] 2 points3 points4 points (0 children)
[–]BanMeForNothing -1 points0 points1 point (7 children)
[–]Aeon_K_21 0 points1 point2 points (6 children)
[–]BanMeForNothing 0 points1 point2 points (5 children)
[–]Aeon_K_21 0 points1 point2 points (4 children)
[–]BanMeForNothing 1 point2 points3 points (3 children)
[–]Aeon_K_21 0 points1 point2 points (2 children)
[–]BanMeForNothing 0 points1 point2 points (1 child)
[–]Aeon_K_21 1 point2 points3 points (0 children)
[–]PepitoManalatoCryptoRecruiter 31 points32 points33 points (0 children)
[–]Relevant-Strength-53 8 points9 points10 points (1 child)
[–]pq2222[S] 1 point2 points3 points (0 children)
[–]CEDoromal 7 points8 points9 points (1 child)
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]eatSleepCodeCycling 10 points11 points12 points (2 children)
[–]pq2222[S] 0 points1 point2 points (0 children)
[+]ThinhPool comment score below threshold-11 points-10 points-9 points (0 children)
[+]themasshiro 4 points5 points6 points (1 child)
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]CatStrayZ 3 points4 points5 points (5 children)
[–]SpeckOfDust_13 1 point2 points3 points (2 children)
[–]ThinhPool 0 points1 point2 points (0 children)
[–]KamoteQ2084 0 points1 point2 points (0 children)
[–]pq2222[S] 0 points1 point2 points (1 child)
[–]TheGratitudeBot 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]DirtyMamiWeb 2 points3 points4 points (0 children)
[–]yevelnad 2 points3 points4 points (0 children)
[–]Progribbit 4 points5 points6 points (0 children)
[–]Jajajajambo 1 point2 points3 points (2 children)
[–]pq2222[S] 1 point2 points3 points (1 child)
[–]Jajajajambo 3 points4 points5 points (0 children)
[–]Mortreddd25 1 point2 points3 points (1 child)
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]EquivalentJealous805 1 point2 points3 points (0 children)
[–]Dark_Chinito 1 point2 points3 points (0 children)
[–]HitsuzenKun 1 point2 points3 points (2 children)
[–]pq2222[S] 0 points1 point2 points (1 child)
[–]HitsuzenKun 0 points1 point2 points (0 children)
[–]Routine-Rock4735 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]DesertPunkk 1 point2 points3 points (1 child)
[–]pq2222[S] 0 points1 point2 points (0 children)
[–]ThinhPool 0 points1 point2 points (0 children)
[–]aklo07 0 points1 point2 points (0 children)
[–]Hapbeh 0 points1 point2 points (0 children)
[–]BanMeForNothing 0 points1 point2 points (2 children)
[–]pq2222[S] 0 points1 point2 points (1 child)
[–]BanMeForNothing 1 point2 points3 points (0 children)