Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualHodgman

Posted 06 December 2012 - 08:47 PM

Yeah, that one is responsible for this fun piece of code

Oh. Oh... I'm adding volatile to my list of keywords that should almost never, ever be used -- I think it only appears once in my entire game engine, inside a class that is just a reinvention of a C++11 standard class, meaning it doesn't need to exist.
I'd go as far as to say that if you're using the volatile keyword, you've probably got a bug.


Interesting.
The clear separation of a declaration and an implementation is one of the things I really like with C and C++.
The header file has (should have) everything I need as a _user_ of the class, and nothing more.
Makes the intention of the class very clear, and then I can "hide" the implementation in a cpp file.

Except that the header file also contains information about private member variables and methods. So you either give the client all the details about the class, or you end up using something like pimpl, which is yet another hoop to jump through that other languages have realised provides no tangible benefit.

I'm also in the camp that gets extremely bothered by the fact that in C#/Java/etc there's no separation between declaration and implementation. I really love the fact that .h files can just show you the what without the how.

I often use PIMPL-style idioms, where I'm writing the same thing 3 times, instead of twice, but still prefer it over C# style classes... It's not like writing lines of code is actually anyone's bottleneck or main time-sink when programming anyway.

One of the styles that I like is having foo.h with just the stuff the user needs to see, then foo_impl.h with the member variables/data layout, then foo.cpp with the method implementations. If you're using a foo you just need the first, if you're creating a foo you need the 2nd, or if you're working on foo you need the 3rd.

This isn't the 80's anymore. We don't have to program in vi and cc on the command line. Realistically, managing any project of a decent size without an IDE is just making work for no reason.

On the same point, C++ IDEs have features to automatically duplicate/sync the necessary lines between .h and .cpp files, if you care for that kind of thing.

#2Hodgman

Posted 06 December 2012 - 08:45 PM

Yeah, that one is responsible for this fun piece of code

Oh. Oh... I'm adding volatile to my list of keywords that should almost never, ever be used -- I think it only appears once in my entire game engine.
I'd go as far as to say that if you're using the volatile keyword, you've probably got a bug.


Interesting.
The clear separation of a declaration and an implementation is one of the things I really like with C and C++.
The header file has (should have) everything I need as a _user_ of the class, and nothing more.
Makes the intention of the class very clear, and then I can "hide" the implementation in a cpp file.

Except that the header file also contains information about private member variables and methods. So you either give the client all the details about the class, or you end up using something like pimpl, which is yet another hoop to jump through that other languages have realised provides no tangible benefit.

I'm also in the camp that gets extremely bothered by the fact that in C#/Java/etc there's no separation between declaration and implementation. I really love the fact that .h files can just show you the what without the how.

I often use PIMPL-style idioms, where I'm writing the same thing 3 times, instead of twice, but still prefer it over C# style classes... It's not like writing lines of code is actually anyone's bottleneck or main time-sink when programming anyway.

One of the styles that I like is having foo.h with just the stuff the user needs to see, then foo_impl.h with the member variables/data layout, then foo.cpp with the method implementations. If you're using a foo you just need the first, if you're creating a foo you need the 2nd, or if you're working on foo you need the 3rd.

This isn't the 80's anymore. We don't have to program in vi and cc on the command line. Realistically, managing any project of a decent size without an IDE is just making work for no reason.

On the same point, C++ IDEs have features to automatically duplicate/sync the necessary lines between .h and .cpp files, if you care for that kind of thing.

#1Hodgman

Posted 06 December 2012 - 08:42 PM


Interesting.
The clear separation of a declaration and an implementation is one of the things I really like with C and C++.
The header file has (should have) everything I need as a _user_ of the class, and nothing more.
Makes the intention of the class very clear, and then I can "hide" the implementation in a cpp file.

Except that the header file also contains information about private member variables and methods. So you either give the client all the details about the class, or you end up using something like pimpl, which is yet another hoop to jump through that other languages have realised provides no tangible benefit.

I'm also in the camp that gets extremely bothered by the fact that in C#/Java/etc there's no separation between declaration and implementation. I really love the fact that .h files can just show you the what without the how.

I often use PIMPL-style idioms, where I'm writing the same thing 3 times, instead of twice, but still prefer it over C# style classes... It's not like writing lines of code is actually anyone's bottleneck or main time-sink when programming anyway.

One of the styles that I like is having foo.h with just the stuff the user needs to see, then foo_impl.h with the member variables/data layout, then foo.cpp with the method implementations. If you're using a foo you just need the first, if you're creating a foo you need the 2nd, or if you're working on foo you need the 3rd.

This isn't the 80's anymore. We don't have to program in vi and cc on the command line. Realistically, managing any project of a decent size without an IDE is just making work for no reason.

On the same point, C++ IDEs have features to automatically duplicate/sync the necessary lines between .h and .cpp files, if you care for that kind of thing.

PARTNERS