• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "One File == One Class or what ??"

Collapse

  • Guest's Avatar
    Guest replied
    Mix and Match matie ....

    Since I use Java / C++ / Javascripy and C#
    I have found that it makes sense in terms of the size of .obj
    to have a C++ header and a C++ source.

    Now being that I love Microsoft Visual C++
    I have found some really wierd and wonderful
    circumstances where you need to move aspects of the
    body to the header if you go from vc6 to vc7.

    When using the document/view architecture of that
    particular compiler I often want view parameters
    at the start up of the view
    rather than in say onUpdate()
    So I often end up with more than one class per file pair.

    Clearly if you plan to create a re-usable DLL
    it makes no sense to put all the source in one or two files
    as upgrades become a right 'mare.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    One Class - > TWO FILES

    A header file for the class definition/documentation.

    A Source file for the implementation.

    When some other fecker wants to use the class, give him the header file and a library.

    Spod - In "Fcuking Amateurs" mode!

    Leave a comment:


  • Guest's Avatar
    Guest replied
    re

    yes that's right OrangeHopper.

    I thought about perhaps making a song and dance out the question but decided against this proposition due to the fact that it isn't warranted and would be unjustifiable.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: re

    Ah, our resident expert - concise and straight to the heart of things.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    re

    its just sometimes convenient to have them in one file i suppose.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    monoliths

    So it would seem from the current consensus that the one class per file arrangement is the method of choice ?? - We know that there are reasons when you *may* wish to put more than a single class in a source file, but there don't seem to be any valid reasons (or mandatory reasons for that matter) for doing so.

    I have since spoken to the guy involved and let him know of several reasons for following this approach, I still can't seem to find any decent 'guidelines' documents on the web that specifiy this though ....

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: monoliths....

    Stroustrup is watching Java and biting his nails considering to retire - he wont blame ya for not doing your C++ using correct number of files cuz he would be happy enough to know someone else is using his soon to be Latin-like language

    AtW
    C++ user since 1991

    Leave a comment:


  • Guest's Avatar
    Guest replied
    re

    i use inner classes only when they're small - say <100 lines. they are usually variants of API classes as well.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: monoliths....

    If he has 3 to 4 classes per file then presumably he has only the one header file for the class definitions. This would be regarded by many people, including Stroustrup, to be bad for a number of reasons - organisation, encapsulation, compilation dependencies.

    The only case where I would regard this arrangement as valid is if only one class is publically available and the others are private helpers to that class.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: monoliths....

    i'd create new file for every class thats either:
    a) not relevant
    b) bigger than X lines
    c) total length of file is greater than Y lines

    X could differ for different people but for me 1000 would be a good number.

    Y would be 5,000

    My personal record is file 120kb big

    Leave a comment:


  • Guest's Avatar
    Guest replied
    monoliths....

    Thats exactly what I said when I joined the project, so far he has been working alone so it hasn't bothered him. He has roughly 3 or 4 classes per file at present, and he's adding to these files all of the time. I know what I 'think' we should be doing and how we should be doing it, I just can't seem to find any evidence of this on the web (even on the Microsoft site !!). Any useful URLs etc. much appreciated......

    D

    Leave a comment:


  • Guest's Avatar
    Guest replied
    monoliths

    I have never been a fan of monolithic code. OK perhaps in the days of yore, but any language that supports splitting an application into multiple files is doing a good thing.

    It doesnt need to be OO to be a good idea, in plain C I make my code into libraries.

    Isnt modular programming seen as a good thing these days ?

    I would be worried about the competence of a developer of OO code that put everything in a single source file.
    What does he do about change control ?

    Leave a comment:


  • Guest's Avatar
    Guest started a topic One File == One Class or what ??

    One File == One Class or what ??

    A long time ago I used to develop in C++. (Okay, not that long ago ) and used to follow the 'One Class, One file' development mindframe (and still do). Today I had a discussion with another contractor with whom I work on a day-to-day basis, he has placed all of his classes in a single file (with some weird file-naming convention) instead of having the files named the same as the contained class. The question is this: what is the norm/standard/preferred method of organising your project ?? I know that it is really a matter of choice, but I feel quite strongly that the one file per class is the 'right' way to do things, not least when working on a project that has multiple developers working on the same source code 99% of the time...

    discuss.....

Working...
X