I express here 4 examples:
- Combo and CCombo are two classes with rather same interface (say ICombo), but in fact there is no common interface defined in SWT. Here is a case that happened to me; I had a number of (big) combo boxes in a SWT application, which worked fine in Windows. When I wanted to run the application on Linux, since setVisibleItemCount(int) is not implemented on GTK (actually not possible due to the way GTK combos are implemented: either a list+button or menu+button), combos covered the whole screen. If there was a common ICombo interface, I could easily change all the Linux combos to CCombo (which supports that method).
- setText()/getText() is a very common method among widgets, which is not forced by any interface. Suppose a case that you want to implement a number of different table editors (a CCombo and a Text as an example), with a common listener. If there was an interface for widgets (like IWidget), you could then use that to handle all the table columns regardless of column number.
- Button is another example. Why should checkbox, radio button, and normal button use the same class, and for example getSelection doesn't work for button? Neither SRP, nor LSP are held here.
- There would be fine to have a simple (either without any method) interface for layout data classes. setLayoutData(Object) would better to accept a special interface, rathe bare Object :).
2 comments:
man ketab e "Somahtadayto" ro be shoma tosie mikonam. male Microsoft Press e!
من هم همينطور
س--اسد
Post a Comment