3 ms·
I'm using object-oriented programming (OOP) and like it. For the problems described in the OP, I'm not encountering those! I want to write relatively simple c
by graycat 12y ago
I'm using object-oriented programming (OOP) and
like it. For the problems described in the OP, I'm
not encountering those!
I want to write relatively simple code, thus, want
to avoid tricky features of the software tools I
use, and so far have been successful. But this
desire means that I don't have deep experience with
tricky aspects of OOP. So, YMMV.
So far mostly my code looks just like it would have
before OOP; I've created only a few OOP classes;
and all of those are simple. I write a lot of
functions but not many classes.
Some things I do like:
(1) Can have an array of classes and, then, can sort
the array with whatever class properties want to
use as the sorting keys.
(2) Can serialize an instance of a class to a byte
array, send the byte array via TCP/IP, and
deserialize the result.
Well, the OP notes some of the dangers of
inheritance. I agree and saw the danger right away
and, thus, in the code I write try not to use
inheritance and so far have been fully successful.
But, I can think of situations where inheritance
could be useful and keep the work better organized
than not using inheritance.
But, I'd say: The main issue is just having humans
understand the code, and for that, using inheritance
or not, the main solution is just to document what
is going on.
Or, if the way around using inheritance is just
having multiple copies of the same source code, then
just document this fact so that when want to change
one of the copies, likely change all the others,
also. And, of course, generally should know all the
places in the code base where that code, or some
modification of it, is being used. Can solve such
an issue with just documentation.
Or we don't want to look to programming language
syntax and features to solve all problems of
meaning in that software, meaning better
communicated with documentation.
Gee, so far this is a polymorphic post since I
didn't way what OOP language I'm using! So, I'm
writing in Microsoft's Visual Basic .NET with their
.NET Framework, ASP.NET (for Web pages), and ADO.NET
(for using SQL Server). That Microsoft software is
awash in classes, and that architecture seems to
be working well.
Yes, that Microsoft code is awash in inheritance,
but mostly I just ignore that fact and regard it as
more just documentation than actual software. I get
by mostly ignoring inheritance because I don't use
it directly in my code.
In my project, the hard technical work was the
applied math; it turns out, given the math, the
corresponding code is simple.