Reputation
726
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
4 3
Newest
 Yearling
Impact
~17k people reached

  • 0 posts edited
  • 0 helpful flags
  • 9 votes cast
23h
comment Is it ever overkill creating classes/objects?
@JörgWMittag interesting to know; I haven't played round much with Ruby or Smalltalk, and (mistakenly, clearly) gleaned that off the code samples I could find online quickly. But it sounds like that class/module duality would achieve the same thing, in that you could write a function directly in the top level of your source file, without having to nest it in a class declaration. Effectively, you could treat it as for all intents and purposes a free-standing function, even if that's not technically what's going on. Is that the case?
1d
comment Is it ever overkill creating classes/objects?
The fact that Java and C# don't allow free standing functions doesn't make it 'uncommon among OO languages'. Besides C++, Python, Ruby, Smalltalk, and Objective C and allow this. In fact, taking OO to the extreme of "everything must be in a class" seems to be a primarily Java/C# thing. Instead of standalone functions being a "throwback to C" (or to procedural programming in general), maybe it's a recognition that classes are a tool, and they don't necessarily make sense for every given thing.
Mar
11
awarded  Yearling
Mar
11
awarded  Yearling
Apr
23
awarded  Good Answer
Mar
11
awarded  Yearling
Jul
26
awarded  Nice Answer
Jun
21
answered Can the Turing machine be classified?
Mar
14
answered Which style to use for unused return parameters in a Python function call
Mar
11
answered Is there a good example of Python code for unit testing an api?
Mar
11
awarded  Teacher
Mar
11
awarded  Supporter
Mar
11
answered Defensive Programming vs Exception Handling?