Since the thread question has already been satisfied and beyond, I just want to say first that it's totally fine with me to open it up to anything else you guys want, so keep posting whatever comes to your mind :) I've been learning from the discussion.
MrSwiss wrote:You talk about a largish UDT (how big really?).
[...]
The Art of writing UDT's is to make it contain only the really needed components.
(and, to avoid, what I'd term: fillers (just for convenience) additions)
Well, I don't know if I make use of the UDT in some strict form, but it certainly works well. I'm always open to new ways of doing things, though, and this is one area where I've wondered about other possibilities. It's definitely better than the disorganized mess of coding I did years ago.
In this case, my UDT is the heart of an important object. 47 properties (I will call properties because I don't remember if there's a formal word for UDT items), several of those being Types of ~8-15 other properties, as well as one Union that makes the object unique. I've used this form of code for various different projects. I'll give you a simple example (this UDT is not as large as I just mentioned), a modest GUI for a game/small project:
It is
Type _gui_obj_. Every GUI object has a number of properties, no matter what kind of object it is. x,y,z (z for layering), width, height, color, border info, parent object, etc etc, also a pointer to a private function, and of course Functions such as Init_Self, Draw_Self, etc etc. Within the UDT there is a Union that extends the object to be unique, such as a button, a list box, a check box, an input box, etc. Example:
Code: Select all
Union
As guiButton_ btn
As guiTextBox_ txt
As guiListBox_ lst
As guiCheckBox_ chk
As guiInputBox_ inb
End Union
So, this whole record is relatively largish, and saved to file with an
Enum (As EnumName) in the middle is what I was referring to as a problem for reading/writing 32/64 (until you guys gave some great suggestions.)
But on the subject of a proper UDT (or the art of a good UDT):
In the end, I have a whole GUI interface with animated buttons, objects all parented to a form which is drag-able onscreen, functions that return user interaction. I invented it from scratch using imagination and the coding skills I had at the time. It was fun, and, most importantly, it works! Is it the most formal or mature way of coding? Nah, I've learned otherwise since then. Shouldn't it be written as true OOP, probably by Extending the object rather than using Union? I would guess so, but I haven't bothered taking it to that level. I'm sure it would make more mature programmers scoff and roll their eyes :)
As I said, I'm open to suggestions and feedback, because I'm always willing to learn. However, I am the type of person who must eventually draw a line on improving what already works, and fixing what isn't broken, because I've spent a lot of years doing that, and I can't spend many more if I want to actually accomplish a finished product.
Sorry for so much explanation, I just had a big coffee. :)
I will say this (again), from 2005 (and technically earlier) up to today, I have benefited greatly from all of you, and many others, in good posts and conversations. I guess that's the whole point of the forum, but I definitely appreciate it.