Showing posts with label oo. Show all posts
Showing posts with label oo. Show all posts

Friday, April 21, 2017

OO Parenting by MS

OO Parenting by MS


I really love object orientation (OO), because it is so easy to build software using it; and it is so easy to totally screw up using it. Today I was surprised when I was trying to find out some information about the Select method in System.Windows.Forms.Control. The documentation for the Select method states what the method does and doesnt do, but it also informs what inheriting classes that does not support it. Of course, every parent class should know everything about the inheriting classes; and have documentation on everything

Excerpt from the documentation:
The Windows Forms controls in the following list are not selectable. Controls derived from controls in the list will also not be selectable.
* Label
* Panel
* GroupBox
* PictureBox
* ProgressBar
* Splitter
* LinkLabel (when there is no link present in the control)

Cmon, why put the Select method in the Control class if they know that many inheriting classes will not implement it at all. This solution/idea reeks of bad design! If a Control does not support a certain functionality, then that class should not have a method pretending to support the functionality. But this is not the first time I found a similar problem with the "design" of Windows Forms, so I will stop whining here....

Available link for download

Read more »

Saturday, April 8, 2017

OO is for suckers

OO is for suckers


Im trying to read up on .NET Forms and how they work with .NET 2.0. Im reading a quite good book "Programming Microsoft Windows Forms" by Charles Petzhold. Its a Microsoft Press book. This evening I read something that I though was quite strange. The below quote is from page 167, when the author talks about creating controls in DLLs.

"We havent been worrying much about making classes public. Its really only an issue when youre putting classes in a DLL."

So, making classes public, private, protected, package (or whaterver its named in C#) is only good when packaging everything in a DLL. I thought it was good OO to make certain classes private, public, etc. Perhaps I was wrong to put classes in different namespaces/packages so classes cant access every other class in a project. But the good thing is that Ive been enlighted, and only bother with OO when packaging everything in a DLL.

BTW, I know Im nitpicking, but I thought it was fun :)

Available link for download

Read more »