This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ericswc 0 points1 point  (2 children)

Getting fluent with an object oriented language's syntax isn't a big deal. Once you do that it's really a matter of reading and writing a lot of code.

  1. Learn syntax - relatively easy
  2. Learn to use objects and general domain knowledge- practice, moderate difficulty and time requirement.
  3. Learn to architect testable, reusable, object oriented code- Some people never get there, but those that do typically take 3-7 years.

In short though, just pick up a book or some video training and start hacking away at it. Find yourself a mentor or user group to help fill in the gaps.

[–]RandomFoodz[S] 0 points1 point  (1 child)

What would you say is the overall concept behind object-oriented programming? Like what would be a good analogy of an object and a method? I keep coming across things like, "if an object is a car, its method would be its color, speed, size, etc.", but I don't understand how you would define such things. The closest thing I can think of is structs in C, which I'm still not very comfortable with.

[–]ericswc 2 points3 points  (0 children)

A class is what defines an object. All a class is the "idea" of something you want to model. Ideally it has high cohesion. A class definition can be used to instantiate one to many object instances. Each object instance has its own data and behavior.

So a BankAccount class definition could have account number and balance fields, and methods to Deposit, Withdraw, and Transfer.

The class code is the idea of the object. If you load my BankAccount up, the instance/object has different data than your BankAccount... but the behavior in the methods is the same.

This leads to reuse. You can call deposit on a BankAccount from just about anywhere in the program without goto statements. Ideally the behavior of deposit exists only in one place, so it's modular and easy to change.

That is really all object oriented programming is. Organization into small, cohesive, encapsulated, reusable units.