Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What OOP coding practices should you always make time for?

Tags:

oop

rad

I tend to do a lot of projects on short deadlines and with lots of code that will never be used again, so there's always pressure/temptation to cut corners. One rule I always stick to is encapsulation/loose coupling, so I have lots of small classes rather than one giant God class. But what else should I never compromise on?

Update - thanks for the great response. Lots of people have suggested unit testing, but I don't think that's really appropriate to the kind of UI coding I do. Usability / User acceptance testing seems much important. To reiterate, I'm talking about the BARE MINIMUM of coding standards for impossible deadline projects.

like image 636
Iain Avatar asked Nov 24 '08 14:11

Iain


People also ask

What is good OOP practice?

Meaningful Names: The first practice that needs to be followed in the OOP's concept is to use meaningful names. And also, all the methods must follow the camel case naming convention. We should always make the design in such a way that one class is responsible only for one particular task.

What are the 4 basics of OOP?

Abstraction, encapsulation, inheritance, and polymorphism are four of the main principles of object-oriented programming.

What is the most important object-oriented programming principle?

Polymorphism is the most essential concept of the Object-Oriented Programming principle. It has meaning 'poly' – many, 'morph' – forms. So polymorphism means many forms. In Object-Oriented Programming, any object or method has more than one name associated with it.


2 Answers

Not OOP, but a practice that helps in both the short and long run is DRY, Don't Repeat Yourself. Don't use copy/paste inheritance.

like image 163
Corey Trager Avatar answered Sep 20 '22 19:09

Corey Trager


Not a OOP practice, but common sense ;-).

If you are in a hurry, and have to write a hack. Always add a piece of comment with the reasons. So you can trace it back and make a good solution later.

If you never had the time to come back, you always have the comment so you know, why the solution was chosen at the moment.

like image 42
Toon Krijthe Avatar answered Sep 20 '22 19:09

Toon Krijthe