openframeworks / openframeworks/openFrameworks
Constructors in openFrameworks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
We need a standardized approach to constructors.
The hardline answer is that there are only two types of constructors:
- default constructors
- copy constructors
This means that ofBuffer(const string) shouldn't exist, only ofBuffer::load(const string). That's kind of reasonable.
But it also means that ofRectangle(x,y,w,h) shouldn't exist, and that's unreasonable.
I think a good guideline is that if anything would be called load, init or setup, then it should be in a method, not a constructor. If something would be called set (simple data container) then it's ok to have a constructor.
What does everyone think? Should ofFile(string filename) exist? How about ofFile(string filename, bool binary)? How about ofImage(string filename)?
Code is cheap, but having more alternatives can make things harder to explain and more difficult to maintain, even when they're simple wrappers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are identified in the issue. Review the constructor examples for ofBuffer, ofRectangle, ofFile, and ofImage, then determine whether a consistent project-wide guideline can be agreed on; done means the API policy and its scope are documented or the issue is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100