News for hackers. Stuff that matters.
Re:Windows CoreAudio API in C# by asveikau on Thursday February 04, 2016 @06:17PM (#11038058)
> discourages ... from splitting their code into logical OOP silos

What you fail to see is those silos can be a prison. One of the worst experiences I consistently have with heavily "OOP-person" code is you come to a new source tree and there are so many little tiny do-nothing classes and interfaces in individually tiny insignificant files that you can't come fresh to the project and tell "where the meat is" by browsing the filesystem. Putting those smaller interfaces and glue in a few mid-sized thematically oriented source files can be a breath of fresh air relative to this.

Re:Windows CoreAudio API in C# by sverrirs on Thursday February 04, 2016 @06:21PM (#11038074)
Exactly this. There is a fine line with regions and they have their uses.

As an example, I was working on a project a while back that had StyleCop rules set up so stringently that nothing could live in the same file, no enums, structs, extension methods, nada. The amount of files you had to create when adding new functionality (even a minor one) was mind boggling...

Re:Windows CoreAudio API in C# by userbinator on Thursday February 04, 2016 @11:17PM (#11039368)
My experience with C# and Java agrees with you completely. As someone who didn't start with, and never quite understood, the OOP craze, the urge to make tiny pieces that have almost nothing in them is baffling. Arguments that it's "more readable" are true only locally, and understanding a single-line method does nothing for understanding the system as a whole; a significantly larger amount of cross-file jumping (and often keeping track of a very deep the call stack) is a hindrance. I suppose they do this because it gives the feeling and appearance of being highly productive, when they're really just making things more difficult for themselves and others by bloating the complexity.

The other annoyance that I often encounter at the same time is terribly long and redundant variable names, accompanied by an overdose of design patterns. ("Was it the FooFactoryInterfaceAdapterList or the FooFactoryInterfaceList that particular method was in?") An example from this article's code is GetMasterVolume() vs. GetMasterVolumeMute() --- GetMasterMute() is just as descriptive, especially when the class is already named AudioManager. There's no GetApplicationVolumeMute(), instead it nicely appears as the more succinct GetApplicationMute().

I know there are IDEs which will help you go to the right file, but it's still not as easy as just scrolling through a larger one and reading linearly. That said, excessive code duplication is to be avoided and best replaced with a function; the code referenced in this article shows signs of that, as I easily saw this fragment repeated many times, among others:

    ISimpleAudioVolume volume = GetVolumeObject(pid);
    if (volume == null)
        return;
Re:Windows CoreAudio API in C# by moonchrome on Thursday February 04, 2016 @09:00PM (#11038883)
I feel like in languages like this you shouldn't even be using filesystem to browse the code but jump in to IDE visualization tools (hopefully there are architectural docs with this stuff outlined, but if not I just look at stuff like class diagrams)
Re:Windows CoreAudio API in C# by pjmlp on Friday February 05, 2016 @04:12AM (#11040394)
You don't need to browse the filesystem when you have an IDE.