Poor Program Design?

Hi Griffonbait!
My experience with Borland C++ Builder is that BCB puts a declaration in the form's header file and opens up the coding window in the .cpp file ready for coding.

My understanding of programming, and the way I have taught it, is that the header file is primarily for declarations not for a project's ("solution" as VC++ calls it) code.
1. Headers files are not needed for OOP-Design
2. The reason why the implementation of the managed-windows-forms C++/CLI is in the header file is, that the windows-forms designer can work probably (that means you can either change in the designer or change in the code; the changes are reflected in both parts; there are no misterious files anymore)

-- 
Greetings
 Jochen Kalmbach
 Microsoft MVP VC++

  My blog about Win32 and .NET
  http://blog.kalmbachnet.de/
  
PS: Please mark an answer as "answered" if it helped!!!


Answer this question

Poor Program Design?

  • gd2q

    We are using header files in C, C++ and in the C++ extension C++/CLI. There is no need for me to explain why header files are useful. (see Stroustrup, The C++ Programming Language, 9.2.1 Header Files, 9.2.3 The One-Definition Rule).

    < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    Griffonbait has a point but it is not necessary to use OOP to explain the problem. I’m also confused to see in the header file (e.g. form1.h) “project code”. Because the code is strictly for the form, means the GUI, I can tolerate that. But I agree it looks odd. I would have added at least an additional .cpp file with all method implementations of the form class. Maybe someone from VC++ Compiler Team can give us a reasonable explanation.

     

    I can not see any major design problem. Actually, it is even clever to put the project namespace into the header file. It just looks new and a little bit different. I admit, I used the Borland C++Builder in the past. Maybe, I am little bit biased.



  • gaunmanuel

    Hi Griffonbait! > I don't understand NNTP User how you can say in 1. that OOP doesn't > need header files when you check out the form's .cpp file - it > certainly includes headers. Am I missing something here OOP does not define how you implement it in source code... (at least I do not know any OOP-Design-Book which relies on header-files). For example C# does not have any kind of header files... -- Greetings Jochen Kalmbach Microsoft MVP VC++ My blog about Win32 and .NET http://blog.kalmbachnet.de/ PS: Please mark an answer as "answered" if it helped!!!
  • DennisCIS

    Thankfully there is nothing stoping you from doing that yourself. I for one seem to spend most of my time diligently moving all message handlers to the .cpp file in order to somehow counter the horrible mess the IDE creates. Partial classes have been introduced in C# and VB for just this reason, so that a programmer never need look at the generated code again. It's just us poor C++ programmers that are now forced to scroll down 5 screens just to reach our first line of code, when C++ had a code separation model since the dark ages of programming.
  • Matthew Mickelson

    I don't understand NNTP User how you can say in 1. that OOP doesn't need header files when you check out the form's .cpp file - it certainly includes headers. Am I missing something here
  • Chook_rl

    I am a newcomer to these waters and have for the last 12 years been a staunch Borland C++/ C++ Builder user. I am really only a dabbler when it comes to programming (math teaching being my main profession), however I have written many OO-based programs over the years (my current project is over 3000 lines of code), as well as taught OOP to students.

    In my recent (read within the last week) move from Borland C++ Builder to MS Visual C++ I have noticed a strange way in which Visual C++ automatically starts up a method in the form's header file. That is, when I double click on say a button on a form in design view Visual C++ opens up the "click" method in the form's .h file ready for the programmer to write the code.

    My experience with Borland C++ Builder is that BCB puts a declaration in the form's header file and opens up the coding window in the .cpp file ready for coding.

    My understanding of programming, and the way I have taught it, is that the header file is primarily for declarations not for a project's ("solution" as VC++ calls it) code.

    Can anyone enlighten me or is MS VC++ promoting poor program design

  • Jon Voigt

    I found this link for changing the code generation:
    http://www.codeproject.com/dotnet/vs_templates.asp

    Changing the VC++ templates and the scripts might help. But I'm not really sure. I never did that and I would have to read more to understand.



  • Poor Program Design?