Object oriented programming mindset

Hello.

I am college student. I had Java in my last semester.

Thing is that I have previously programmed only in the procedural/ structural way (using C and PHP). And I just don't get that mindset of programming in the object oriented way.

Whenever I try to solve a problem, I tend to make my approach in the procedural way. I just can't think the OO way naturally.

So what do I do in order to change my thinking?

I have solved the small problems that were asked in my Java exam. But it's not the marks that I am concerned about. I want to be a good object oriented programmer.

I want to be able to decide for myself the best approach (structural or object oriented) for solving a type of problem. Also, it will help me in my career in an IT industry.

Thanks.
 
Start practicing one OOP concept daily. Make programs that necesserily utilize any one of the several OOP cncept daily. Furthur, try to use multiple OOP features in a single program.
 

Santa Maria!

Journeyman
OO concepts become useful when you're building a non-trivial, somewhat-large application.
Try to think in terms of 'entities' and their properties. You need to identify what the various entities are in your application, then try to logically organize your code with that in mind.

Encapsulate actions related to one entity as methods defined on that entity.
If you find that multiple entities have properties or actions in common, consider using inheritance and factor out the common behavior into a base class. And if you want to get philosophical, try and see if you can solve your problem using composition instead of inheritance.
If using inheritance, if you have a collection of objects and you want to perform an common action (method call) on all those objects, but the effect of the action must depend on the type of that object (which subclass of the base is this object?), then polymorphism comes into play.

This is an extremely general answer to your question, but your question is massively broad.
Best bet is to practice, practice, practice with hobby projects. You will eventually develop a 'feel' for thinking in terms of OO.
When you start coding up a solution, you'll be faced with more specific problems, then you can ask more specific questions :)
 

ShankJ

Been There, Done That!!
What do you mean by procedural approach?? Creating function and then proceeding??
 

ShankJ

Been There, Done That!!
Procedural programming - Wikipedia, the free encyclopedia
I have done both C(as well as C++) and JAVA so i know what is the defination of procedural programing.. I just wanted to have an idea on how the OP goes about while writing a programe and what in his terms was procedural programing..
 
OP
gdebojyoti

gdebojyoti

AFOL
I use functions only when necessary. When there is a repetitive set of tasks that need to be performed, I use functions.
 

nightcrawler

Broken In
The simplest way that helped me back when I had made the transition was to categories things into sets and subsets, group all the common tasks (starting from the simplest) into one group etc.. This helped a lot. Also try to visualise things around you like that. It is more to do with changing the mindset than anything else.

Hope this helps and best of luck with the transition :)
 

JGuru

Wise Old Owl
The best book for OOPS in Java is Beginning Java Objects by Jacquie Barker (Wrox) & Beginning Java Programming: The Object Oriented Approach by Deepak Vohra (Wrox).
 

gopi_vbboy

Cyborg Agent
I also had hard time with OOPS in java code.You have hard time
figuring out code flow.

Books can't teach OOPS accurately.You have to read code to learn OOP.

I advice download some open source project using OOPS and learn it.
 

prehistoricgamer

Q.C Passed. Tested. OK
Objective Programming is just what the name says. They are objects. Whatever application / program / software you are trying to write, try to think that the elements in them are real objects in the world. Suppose you create an object called Person, and if you relate the "Person" as an object in the real world, it has fields (characteristics) like name, height, weight, sex etc. If the object is a color, it will have entities like hue, transparency, saturation etc.

Map the program objects to real world objects and you will find it easy to write the necessary functions and operations related to them. From there on, the flow will be by itself if you've understood the real world objects well.
 

avinandan012

Cyborg Agent
DISCLAIMER : if dont want to go that deep(read: you don't care about time & space complexity) make everything static there you have some what got the procedural language :lol:.

On a serious note start using POJO in every program you can think of this should help you realizing the abstractions & inheritence.
 

Desmond

Destroy Erase Improve
Staff member
Admin
Start reading this :

*img6a.flixcart.com/image/book/2/1/4/head-first-object-oriented-analysis-design-400x400-imadg4ytfsvzzthz.jpeg

Head First Object-Oriented Analysis & Design 1st Edition - Buy Head First Object-Oriented Analysis & Design 1st Edition by Pollice, Gary|Author; West, David|Author; McLaughlin, Brett D|Author;|Author; Online at Best Prices in India - Flipkart.com
 
Top Bottom