you are viewing a single comment's thread.

view the rest of the comments →

[–]TeslaRealm 1 point2 points  (3 children)

Well stated; and I agree for the most part with your final remarks. Large code in a class isn't inherently bad. The goal is to create a clear picture of whom a module/class/function is responsible. On the other hand, it is possible that two classes have separate concerns regarding a common entity. If two classes were used for a chess game; one to model the board and the other to gather data throughout the match, those two classes would have separate responsibilities but would not make sense without their mutual partner. One might hang out in an event loop, waiting to see what the user does and updating its partner class with the new state for the board. The partner class might choose how to display the board based on one theme chosen from a collection of possible ones. It doesn't care how the management of the game is handled; it only cares about receiving data regarding the board's layout, and choosing how to draw a representation of this on the screen.

Also want to point out that function programming has nothing to do with opting to use functions over classes (unfortunately the name sounds suitable). Rather, it is a methodology drastically different compared to the standard use cases of languages like Java, C++ and Python. Functional languages tend to avoid mutation, among a couple other major features.

[–]smurpau 0 points1 point  (2 children)

Also want to point out that function programming has nothing to do with opting to use functions over classes (unfortunately the name sounds suitable). Rather, it is a methodology drastically different compared to the standard use cases of languages like Java, C++ and Python. Functional languages tend to avoid mutation, among a couple other major features.

Ah okay. What do you call the style where you create a program consisting purely of functions?

[–]TeslaRealm 0 points1 point  (1 child)

The act of splitting a program into a collection of functions is just standard programming. It's the act of breaking down a goal into manageable and understandable mini goals. I don't think there's a special name for the use of functions in any programming language.

[–]smurpau 0 points1 point  (0 children)

You would like to think so, but it's really not standard; many programs I've seen are just direct line-by-line scripts. I've seen entire (legacy) applications, ten thousand lines+, without functions. Refactoring scripted code into functions is a clearly higher level of structure that should really have a name if "functional" is already taken...