Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Having hard time understanding OOP

views
     
TSEncikSejati
post Jun 1 2025, 08:37 PM, updated 7 months ago

New Member
*
Newbie
18 posts

Joined: Feb 2017
can anyone give me example ,i seem to struggle with understanding Object Oriented Programming . pening lalat woo dry.gif
SUSipohps3
post Jun 1 2025, 09:19 PM

Regular
******
Senior Member
1,974 posts

Joined: Dec 2011



ChatGPT Gemini can help
TSEncikSejati
post Jun 1 2025, 10:20 PM

New Member
*
Newbie
18 posts

Joined: Feb 2017
QUOTE(ipohps3 @ Jun 1 2025, 05:19 AM)
ChatGPT Gemini can help
*
thx !!!
flashang
post Jun 2 2025, 08:34 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(EncikSejati @ Jun 1 2025, 08:37 PM)
can anyone give me example ,i seem to struggle with understanding Object Oriented Programming . pening lalat woo  dry.gif
*
everyone learning preference are different.

some people may need to do a lot of practice, from the code and result to understand the concept,

some other need to understand the concept, then start to read / code to understand how to make it work.

in short, either read a lot, or type a lot, or both.

smile.gif



This post has been edited by flashang: Jun 2 2025, 08:39 PM
kiddokitt
post Jun 2 2025, 08:39 PM

On my way
****
Junior Member
606 posts

Joined: Oct 2014


What book are you reading to learn OOP? And which programming language?
ragk
post Jun 4 2025, 01:54 PM

BooBoo~
*******
Senior Member
2,353 posts

Joined: Apr 2009


Look for the example of the 4 principles of OOP in the language u understand, it's hard to understand the essence by just reading the theory
silkworm
post Jun 7 2025, 12:01 AM

Enthusiast
Group Icon
Elite
965 posts

Joined: Jan 2003
From: Kajang


Think of raw construction materials, like wood, sand or rocks. Used as-is, we can maybe whip up a basic shelter like a hut.

Take some sand, cement, water and pour it into a rectangular mould. We've Encapsulated those materials into a standard unit, a brick.

The shape and size of the brick is independent from the material it is made of. The brick is an Abstraction. Now we can make straight, tall walls for a house.

Perhaps the sand brick is too weak to build over a certain height, or looks ugly. Mix in some stone, or use clay, but keep the same mould dimensions. The new bricks Inherit the dimensions of the original brick but have different properties such as strength, or may be more expensive (or cheaper).

Because the dimensions of the brick are the same we can use the bricks interchangeably to achieve the desired strength, aesthetics, or cost target for our wall. They exhibit Polymorphism.

Now, recall the usual programming 101 material such as variables, functions, if-else statements, for-loops, whiles or do-whiles, etc. Those are the raw materials that we use as programmers.

silverhawk
post Jun 7 2025, 03:42 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


Exactly what is it about OOP that you find it hard to understand?
bibirbieber
post Jun 12 2025, 04:19 PM

Getting Started
**
Junior Member
237 posts

Joined: Nov 2017
Sometimes it easier to understand if you start to implement what you read/learn. Try to develop a simple projects such as daily journal or some calculation related projects. Use those Ai to guide you through this process. Then try to implement what you learned earlier.
meng6
post Jul 16 2025, 11:33 PM

Getting Started
**
Junior Member
63 posts

Joined: Aug 2020
QUOTE(silkworm @ Jun 7 2025, 12:01 AM)
Think of raw construction materials, like wood, sand or rocks. Used as-is, we can maybe whip up a basic shelter like a hut.

Take some sand, cement, water and pour it into a rectangular mould. We've Encapsulated those materials into a standard unit, a brick.

The shape and size of the brick is independent from the material it is made of. The brick is an Abstraction. Now we can make straight, tall walls for a house.

Perhaps the sand brick is too weak to build over a certain height, or looks ugly.  Mix in some stone, or use clay, but keep the same mould dimensions. The new bricks Inherit the dimensions of the original brick but have different properties such as strength, or may be more expensive (or cheaper).

Because the dimensions of the brick are the same we can use the bricks interchangeably to achieve the desired strength, aesthetics, or cost target for our wall. They exhibit Polymorphism.

Now, recall the usual programming 101 material such as variables, functions, if-else statements, for-loops, whiles or do-whiles, etc. Those are the raw materials that we use as programmers.
*
Great example thumbsup.gif
otai_g
post Jul 18 2025, 11:27 AM

On my way
****
Junior Member
623 posts

Joined: Sep 2008


the simple example to easy understand.

proton car.

car is class and proton is object.


silkworm
post Jul 18 2025, 12:25 PM

Enthusiast
Group Icon
Elite
965 posts

Joined: Jan 2003
From: Kajang


QUOTE(otai_g @ Jul 18 2025, 11:27 AM)
the simple example to easy understand.

proton car.

car is class and proton is object.
*
Almost. You could say that, "A red Proton Saga with half a tank of petrol, 79000 km on the odometer, half-worn GoodYear tyres, going at 90km/h on the PLUS highway", is an object of the Car class.

This post has been edited by silkworm: Jul 18 2025, 05:29 PM

 

Change to:
| Lo-Fi Version
0.0192sec    0.56    5 queries    GZIP Disabled
Time is now: 15th December 2025 - 08:38 PM