Sign in to follow this  

OOP...**P?

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The type of programming, i think it started with the creation of OOP, because everything before that was pretty much the same i guess, i don't recall it having a particular structure, there was good programming and bad programming, readable and unreadable, maintanable and unmaintanable, i don't recall specifications about structure.

But since OOP was created, i've heard some ppl refering to it's oposite, has funtional programming, and estructural programming.

Share this post


Link to post
Share on other sites
There are procedural(imperitive?) programming{C}, object oriented programming{C++}, functional programming{Haskel}, logical programming{Prolog}, aspect oriented programming{Any OOP Language also supports this probably}, and probably a few more. Also, I might have named some of them incorrectly. Example languages(meaning languages that encourage that paradigm) are in {}

Pure Functional Programming is very simmilar to math. Variables don't change value (you cant say X = 5 then say X = X + 1 for ex), and there are no side effects (functions can do nothing but return values based on calculations done to the function's parameters).

I can't say much about the rest really, and I could be wrong about functional programming.

For the record, Common Lisp is NOT a functional programming language. It supports every paradigm to an extreme degree.

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
For the record, Common Lisp is NOT a functional programming language. It supports every paradigm to an extreme degree.


I knew someone would say that, which is why I added "Scheme" to keep the dogs at bay. It din't work. [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by thedevdan
Quote:
Original post by Extrarius
For the record, Common Lisp is NOT a functional programming language. It supports every paradigm to an extreme degree.


I knew someone would say that, which is why I added "Scheme" to keep the dogs at bay. It din't work. [wink]


Funny, I was under the impression that Scheme dialects are by nature also classified as Lisp dialects (versions of the same type of language, ie. S-Expressions, Lists, Prefix notation, ...).

Personally I would advise that you learn about all of the types of programming paradigms learn the ones that you think will ever be useful and the use whatever best fits the task at hand (somewhat of a generic response eh?).

As for good code White Rabbit, I'm affraid that good Procedural code written in pre-C languages can still kick the ass of alot of code written in pure OO languages like Java!. It's all got to do with one's skill and perfectionist nature.

One thing to note is that some types of OO rely on another type of programming like OO's dependence on Imperitive or Functional (possibly even Declarative?, uh like Prolog).

Hope that helps somewhat.

Share this post


Link to post
Share on other sites
Hmm...interesting.

Everyone is teaching OOP, so it is really hard to find other ways of learning this stuff. Im having a hard time seeing how you would program out of OOP, but then again i didnt see how OOP would work until i actually started doing it.

What about a straight run and gun language like HTML. It runs top to bottom, in order...what kind of programming is that?

Share this post


Link to post
Share on other sites
Quote:
Original post by c-gibson-s
What about a straight run and gun language like HTML. It runs top to bottom, in order...what kind of programming is that?
I think you'll be hard pressed to find anyone who considers that programming. Considering it doesn't really do any processing at all, and obviously isn't Turing-complete, it really can't be called a programming language. Formatting language, but not programming language.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
HTML is not a programming language, it is nothing more than a script language, unless you created a program that generates compiled HTML. Then maybe it could become a programming language.

Share this post


Link to post
Share on other sites
Quote:
Original post by White Rabbit
everything before that was pretty much the same i guess, i don't recall it having a particular structure, there was good programming and bad programming, readable and unreadable, maintanable and unmaintanable, i don't recall specifications about structure.


hola!

no need to guess:

Programming Paradigm

Share this post


Link to post
Share on other sites
HTML is a markup language that describes a document's structure. Hence, "hypertext markup language." Most people don't consider HTML programming.

Any half-decent CS curriculum should include a comparative languages class in which you look at other types of programming languages. If yours doesn't, consider switching schools.
Quote:
As for good code White Rabbit, I'm affraid that good Procedural code written in pre-C languages can still kick the ass of alot of code written in pure OO languages like Java!. It's all got to do with one's skill and perfectionist nature.

What sort of documentation do you have to back up this claim?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by antareus
HTML is a markup language that describes a document's structure. Hence, "hypertext markup language." Most people don't consider HTML programming.

Any half-decent CS curriculum should include a comparative languages class in which you look at other types of programming languages. If yours doesn't, consider switching schools.
Quote:
As for good code White Rabbit, I'm affraid that good Procedural code written in pre-C languages can still kick the ass of alot of code written in pure OO languages like Java!. It's all got to do with one's skill and perfectionist nature.

What sort of documentation do you have to back up this claim?


OOP / C++ is the natural evolution of writing procedural code but all C++ classes pass a this pointer variable when calling functions/methods to indicate what object it is refering to. What do you think class functions in DLL's are mangled. Even if the pointer is not necessary. "This" seems like a little wee waste of time. Now I'm not going to argue the benefits of OOP but C++ programmers are moronic idiots sometimes, enuf said.

Share this post


Link to post
Share on other sites
Don't think of programming languages as being representative of a particular paradigm. Some languages have syntax to facilitate writing code in a particular fashion, but most languages can implement multiple paradigms, even if it's a little bit clumsy. You can write OO code in C, functional code in C++ and procedural code in Java; generic code in Python and aspect-oriented code in Lisp, too, if you wanted to.

So think of the paradigms in terms of the approaches to problem solving they represent. Keep in mind that they're not a closed set, either. New paradigms continue to evolve all the time.

Key Characteristics
Imperative/Procedural: Top-to-bottom, left-to-right program flow (but not necessarily left-to-right evaluation order; operator precedence, etc, can alter that). Obviously, all other paradigms are extensions of procedural programming.

Functional: All data are mutable functions, including code. Being mutable, this allows for a high degree of customization and flexibility, but also presents a challenge in terms of intuitive comprehensibility. Whatever the Lisp/Scheme advocates may say, it is not an easy paradigm to come to grips with.

Object-Oriented: All operations on data should be intrinsic to that data. The key concepts are encapsulation (everything about the object should be encoded within the object), data hiding (implementation details, private variables, etc, should be screen from public view) and inheritance and polymorphism (specialization of more generic object types allows for specific behaviors invoked through a common interface).

Generic: For all the hoopla over generic programming, it only matters in statically-typed languages. Dynamically-typed languages (Python, Lisp, Perl, etc) don't even have template initiatives for a reason: they don't need them. The key concept is implementing an algorithm that is correct for all data types that implement a certain interface. It is, in effect, a by-contract design technique.

Aspect-Oriented: Build functionality independent of the object type, then incorporate it into the object definition as needed. Ruby has mixins, which are a primitive implementation of this concept. AOP has really been kept under wraps, so little of use is widely known about it. Until open and public implementations are widely available as non-beta releases, I wouldn't worry about it.


That should help.

Share this post


Link to post
Share on other sites
im sure every language has their advantages and disadvantages, no need to argue about what is better.

ah i didnt think html would be considered programming, hence the name, i was just at a loss for words as to what it would be called. typing?

i get it. that link really helped petewood, gracias.

edit: nice oluseyi

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
OOP / C++ is the natural evolution of writing procedural code but all C++ classes pass a this pointer variable when calling functions/methods to indicate what object it is refering to. What do you think class functions in DLL's are mangled. Even if the pointer is not necessary. "This" seems like a little wee waste of time. Now I'm not going to argue the benefits of OOP but C++ programmers are moronic idiots sometimes, enuf said.



//OOP
//File.h
class File {
public:
File(const std::string& name);
~File();
char Read();
void Write(char);
};



//OOP?
#include "File.h"
typedef File* HFILE;

HFILE CreateFile(const char* name) {
return new File(name);
}
void DestroyFile(HFILE file) {
delete file;
}
void WriteFile(HFILE file, char c) {
file->Write(c);
}
char ReadFile(HFILE file) {
return file->Read();
}

Share this post


Link to post
Share on other sites
Quote:
Original post by petewood
Quote:
Original post by Anonymous Poster
OOP / C++ is the natural evolution of writing procedural code but all C++ classes pass a this pointer variable when calling functions/methods to indicate what object it is refering to. What do you think class functions in DLL's are mangled. Even if the pointer is not necessary. "This" seems like a little wee waste of time. Now I'm not going to argue the benefits of OOP but C++ programmers are moronic idiots sometimes, enuf said.


*** Source Snippet Removed ***

*** Source Snippet Removed ***

Yes. Both is pretty OOP - ish.
Except that second one have alot better implementation hiding.
(edit:read thread about "don't make public virtual functions" )

Share this post


Link to post
Share on other sites
Quote:
Original post by Dmytry
Yes. Both is pretty OOP - ish.
Except that second one have alot better implementation hiding.
Just wanted to point out that the Win32 API is implemented something like this. It's object-oriented, but provides a purely procedural interface (since C was the language of choice when it was developed & published).

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
@petewood:
A more useful retort would have been to point out that procedural functions that act on data require that data to be specified.

wow, that's most perfect explanation what's OOP is i ever heard in my life!

Yes,it's all is about limiting side-effects, like, functional languages have no side effects. Procedural have side effects, if you write in OOP you're specifiing what side effect you do make. Some languages force you to do that, some don't.

edit: and before someone will say something about inheritance, inheritance it IS implementation details that can be hided behind that model. You may have function Close(THandle handle) that can be used to close window ,close file, close door, and that is , it's the same as if you have inheritance and that things derives from parent named "closeable" that have virtual function "close".

as about WinAPI, almost any good system API is done in that way, when it's reasonable (except, say, OpenGL, that instead lets you to select current "thing" once for several commands, i think it's good for performance)

Share this post


Link to post
Share on other sites

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this