|
I found the OOP manual that came with Turbo Pascal 5.5 was very good. And thin too. I think I downloaded a PDF version recently.
|
|
|
|
|
OOP has only three pillars.
|
|
|
|
|
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I was sure someone had pointed that out.
You have just been Sharapova'd.
|
|
|
|
|
charlieg wrote: then I get a C programmer along, and here come the globals.
That's sig material right there.
|
|
|
|
|
Well, I am not about to argue that all of this should be followed. For me, inheritance more than 1 layer deep usually means I'm leveraging something really simple, so the inheritance is just stupid. Other than graphical development objects, I've not yet run across an application that really fits the textbook case of is a and was a or whatever .
The part that I really appreciated in OOD and C++ was the concept of using a class to encapsulate data and processing together. The general concept lends itself to organizing your code into definitive, understandable chunks.
And along come the globals....
Without this, you end up coupling dissimilar portions of code together, and you don't even know how you managed to do it. Pretty soon, glue is running all over interfaces, assuming you can even ascertain what your interface is. You make an innocuous refactoring in some code and the train jumps the tracks killing all aboard.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Oh my, some people still chew on the "don't put twenty elephanting parameters in a method" principle.
it ain’t broke, it doesn’t have enough features yet.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
Ummm, yes, put that in front of me, and I'm going to go look for a big stick .
I have a file - It has 6000 lines of code in it. I think sometimes Visual Studio is so good at sorting and organizing, we get lazy. All of the methods are message driven. That's just one file.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
In the Fortran days, I was working for a company that had to push the release date for their new Fortran compiler ahead: A very important customer was waiting impatiently for it. You see, the old compiler could handle only 99 arguments to a function, and his code had more than that(!)
The new compiler could accept 127 arguments, satisfying this customer, but it was prepared for up to 255. I don't know if there ever was a customer requesting that.
Another company I was working for made a linker for use by the developer of the ITT System 12 telephone exchange. The S12 programmers reached an internal limit in this linker: A module could export "only" 32767 symbols. (There was no practical limit for imports; we are talking about a single module exporting 32K symbols!) Changing the index data type from signed to unsigned 16bit integer doubled the capacity.
S12 also defined the biggest struct I have ever heard of in practical use: Approx 8300 lines. Print it out 72 lines to the page, and it makes a 120 page book... (How could you possibly create an 8300 lines long type definition? It was a message type, with a common header and a large number of variant structures following. So, it wasn't quite as crazy as it at first might sound.
|
|
|
|
|
Create a class called Globals, and stick them in there with no access restrictions.
Will Rogers never met me.
|
|
|
|
|
oh that burns But I console myself with the fact they I work at an hourly rate. The more you elephant it up, the more money I bank. I love legacy code - it's never my fault.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Sounds like the Console class to me.
|
|
|
|
|
I guess it should be called COMMON and be a byte array onto which any user might impose their own structure.
|
|
|
|
|
Now there's a great idea! Talk about reusable code; that would make it almost universal. The only thing better would be to add indirection, along with a couple of methods to expand or contract the space allocated, and we're covered for any contingency.
Will Rogers never met me.
|
|
|
|
|
Inheritance is ONLY somewhat useful?
Wow, base classes that do all of the definition, layout and heavy lifting are the lifeblood of most of my programs.
Specifically base forms that add the core functionality, are inherited multiple times in multiple ways, and that standard functionality applied across similar but different screens.
My jaw is still dropped...
BTW, most C guys are trainable. Show them how to refactor their code. Catch this in code reviews, and make sure it does not happen again.
|
|
|
|
|
Kirk - not arguing, but you've gone right where I've found inheritance to be most useful - definition, layout, base behavior of graphical items - completely agree.
What I've found is that when I start getting into more application domain objects, one needs be very, very careful.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Charlie,
Absolutely. Inheritance is core to GUI components (a button). Subclassing that, and making it a graphic button, etc. Wonderful.
But it is the ONE area of OOP that really requires "Architectural Forethought". And if I am not building a complete framework, I try to limit my inheritance requirements. But it is great when you have a client say: We need to generate a PDF of any of the given screens, and you can add that to the base class, expose the access method and bam... 40 screens now have cool functionality!
|
|
|
|
|
Now that's just a good damn idea - right up there with a brilliant flash of the obvious. You could almost leave the base class empty as a hook.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
If you are out to impress the ladies, wear a Selachimorpha costume.
'Cause every girl crazy 'bout a shark dressed man.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
But some choose to be lone sharks.
|
|
|
|
|
|
How do you Mako this stuff up?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
|
Which one: [^] ?
Them is can be pricy: [^].
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Something very fishy about that one. Nonetheless, it will tide me over until tomorrow.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|