Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
quick question 4 C programmers
#41
OOP only becomes really useful when working with a team or teams of programmers, right? If you're the only programmer working on a project, you have a "god-like", bird's eye-view of the whole thing you're trying to make, so why would you bother? I guess it must be something to do with cross-platform compatibility, and library compatibility, and crash-safety. I started reading a very good book on C++, and it started with OOP, but I didn't get to the part where the connection was made to the language. To tell you the truth, I wasn't very impressed with the concept of objects communicating with each other; it seems unnecessary, I can do it all with sub-routines and functions. I get the impression (probably wrong) that the extra formalities would have a noticeable speed impact.

Still, I will probably learn it some day; if nothing else, it will allow me to use and modify some 1st-class 3D engines around. And use some OOP 3D libraries.
Reply
#42
torstum: just because you're the only one working on a project doesn't mean OO design won't help you. In a few ways, OOP allows quicker development, reduces code duplication and increases code reuse. Basically, the benefits of encapsulation and OOP aren't negated by being a sole developer, but they may be difficult to immediately see. Besides, even solo projects grow out-of-hand, and your bird's eye view doesn't really help much when you're looking at >10000 LOC.
stylin:
Reply
#43
OOP definately helps in a team environment but for once, stylin is right about something ( :laughing: :laughing: :laughing: )...OOP has many practical uses in solo work...especially in game development or any other kind of heavy data processing applications.
\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Reply
#44
Completely OT, but I need this for something: How can I calculate the width/height of a window in VB6 just knowing the dimmensions of an image I want to put inside?

I can't remember Big Grin
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#45
Code:
form.width = imageWidth * screen.twipsPerPixelX
form.height = imageHeight * screen.twipsPerPixelY

You mean like that? Where 'form' is the form, and imageWidth/Height are the dimensions of the image, in pixels.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#46
You have to do sneaky things (like AdjustWindowRect - see MSDN) to get the size of the window decorations too.
Reply
#47
Yeah, I meant that, to calculate the window's height and width so the client area is exactly what I want to measure.

I knew how to do this a while ago but now I am amnesiac.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#48
I tend to do i like this, its just a re-write of code I found all over the web. Excuse if its filth, its old.

Code:
unsigned long YF_Window_ResizeClientArea(HWND Window_hWnd, unsigned long NewClientWidth, unsigned long NewClientHeight)
{
  RECT r1;
  RECT r2;

    /* get window dimensions and position */
    if (!GetWindowRect(Window_hWnd, &r1)) return 0;
    if (!GetClientRect(Window_hWnd, &r2)) return 0;  

    /* calculate new size based on difference between r1 and r2 and call MoveWindow */
    if (!MoveWindow(Window_hWnd, r1.left, r1.top, NewClientWidth  + ((r1.right - r1.left) - (r2.right - r2.left)), NewClientHeight + ((r1.bottom - r1.top) - (r2.bottom - r2.top)), TRUE)) return 0;
    
    /* success */
    return 1;                    
}
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#49
Quote:torstum: just because you're the only one working on a project doesn't mean OO design won't help you. In a few ways, OOP allows quicker development, reduces code duplication and increases code reuse. Basically, the benefits of encapsulation and OOP aren't negated by being a sole developer, but they may be difficult to immediately see. Besides, even solo projects grow out-of-hand, and your bird's eye view doesn't really help much when you're looking at >10000 LOC.

You're right, my biggest QBasic program is over 1000 lines, and at times it seems to be getting a bit complex. When things start getting out-of-hand, I usually create a new SUB and chuck a whole section in. Don't know if that will work if it reaches the 10000 line mark!

Is Win32 programming an example of OOP? Because I just saw some examples of code, and I simply had to look away! It's quite disgusting; 10 commands (approximately) to open a window? What's the deal there? I'm sure it's not OOP.
Reply
#50
The Win32 API is NOT OOP. It's just a rather large API that you use for Win32 programming.

And yes, 10 commands to open a window can be annoying, which is why you wrap it up in a class and never look at it again. Tongue Actually, those 10 commands can be useful, as most of them are specifying the way your window looks and acts, which you probably couldn't get out of a single function call.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)