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.
- 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!
Reply to: One File == One Class or what ??
Collapse
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.
Logging in...
Previously on "One File == One Class or what ??"
Collapse
-
Guest replied
-
Guest repliedOne 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 repliedre
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 repliedRe: re
Ah, our resident expert - concise and straight to the heart of things.
Leave a comment:
-
Guest repliedre
its just sometimes convenient to have them in one file i suppose.
Leave a comment:
-
Guest repliedmonoliths
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 repliedRe: 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 repliedre
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 repliedRe: 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 repliedRe: 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 repliedmonoliths....
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 repliedmonoliths
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 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.....Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- How you think you look on LinkedIn vs what recruiters see Today 09:00
- Reports of umbrella companies’ death are greatly exaggerated Nov 28 10:11
- A new hiring fraud hinges on a limited company, a passport and ‘Ade’ Nov 27 09:21
- Is an unpaid umbrella company required to pay contractors? Nov 26 09:28
- The truth of umbrella company regulation is being misconstrued Nov 25 09:23
- Labour’s plan to regulate umbrella companies: a closer look Nov 21 09:24
- When HMRC misses an FTT deadline but still wins another CJRS case Nov 20 09:20
- How 15% employer NICs will sting the umbrella company market Nov 19 09:16
- Contracting Awards 2024 hails 19 firms as best of the best Nov 18 09:13
- How to answer at interview, ‘What’s your greatest weakness?’ Nov 14 09:59
Leave a comment: