DEV Community

Discussion on: Refactoring: Classes for Everything?

Collapse
 
stojakovic99 profile image
Nikola Stojaković

Those that argue that the "Function" is a first class citizen in C# or Java are simply wrong, this includes Microsoft and possibly Oracle.

Can you explain this? First class citizens in programming languages are entities which support operations generally available to other entities. In this case it would be;

  • returning from method
  • being passed as a parameter
  • being assigned to a variable
  • modified

And all four things are supported by functions in both, Java and C#.

Collapse
 
jwp profile image
John Peters • Edited

Sure in C# functions only live within a class. In Javascript both a class or function are top level.

Sure there are tricks to make the C# function appear to be first class with the "using" statement but they are still required to be defined inside of a class. Why MSFT doesn't fix this is dumb.

Java is the same thing.